This commit is contained in:
Royce551 2020-09-12 01:08:31 -05:00
parent bb66946be9
commit 9d7f2d7b9a
10 changed files with 62 additions and 38 deletions

View file

@ -22,6 +22,7 @@ namespace FRESHMusicPlayer.Handlers.Notifications
{
public bool IsImportant = false;
public bool DisplayAsToast = false;
public bool Read = false;
public string HeaderText;
public string ContentText;
@ -39,5 +40,6 @@ namespace FRESHMusicPlayer.Handlers.Notifications
}
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => MainWindow.NotificationHandler.Remove(this);
}
}

View file

@ -23,7 +23,7 @@
</Storyboard>
<ContextMenu x:Key="MiscContext">
<MenuItem Header="Tag Editor" Click="TrackContextTagEditor_Click"/>
<MenuItem x:Name="MiniPlayerContext" Header="MiniPlayer Mode" IsCheckable="True" Click="TrackContextMiniplayer_Click"/>
<MenuItem x:Name="MiniPlayerContext" Header="Player that is mini" IsCheckable="True" Click="TrackContextMiniplayer_Click"/>
</ContextMenu>
</Window.Resources>
<DockPanel Background="#FF0C6C08">
@ -40,17 +40,32 @@
<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>
<Border x:Name="SettingsButton" Background="Transparent" Width="22" Height="22" DockPanel.Dock="Right" Margin="0,-0.75,15,0" MouseDown="SettingsButton_Click">
<!---some manual corrections were applied to keep the icons visually correct-->
<Canvas>
<Path Data="{StaticResource SettingsIcon}" Fill="{StaticResource PrimaryTextColor}"/>
</Canvas>
</Border>
<Border x:Name="QueueManagementButton" Background="Transparent" Width="22" Height="22" DockPanel.Dock="Right" Margin="0,-0.75,15,0" MouseDown="QueueManagementButton_Click">
<!---some manual corrections were applied to keep the icons visually correct-->
<Canvas>
<Path Data="{StaticResource QueueIcon}" Fill="{StaticResource PrimaryTextColor}"/>
</Canvas>
</Border>
<TextBlock x:Name="NotificationCounterLabel" TextWrapping="NoWrap" Text="1" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Right" Margin="0,0,20,0" MouseDown="NotificationButton_Click" Cursor="Hand" Visibility="Collapsed"/>
<Border x:Name="NotificationButton" Width="22" Height="22" DockPanel.Dock="Right" Margin="5,-0.75,5,0" MouseDown="NotificationButton_Click" Visibility="Collapsed">
<!---some manual corrections were applied to keep the icons visually correct-->
<Canvas>
<Path Data="{StaticResource NotificationIcon}" Fill="{StaticResource PrimaryTextColor}"/>
</Canvas>
</Border>
<Border x:Name="SearchButton" Background="Transparent" Width="20" DockPanel.Dock="Right" Margin="0,2,15,0" HorizontalAlignment="Right" MouseDown="SearchButton_Click" Height="20" VerticalAlignment="Top">
<Canvas>
<Path Data="{StaticResource SearchIcon}" Fill="{StaticResource PrimaryTextColor}"/>
</Canvas>
</Border>
</DockPanel>
<!--Controls Box-->
<Border x:Name="ControlsBoxBorder" BorderThickness="1" Height="84" BorderBrush="{StaticResource ControlBoxColor}" DockPanel.Dock="Bottom" RenderTransformOrigin="0.5,0.5">

View file

