This commit is contained in:
Royce551 2020-08-21 08:49:33 -05:00
parent 1152109f77
commit 10caac3a4d
5 changed files with 48 additions and 43 deletions

View file

@ -15,7 +15,7 @@ namespace FRESHMusicPlayer
void App_Startup(object sender, StartupEventArgs e )
{
//Force Viet for the time being
//System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("pt");
//System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("vi");
MainWindow window = new MainWindow();
window.Show();

View file

@ -49,7 +49,8 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Forms
Displayfilepaths.Add(System.IO.Path.GetFileName(path));
iterations++;
}
EditingHeader.Text = string.Format(Properties.Resources.TAGEDITOR_EDITINGHEADER, string.Join(", ", Displayfilepaths));
if (iterations <= 5) EditingHeader.Text = Properties.Resources.TAGEDITOR_EDITINGHEADER + string.Join(", ", Displayfilepaths);
else EditingHeader.Text = Properties.Resources.TAGEDITOR_EDITINGHEADER + string.Join(", ", Displayfilepaths.Take(5)) + " + " + (Displayfilepaths.Count - 4);
Title = $"{string.Join(", ", Displayfilepaths)} | FRESHMusicPlayer Tag Editor";
unsavedChanges = false;
}
@ -102,13 +103,16 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Forms
private void Player_SongChanged(object sender, EventArgs e)
{
foreach (string path in filePathsToSaveInBackground)
if (filePathsToSaveInBackground.Count != 0)
{
if (path == MainWindow.Player.FilePath) break; // still listening to files that can't be properly saved
}
SaveChanges(filePathsToSaveInBackground);
filePathsToSaveInBackground.Clear();
Close();
foreach (string path in filePathsToSaveInBackground)
{
if (path == MainWindow.Player.FilePath) break; // still listening to files that can't be properly saved
}
SaveChanges(filePathsToSaveInBackground);
filePathsToSaveInBackground.Clear();
Close();
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)

View file

@ -18,7 +18,7 @@ namespace FRESHMusicPlayer.Handlers.Notifications
}
public void Update(NotificationBox box, NotificationInfo info)
{
Notifications[Notifications.IndexOf(box)].UpdateContent(info);
Notifications[Notifications.IndexOf(box)]?.UpdateContent(info);
NotificationInvalidate?.Invoke(null, EventArgs.Empty);
}
public void Remove(NotificationBox box)

View file

@ -28,18 +28,18 @@
<DockPanel Background="#FF0C6C08">
<!--Menu-->
<DockPanel x:Name="MainBar" Height="25" DockPanel.Dock="Top" Background="{StaticResource NavBarColor}" >
<TextBlock x:Name="TracksTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_TRACKS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0,10,0" MouseDown="TracksTab_MouseDown">
<TextBlock x:Name="TracksTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_TRACKS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0,10,0" MouseDown="TracksTab_MouseDown" Cursor="Hand">
</TextBlock>
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2,5" Stroke="#FFDADADA" DockPanel.Dock="Left"/>
<TextBlock x:Name="ArtistsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ARTISTS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ArtistsTab_MouseDown">
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2,5" Stroke="{StaticResource SecondaryTextColor}" DockPanel.Dock="Left"/>
<TextBlock x:Name="ArtistsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ARTISTS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ArtistsTab_MouseDown" Cursor="Hand">
</TextBlock>
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2,5" Stroke="#FFDADADA" DockPanel.Dock="Left"/>
<TextBlock x:Name="AlbumsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ALBUMS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="AlbumsTab_MouseDown">
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2,5" Stroke="{StaticResource SecondaryTextColor}" DockPanel.Dock="Left"/>
<TextBlock x:Name="AlbumsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ALBUMS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="AlbumsTab_MouseDown" Cursor="Hand">
</TextBlock>
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2,5" Stroke="#FFDADADA" DockPanel.Dock="Left"/>
<TextBlock x:Name="ImportTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_IMPORT}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ImportTab_MouseDown">
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2,5" Stroke="{StaticResource SecondaryTextColor}" DockPanel.Dock="Left"/>
<TextBlock x:Name="ImportTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_IMPORT}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ImportTab_MouseDown" Cursor="Hand">
</TextBlock>
<TextBlock x:Name="SettingsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_SETTINGS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Right" Margin="0,0,10,0" MouseDown="SettingsTab_MouseDown" HorizontalAlignment="Right">
<TextBlock x:Name="SettingsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_SETTINGS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Right" Margin="0,0,10,0" MouseDown="SettingsTab_MouseDown" HorizontalAlignment="Right" Cursor="Hand">
</TextBlock>
<!--<Path x:Name="VolumIcon" Data="{StaticResource VolumeIcon}" Stretch="Uniform" RenderTransformOrigin="1.1,0.633" Width="20" VerticalAlignment="Center" DockPanel.Dock="Left" HorizontalAlignment="Left" Fill="White"/>-->
</DockPanel>
@ -126,7 +126,7 @@
</Border>
<Frame x:Name="RightFrame" DockPanel.Dock="Right" RenderTransformOrigin="0.5,0.5" Background="#FFF11F1F" Visibility="Collapsed" Width="235" NavigationUIVisibility="Hidden"/>
<Frame x:Name="ContentFrame" Content="Frame" Background="#FF250C27" NavigationUIVisibility="Hidden"/>
</DockPanel>
</Window>

