mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 19:02:19 -05:00
add drag and drop support for library pages
This commit is contained in:
parent
1360e5c973
commit
dd01e74369
7 changed files with 68 additions and 16 deletions
|
@ -47,11 +47,11 @@
|
|||
<TextBlock x:Name="YearLabel" Margin="20,2,5,2" Grid.Row="3" TextTrimming="WordEllipsis" Text="{x:Static resx:Resources.TRACKINFO_YEAR}" Foreground="{StaticResource PrimaryTextColor}" FontSize="16" TextAlignment="Right" />
|
||||
<TextBlock x:Name="GenreLabel" Margin="20,2,5,2" Grid.Row="4" TextTrimming="WordEllipsis" Text="{x:Static resx:Resources.TRACKINFO_GENRE}" Foreground="{StaticResource PrimaryTextColor}" FontSize="16" TextAlignment="Right" />
|
||||
<TextBlock x:Name="AlbumLabel" Margin="20,2,5,2" Grid.Row="5" TextTrimming="WordEllipsis" Text="{x:Static resx:Resources.TRACKINFO_ALBUM}" Foreground="{StaticResource PrimaryTextColor}" FontSize="16" TextAlignment="Right" />
|
||||
<TextBox x:Name="ArtistBox" Grid.Row="1" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="TitleBox" Grid.Row="2" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="YearBox" Grid.Row="3" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="GenreBox" Grid.Row="4" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="AlbumBox" Grid.Row="5" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="ArtistBox" Grid.Row="1" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="TitleBox" Grid.Row="2" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="YearBox" Grid.Row="3" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="GenreBox" Grid.Row="4" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="AlbumBox" Grid.Row="5" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
</Grid>
|
||||
<Grid Height="153" Margin="0,5,0,0" Background="{StaticResource BackgroundColor}">
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -72,10 +72,10 @@
|
|||
<TextBlock x:Name="TrackNumLabel" Margin="20,2,5,2" Grid.Row="3" TextTrimming="WordEllipsis" Text="{x:Static resx:Resources.TAGEDITOR_TRACKNUM}" Foreground="{StaticResource PrimaryTextColor}" FontSize="16" TextAlignment="Right" />
|
||||
<TextBlock x:Name="DiscNumLabel" Margin="20,2,5,2" Grid.Row="4" TextTrimming="WordEllipsis" Text="{x:Static resx:Resources.TAGEDITOR_DISCNUM}" Foreground="{StaticResource PrimaryTextColor}" FontSize="16" TextAlignment="Right" />
|
||||
|
||||
<TextBox x:Name="AlbumArtistBox" Grid.Row="1" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="ComposerBox" Grid.Row="2" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="TrackNumBox" Grid.Row="3" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="DiscNumBox" Grid.Row="4" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="AlbumArtistBox" Grid.Row="1" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="ComposerBox" Grid.Row="2" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="TrackNumBox" Grid.Row="3" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
<TextBox x:Name="DiscNumBox" Grid.Row="4" Grid.Column="2" Background="{x:Null}" Foreground="{StaticResource PrimaryTextColor}" CaretBrush="{StaticResource PrimaryTextColor}" Margin="2,2,10,2" VerticalAlignment="Stretch" FontSize="16" TextChanged="TextChanged"/>
|
||||
</Grid>
|
||||
<Grid Height="153" Margin="0,5,0,0" Background="{StaticResource BackgroundColor}">
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
@ -30,12 +30,12 @@ namespace FRESHMusicPlayer
|
|||
{
|
||||
Winforms.Timer progressTimer;
|
||||
public static SelectedMenus SelectedMenu = SelectedMenus.Tracks;
|
||||
// TODO: i dunno how to pass this to the pages, if there is a way to i can avoid making this static
|
||||
public static Player Player = new Player();
|
||||
public static NotificationHandler NotificationHandler = new NotificationHandler();
|
||||
public static List<string> Library = new List<string>();
|
||||
public static bool MiniPlayerMode = false;
|
||||
public static bool PreventAuxilliaryPaneHiding = false;
|
||||
public static EventHandler TabChanged;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -147,17 +147,17 @@ namespace FRESHMusicPlayer
|
|||
{
|
||||
case SelectedMenus.Tracks:
|
||||
ContentFrame.Source = new Uri(@"\Pages\Library\LibraryPage.xaml", UriKind.Relative);
|
||||
RightFrame.NavigationService.RemoveBackEntry();
|
||||
ContentFrame.NavigationService.RemoveBackEntry();
|
||||
tab = TracksTab;
|
||||
break;
|
||||
case SelectedMenus.Artists:
|
||||
ContentFrame.Source = new Uri(@"\Pages\Library\LibraryPage.xaml", UriKind.Relative);
|
||||
RightFrame.NavigationService.RemoveBackEntry();
|
||||
ContentFrame.NavigationService.RemoveBackEntry();
|
||||
tab = ArtistsTab;
|
||||
break;
|
||||
case SelectedMenus.Albums:
|
||||
ContentFrame.Source = new Uri(@"\Pages\Library\LibraryPage.xaml", UriKind.Relative);
|
||||
RightFrame.NavigationService.RemoveBackEntry();
|
||||
ContentFrame.NavigationService.RemoveBackEntry();
|
||||
tab = AlbumsTab;
|
||||
break;
|
||||
case SelectedMenus.Import:
|
||||
|
@ -167,6 +167,7 @@ namespace FRESHMusicPlayer
|
|||
default:
|
||||
throw new InvalidOperationException("you are idoit");
|
||||
}
|
||||
TabChanged?.Invoke(null, EventArgs.Empty);
|
||||
TracksTab.FontWeight = ArtistsTab.FontWeight = AlbumsTab.FontWeight = ImportTab.FontWeight = FontWeights.Normal;
|
||||
tab.FontWeight = FontWeights.Bold;
|
||||
}
|
||||
|
@ -314,6 +315,8 @@ namespace FRESHMusicPlayer
|
|||
e.Handled = true;
|
||||
break;
|
||||
case Key.F5:
|
||||
Library.Clear();
|
||||
Library = DatabaseHandler.ReadSongs();
|
||||
ContentFrame.Refresh();
|
||||
e.Handled = true;
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
xmlns:resx = "clr-namespace:FRESHMusicPlayer_WPF_UI_Test.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="372" d:DesignWidth="694"
|
||||
Title="ImportPage">
|
||||
Title="ImportPage" DragEnter="Page_DragEnter" Drop="Page_Drop" AllowDrop="True">
|
||||
|
||||
<Grid Background="{StaticResource BackgroundColor}">
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
@ -5,6 +5,7 @@ using FRESHMusicPlayer.Handlers.Notifications;
|
|||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
@ -73,5 +74,18 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Page_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effects = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
private void Page_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] tracks = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
MainWindow.Player.AddQueue(tracks);
|
||||
DatabaseHandler.ImportSong(tracks);
|
||||
MainWindow.Player.PlayMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:local="clr-namespace:FRESHMusicPlayer_WPF_UI_Test.Pages.Library"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="372" d:DesignWidth="694"
|
||||
Title="LibraryPage">
|
||||
Title="LibraryPage" Unloaded="Page_Unloaded" DragEnter="Page_DragEnter" Drop="Page_Drop" AllowDrop="True">
|
||||
|
||||
<Grid Background="#FF5D5D5D">
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
@ -14,8 +14,10 @@ using System.Windows.Media.Imaging;
|
|||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ATL;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using System.Threading;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
|
||||
{
|
||||
|
@ -28,7 +30,9 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
|
|||
{
|
||||
InitializeComponent();
|
||||
LoadLibrary();
|
||||
MainWindow.TabChanged += MainWindow_TabChanged;
|
||||
}
|
||||
|
||||
public void LoadLibrary()
|
||||
{
|
||||
switch (MainWindow.SelectedMenu) // all of this stuff is here so that i can avoid copying and pasting the same page thrice, maybe there's a better way?
|
||||
|
@ -138,6 +142,37 @@ namespace FRESHMusicPlayer_WPF_UI_Test.Pages.Library
|
|||
if (MainWindow.SelectedMenu == SelectedMenus.Artists) ShowTracksforArtist();
|
||||
else ShowTracksforAlbum();
|
||||
}
|
||||
private void MainWindow_TabChanged(object sender, EventArgs e)
|
||||
{
|
||||
TracksPanel.Items.Clear();
|
||||
CategoryPanel.Items.Clear();
|
||||
LeftSide.Width = new GridLength(222);
|
||||
DetailsPane.Height = new GridLength(75);
|
||||
LoadLibrary();
|
||||
}
|
||||
|
||||
private void Page_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainWindow.TabChanged -= MainWindow_TabChanged;
|
||||
CategoryPanel.Items.Clear();
|
||||
TracksPanel.Items.Clear();
|
||||
}
|
||||
|
||||
private void Page_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effects = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
private void Page_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] tracks = (string[])e.Data.GetData(DataFormats.FileDrop); // TODO: move logic to mainwindow
|
||||
MainWindow.Player.AddQueue(tracks);
|
||||
DatabaseHandler.ImportSong(tracks);
|
||||
MainWindow.Player.PlayMusic();
|
||||
|
||||
MainWindow.Library.Clear();
|
||||
MainWindow.Library = DatabaseHandler.ReadSongs();
|
||||
LoadLibrary();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
<SolidColorBrush x:Key="ControlBoxColor" Color="#FF2C2F33"/>
|
||||
<SolidColorBrush x:Key="NavBarColor" Color="Black"/>
|
||||
<SolidColorBrush x:Key="ForegroundColor" Color="#FF2C2F33"/>
|
||||
<SolidColorBrush x:Key="SecondaryColor" Color="#FF4C5257"/>
|
||||
<SolidColorBrush x:Key="SecondaryColor" Color="#FF46494E"/>
|
||||
<SolidColorBrush x:Key="BackgroundColor" Color="Black"/>
|
||||
</ResourceDictionary>
|
Loading…
Reference in a new issue