@ -98,20 +98,20 @@ namespace FRESHMusicPlayer
#region Controls
public void PlayPauseMethod()
{
if (!Player.Playing) return;
if (Player.Paused)
{
Player.ResumeMusic();
PlayPauseButton.Data = (Geometry)FindResource("PauseIcon");
Smtc.PlaybackStatus = MediaPlaybackStatus.Playing;
SetIntegrations(MediaPlaybackStatus.Playing);
progressTimer.Start();
}
else
{
Player.PauseMusic();
PlayPauseButton.Data = (Geometry)FindResource("PlayIcon");
SetIntegrations(MediaPlaybackStatus.Paused);
progressTimer.Stop();
}
UpdatePlayButtonState();
}
public void StopMethod()
{
@ -146,6 +146,11 @@ namespace FRESHMusicPlayer
RepeatOneButton.Fill = new LinearGradientBrush(Color.FromRgb(105, 181, 120), Color.FromRgb(51, 139, 193), 0);
}
}
public void UpdatePlayButtonState()
{
if (!Player.Paused) PlayPauseButton.Data = (Geometry)FindResource("PauseIcon");
else PlayPauseButton.Data = (Geometry)FindResource("PlayIcon");
}
#endregion
#region Logic
public void SetMiniPlayerMode(bool mode)
@ -202,7 +207,7 @@ namespace FRESHMusicPlayer
sb.Begin(RightFrame);
RightFrame.Visibility = Visibility.Collapsed;
RightFrame.Source = null;
AuxilliaryPaneUri = null;
AuxilliaryPaneUri = "";
AuxilliaryPaneIsOpen = false;
}
public void ProcessSettings()
@ -271,6 +276,7 @@ namespace FRESHMusicPlayer
if (Player.CurrentBackend.TotalTime.TotalSeconds != 0) ProgressIndicator2.Text = Player.CurrentBackend.TotalTime.ToString(@"mm\:ss");
else ProgressIndicator2.Text = "∞";
SetIntegrations(MediaPlaybackStatus.Playing, track.Artist, track.AlbumArtist, track.Title);
UpdatePlayButtonState();
if (track.EmbeddedPictures.Count == 0)
{
CoverArtBox.Source = null;
@ -354,13 +360,27 @@ namespace FRESHMusicPlayer
ContentFrame.NavigationService.RemoveBackEntry();
TabChanged?.Invoke(null, EventArgs.Empty);
}
private void QueueManagementButton_Click(object sender, MouseButtonEventArgs e) => ShowAuxilliaryPane("/Pages/QueueManagement/QueueManagementPage.xaml", 335);
private void NotificationButton_Click(object sender, MouseButtonEventArgs e) => ShowAuxilliaryPane("/Pages/NotificationPage.xaml");
#endregion
private void NotificationHandler_NotificationInvalidate(object sender, EventArgs e)
{
NotificationCounterLabel.Text = NotificationHandler.Notifications.Count.ToString();
if (NotificationHandler.Notifications.Count != 0)
{
NotificationButton.Visibility = Visibility.Visible;
NotificationCounterLabel.Visibility = Visibility.Visible;
}
else
{
NotificationButton.Visibility = Visibility.Collapsed;
NotificationCounterLabel.Visibility = Visibility.Collapsed;
}
foreach (NotificationBox box in NotificationHandler.Notifications)
{
if (box.DisplayAsToast) ShowAuxilliaryPane("Pages\\NotificationPage.xaml"); // TODO: replace this with proper toast implementation
if (!box.DisplayAsToast && box.Read) return;
}
ShowAuxilliaryPane("Pages\\NotificationPage.xaml");
}
#endregion
@ -416,10 +436,6 @@ namespace FRESHMusicPlayer
break;
case Key.OemTilde:
NotificationHandler.Add(new NotificationBox(new NotificationInfo("Debug key", "You just pressed the debug key! You may or may not see cool stuff happening.", false, true)));
int a = 5;
int b = 0;
int c = a / b;
((App)System.Windows.Application.Current).ChangeSkin(Skin.Light);
e.Handled = true;
break;
case Key.F5:
@ -427,7 +443,7 @@ namespace FRESHMusicPlayer
e.Handled = true;
break;
case Key.F7:
ContentFrame.NavigationService.GoBack();
NotificationHandler.Add(new NotificationBox(new NotificationInfo("Debug key", "You just pressed the debug key! You may or may not see cool stuff happening.", false, false)));
e.Handled = true;
break;
case Key.F8:

View file

