a few updates

This commit is contained in:
Royce551 2021-11-06 21:14:47 -05:00
parent 80f2d3b9b8
commit 81b43a37be
4 changed files with 71 additions and 34 deletions

View file

@ -16,6 +16,8 @@ namespace FRESHMusicPlayer.Handlers
/// </summary>
public class GUILibrary : Library
{
public event EventHandler LibraryChanged;
private readonly NotificationHandler notificationHandler;
private readonly Dispatcher dispatcher;
public GUILibrary(LiteDatabase library, NotificationHandler notificationHandler, Dispatcher dispatcher) : base(library)
@ -29,7 +31,11 @@ namespace FRESHMusicPlayer.Handlers
var notification = new Notification { ContentText = $"Importing {tracks.Count} tracks" };
dispatcher.Invoke(() => notificationHandler.Add(notification));
base.Import(tracks);
dispatcher.Invoke(() => notificationHandler.Remove(notification));
dispatcher.Invoke(() =>
{
notificationHandler.Remove(notification);
LibraryChanged?.Invoke(null, EventArgs.Empty);
});
}
public override void Import(string[] tracks)
@ -37,7 +43,11 @@ namespace FRESHMusicPlayer.Handlers
var notification = new Notification { ContentText = $"Importing {tracks.Length} tracks" };
dispatcher.Invoke(() => notificationHandler.Add(notification));
base.Import(tracks);
dispatcher.Invoke(() => notificationHandler.Remove(notification));
dispatcher.Invoke(() =>
{
notificationHandler.Remove(notification);
LibraryChanged?.Invoke(null, EventArgs.Empty);
});
}
public override void Nuke(bool nukePlaylists = true)
@ -50,8 +60,8 @@ namespace FRESHMusicPlayer.Handlers
ContentText = Properties.Resources.NOTIFICATION_CLEARSUCCESS,
Type = NotificationType.Success
});
LibraryChanged?.Invoke(null, EventArgs.Empty);
});
}
//public List<DatabaseQueue> GetAllQueues() FMP 10.2

View file

@ -204,38 +204,54 @@ namespace FRESHMusicPlayer
public async void ShowAuxilliaryPane(Pane pane, int width = 235, bool openleft = false)
{
LoggingHandler.Log($"Showing pane --> {pane}");
UserControl GetPageForPane(Pane panex)
{
switch (panex)
{
case Pane.Settings:
return new SettingsPage(this);
case Pane.QueueManagement:
return new QueueManagement(this);
case Pane.Search:
return new SearchPage(this);
case Pane.Notifications:
return new NotificationPage(this);
case Pane.TrackInfo:
return new TrackInfoPage(this);
case Pane.Lyrics:
return new LyricsPage(this);
default:
return null;
}
}
if (Keyboard.IsKeyDown(Key.LeftShift))
{
new Window
{
Content = GetPageForPane(pane),
Width = 600,
Height = 500,
Topmost = true,
ShowInTaskbar = false,
Owner = this,
WindowStartupLocation = WindowStartupLocation.CenterOwner
}.Show();
return;
}
if (CurrentPane == pane)
{
await HideAuxilliaryPane();
return;
}
if (CurrentPane != Pane.None) await HideAuxilliaryPane(true);
switch (pane)
{
case Pane.Settings:
RightFrame.Content = new SettingsPage(this);
break;
case Pane.QueueManagement:
RightFrame.Content = new QueueManagement(this);
break;
case Pane.Search:
RightFrame.Content = new SearchPage(this);
break;
case Pane.Notifications:
RightFrame.Content = new NotificationPage(this);
break;
case Pane.TrackInfo:
RightFrame.Content = new TrackInfoPage(this);
break;
case Pane.Lyrics:
RightFrame.Content = new LyricsPage(this);
break;
default:
return;
}
if (!openleft) DockPanel.SetDock(RightFrame, Dock.Right); else DockPanel.SetDock(RightFrame, Dock.Left);
RightFrame.Visibility = Visibility.Visible;
RightFrame.Width = width;
RightFrame.Content = GetPageForPane(pane);
var sb = InterfaceUtils.GetThicknessAnimation(
openleft ? new Thickness(width * -1 /*negate*/, 0, 0, 0) : new Thickness(0, 0, width * -1 /*negate*/, 0),

View file

@ -20,6 +20,7 @@ namespace FRESHMusicPlayer.Pages.Library
public LibraryPage(MainWindow window, string search = null)
{
this.window = window;
window.Library.LibraryChanged += Library_LibraryChanged;
InitializeComponent();
LoadLibrary();
CategoryPanel.Focus();
@ -30,6 +31,14 @@ namespace FRESHMusicPlayer.Pages.Library
}
}
private void Library_LibraryChanged(object sender, EventArgs e)
{
var selectedItem = CategoryPanel.SelectedItem;
LoadLibrary();
Thread.Sleep(10);
CategoryPanel.SelectedItem = selectedItem;
}
public async void LoadLibrary() // TODO: figure out how to make this not async void
{
TracksPanel.Items.Clear();
@ -177,6 +186,7 @@ namespace FRESHMusicPlayer.Pages.Library
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
window.Library.LibraryChanged -= Library_LibraryChanged;
CategoryPanel.Items.Clear();
TracksPanel.Items.Clear();
}
@ -191,10 +201,10 @@ namespace FRESHMusicPlayer.Pages.Library
window.Player.Queue.Clear();
InterfaceUtils.DoDragDrop((string[])e.Data.GetData(DataFormats.FileDrop), window.Player, window.Library);
await window.Player.PlayAsync();
var selectedItem = CategoryPanel.SelectedItem;
LoadLibrary();
Thread.Sleep(10);
CategoryPanel.SelectedItem = selectedItem;
//var selectedItem = CategoryPanel.SelectedItem;
//LoadLibrary();
//Thread.Sleep(10);
//CategoryPanel.SelectedItem = selectedItem;
}
private void QueueAllButton_Click(object sender, RoutedEventArgs e)

View file

@ -37,11 +37,11 @@
<DoubleAnimation
Storyboard.TargetName="buttonScaleTransform"
Storyboard.TargetProperty="ScaleX"
To="0.9" Duration="0:0:.10" AutoReverse="True"/>
To="0.95" Duration="0:0:.10" AutoReverse="True"/>
<DoubleAnimation
Storyboard.TargetName="buttonScaleTransform"
Storyboard.TargetProperty="ScaleY"
To="0.9" Duration="0:0:.10" AutoReverse="True"/>
To="0.95" Duration="0:0:.10" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
@ -457,15 +457,16 @@
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="CaretBrush" Value="#FF338BC1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border x:Name="TextBorder" CornerRadius="2" Background="{x:Null}" BorderBrush="{StaticResource SecondaryTextColor}" BorderThickness="1">
<Border x:Name="TextBorder" CornerRadius="2" Background="{StaticResource ForegroundColor}" BorderBrush="{StaticResource ForegroundColor}" BorderThickness="2">
<ScrollViewer Margin="0" x:Name="PART_ContentHost" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="TextBorder" Property="BorderBrush" Value="{StaticResource PrimaryTextColor}"/>
<Setter TargetName="TextBorder" Property="BorderBrush" Value="#FF338BC1"/>
</Trigger>
<Trigger Property="IsFocused" Value="true">
<Setter TargetName="TextBorder" Property="BorderBrush" Value="#FF338BC1"/>