View file

@ -60,17 +60,20 @@ namespace FRESHMusicPlayer
}
private void Window_SourceInitialized(object sender, EventArgs e)
{
var smtcInterop = (WindowsInteropUtils.ISystemMediaTransportControlsInterop)WindowsRuntimeMarshal.GetActivationFactory(typeof(SystemMediaTransportControls));
Window window = Window.GetWindow(this);
var wih = new WindowInteropHelper(window);
IntPtr hWnd = wih.Handle;
Smtc = smtcInterop.GetForWindow(hWnd, new Guid("99FA3FF4-1742-42A6-902E-087D41F965EC"));
Smtc.IsPlayEnabled = true;
Smtc.IsPauseEnabled = true;
Smtc.IsNextEnabled = true;
Smtc.IsStopEnabled = true;
Smtc.IsPreviousEnabled = true;
Smtc.ButtonPressed += Smtc_ButtonPressed;
if (Environment.OSVersion.Version.Major >= 10)
{
var smtcInterop = (WindowsInteropUtils.ISystemMediaTransportControlsInterop)WindowsRuntimeMarshal.GetActivationFactory(typeof(SystemMediaTransportControls));
Window window = Window.GetWindow(this);
var wih = new WindowInteropHelper(window);
IntPtr hWnd = wih.Handle;
Smtc = smtcInterop.GetForWindow(hWnd, new Guid("99FA3FF4-1742-42A6-902E-087D41F965EC"));
Smtc.IsPlayEnabled = true;
Smtc.IsPauseEnabled = true;
Smtc.IsNextEnabled = true;
Smtc.IsStopEnabled = true;
Smtc.IsPreviousEnabled = true;
Smtc.ButtonPressed += Smtc_ButtonPressed;
}
}
private void Smtc_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs args)
{
@ -96,9 +99,6 @@ namespace FRESHMusicPlayer
}
}
#region Controls
public void PlayPauseMethod()
{
@ -241,17 +241,18 @@ namespace FRESHMusicPlayer
TitleLabel.Text = track.Title;
ArtistLabel.Text = track.Artist == "" ? FRESHMusicPlayer_WPF_UI_Test.Properties.Resources.MAINWINDOW_NOARTIST : track.Artist;
ProgressBar.Maximum = Player.CurrentBackend.TotalTime.TotalSeconds;
ProgressIndicator2.Text = Player.CurrentBackend.TotalTime.ToString(@"mm\:ss");
Smtc.PlaybackStatus = MediaPlaybackStatus.Playing;
var updater = Smtc.DisplayUpdater;
updater.Type = MediaPlaybackType.Music;
updater.MusicProperties.Artist = track.Artist;
updater.MusicProperties.AlbumArtist = track.AlbumArtist;
updater.MusicProperties.Title = track.Title;
updater.Update();
if (Player.CurrentBackend.TotalTime.TotalSeconds != 0) ProgressIndicator2.Text = Player.CurrentBackend.TotalTime.ToString(@"mm\:ss");
else ProgressIndicator2.Text = "∞";
if (Environment.OSVersion.Version.Major >= 10)
{
Smtc.PlaybackStatus = MediaPlaybackStatus.Playing;
var updater = Smtc.DisplayUpdater;
updater.Type = MediaPlaybackType.Music;
updater.MusicProperties.Artist = track.Artist;
updater.MusicProperties.AlbumArtist = track.AlbumArtist;
updater.MusicProperties.Title = track.Title;
updater.Update();
}
if (track.EmbeddedPictures.Count == 0)
{
CoverArtBox.Source = null;