@ -28,7 +28,7 @@
<Button x:Name="BrowseTracksButton" Content="{x:Static resx:Resources.IMPORT_BROWSE_TRACKS}" Margin="15,5,5,5" Grid.Row="1" TextBlock.FontSize="16" Click="BrowseTracksButton_Click"/>
<Button x:Name="BrowsePlaylistsButton" Content="{x:Static resx:Resources.IMPORT_BROWSE_PLAYLIST}" Margin="15,5,5,5" Grid.Row="2" TextBlock.FontSize="16" Click="BrowsePlaylistsButton_Click"/>
<Button x:Name="BrowseFoldersButton" Content="{x:Static resx:Resources.IMPORT_BROWSE_FOLDERS}" Margin="15,5,5,5" Grid.Row="3" TextBlock.FontSize="16" Click="BrowseFoldersButton_Click"/>
<TextBlock Foreground="{StaticResource PrimaryTextColor}" FontSize="14" Text="Manual file path/URL entry" Grid.Row="4" Margin="15,5,0,0"/>
<TextBlock Foreground="{StaticResource PrimaryTextColor}" FontSize="14" Text="{x:Static resx:Resources.IMPORT_MANUALENTRY}" Grid.Row="4" Margin="15,5,0,0"/>
<TextBox x:Name="FilePathBox" Grid.Row="5" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="15,2,5,2" VerticalAlignment="Stretch" FontSize="16"/>
<Button x:Name="TextBoxButton" Grid.Row="5" Grid.Column="1" Content="Import" Margin="5" Padding="5,0,5,0" Click="TextBoxButton_Click"/>
<TextBlock Text="{x:Static resx:Resources.IMPORT_DRAGDROP_PROMPT}" Foreground="{StaticResource PrimaryTextColor}" TextWrapping="Wrap" Margin="15,5,5,0" Grid.Row="6" VerticalAlignment="Top" FontSize="16" Height="43"/>

View file

@ -42,8 +42,8 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="InfoLabel" Text="99 Tracks ・ 10:00:00" Grid.Column="0" Foreground="{StaticResource SecondaryTextColor}" FontSize="12" Margin="10" VerticalAlignment="Center"/>
<Button x:Name="QueueAllButton" Content="Enqueue All" Grid.Column="1" Margin="10,10,0,10" Padding="5,1" Click="QueueAllButton_Click"/>
<Button x:Name="PlayAllButton" Content="Play All" Grid.Column="2" Margin="10" Padding="5,1" Click="PlayAllButton_Click"/>
<Button x:Name="QueueAllButton" Content="{x:Static resx:Resources.LIBRARY_ENQUEUEALL}" Grid.Column="1" Margin="10,10,0,10" Padding="5,1" Click="QueueAllButton_Click"/>
<Button x:Name="PlayAllButton" Content="{x:Static resx:Resources.LIBRARY_PLAYALL}" Grid.Column="2" Margin="10" Padding="5,1" Click="PlayAllButton_Click"/>
</Grid>
</Grid>

View file

@ -54,47 +54,38 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
}
public async void ShowTracks()
{
NotificationBox box = new NotificationBox(new NotificationInfo("Library is loading", "Please wait", true, false));
LeftSide.Width = new GridLength(0);
int length = 0;
await Task.Run(() =>
{
Dispatcher.Invoke(() => MainWindow.NotificationHandler.Add(box));
foreach (var thing in DatabaseUtils.Read())
{
Dispatcher.Invoke(() => TracksPanel.Items.Add(new SongEntry(thing.Path, thing.Artist, thing.Album, thing.Title)));
length += thing.Length;
}
Dispatcher.Invoke(() => MainWindow.NotificationHandler.Remove(box));
});
InfoLabel.Text = $"{Properties.Resources.MAINWINDOW_TRACKS}: {TracksPanel.Items.Count} ・ {new TimeSpan(0, 0, 0, length):hh\\:mm\\:ss}";
}
public async void ShowArtists()
{
NotificationBox box = new NotificationBox(new NotificationInfo("Library is loading", "Please wait", true, false));
await Task.Run(() =>
{
Dispatcher.Invoke(() => MainWindow.NotificationHandler.Add(box));
foreach (var thing in DatabaseUtils.Read("Artist"))
{
if (CategoryPanel.Items.Contains(thing.Artist)) continue;
Dispatcher.Invoke(() => CategoryPanel.Items.Add(thing.Artist));
}
Dispatcher.Invoke(() => MainWindow.NotificationHandler.Remove(box));
});
}
public async void ShowAlbums()
{
NotificationBox box = new NotificationBox(new NotificationInfo("Library is loading", "Please wait", true, false));
await Task.Run(() =>
{
Dispatcher.Invoke(() => MainWindow.NotificationHandler.Add(box));
foreach (var thing in DatabaseUtils.Read("Album"))
{
if (CategoryPanel.Items.Contains(thing.Album)) continue;
Dispatcher.Invoke(() => CategoryPanel.Items.Add(thing.Album));
}
Dispatcher.Invoke(() => MainWindow.NotificationHandler.Remove(box));
});
}
public async void ShowTracksforArtist(string selectedItem)

View file

@ -48,16 +48,16 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
TracksPanel.Items.Clear();
await Task.Run(() =>
{
foreach (var thing in MainWindow.Libraryv2.GetCollection<DatabaseTrack>("tracks")
.Query()
.Where(x => x.Title.ToUpper().Contains(searchterm) || x.Artist.ToUpper().Contains(searchterm) || x.Album.ToUpper().Contains(searchterm))
.OrderBy("Title")
.ToList())
{
if (searchqueries.Count > 1) break; // optimization for typing quickly
Dispatcher.Invoke(() => TracksPanel.Items.Add(new SongEntry(thing.Path, thing.Artist, thing.Album, thing.Title)));
length += thing.Length;
}
foreach (var thing in MainWindow.Libraryv2.GetCollection<DatabaseTrack>("tracks")
.Query()
.Where(x => x.Title.ToUpper().Contains(searchterm) || x.Artist.ToUpper().Contains(searchterm) || x.Album.ToUpper().Contains(searchterm))
.OrderBy("Title")
.ToList())
{
if (searchqueries.Count > 1) break; // optimization for typing quickly
Dispatcher.Invoke(() => TracksPanel.Items.Add(new SongEntry(thing.Path, thing.Artist, thing.Album, thing.Title)));
length += thing.Length;
}
});
InfoLabel.Text = $"{Properties.Resources.MAINWINDOW_TRACKS}: {TracksPanel.Items.Count} ・ {new TimeSpan(0, 0, 0, length):hh\\:mm\\:ss}";
taskIsRunning = false;

View file

@ -37,11 +37,7 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
private void PlayButtonClick(object sender, MouseButtonEventArgs e)
{
if (MainWindow.Player.Playing)
{
MainWindow.Player.ClearQueue();
MainWindow.Player.QueuePosition = 0; // temporary fix until FMP Core update
}
if (MainWindow.Player.Playing) MainWindow.Player.ClearQueue();
MainWindow.Player.AddQueue(FilePath);
MainWindow.Player.PlayMusic();
}
@ -58,6 +54,7 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
{
if (e.ClickCount == 2)
{
if (MainWindow.Player.Playing) MainWindow.Player.ClearQueue();
MainWindow.Player.AddQueue(FilePath);
MainWindow.Player.PlayMusic();
}

View file

@ -39,6 +39,7 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages
foreach (NotificationBox box in MainWindow.NotificationHandler.Notifications)
{
NotificationList.Items.Add(box);
box.Read = true;
}
}

View file

@ -15,4 +15,6 @@
<Geometry x:Key="DeleteIcon">M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z</Geometry>
<Geometry x:Key="RepeatOneIcon">M13,15V9H12L10,10V11H11.5V15M17,17H7V14L3,18L7,22V19H19V13H17M7,7H17V10L21,6L17,2V5H5V11H7V7Z</Geometry>
<Geometry x:Key="ShuffleIcon">M14.83,13.41L13.42,14.82L16.55,17.95L14.5,20H20V14.5L17.96,16.54L14.83,13.41M14.5,4L16.54,6.04L4,18.59L5.41,20L17.96,7.46L20,9.5V4M10.59,9.17L5.41,4L4,5.41L9.17,10.58L10.59,9.17Z</Geometry>
<Geometry x:Key="QueueIcon">M15,6H3V8H15V6M15,10H3V12H15V10M3,16H11V14H3V16M17,6V14.18C16.69,14.07 16.35,14 16,14A3,3 0 0,0 13,17A3,3 0 0,0 16,20A3,3 0 0,0 19,17V8H22V6H17Z</Geometry>
<Geometry x:Key="NotificationIcon">M21,19V20H3V19L5,17V11C5,7.9 7.03,5.17 10,4.29C10,4.19 10,4.1 10,4A2,2 0 0,1 12,2A2,2 0 0,1 14,4C14,4.1 14,4.19 14,4.29C16.97,5.17 19,7.9 19,11V17L21,19M14,21A2,2 0 0,1 12,23A2,2 0 0,1 10,21</Geometry>
</ResourceDictionary>