From fa68375a18c332141a78b9022aa8243749ad8f96 Mon Sep 17 00:00:00 2001 From: Blake Burkhart Date: Sun, 12 Sep 2021 21:31:10 -0500 Subject: [PATCH] Use gong-wpf-dragdrop for drag and drop reordering --- Playlist.cs | 23 ++++++++++++++++------- Playlist.csproj | 3 +++ PlaylistView.xaml | 29 ++++++++++++++--------------- packages.config | 1 + 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/Playlist.cs b/Playlist.cs index 7201cd7..0b448b1 100644 --- a/Playlist.cs +++ b/Playlist.cs @@ -11,6 +11,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Controls; +using System.Windows.Media; namespace Playlist { @@ -30,22 +31,26 @@ public override IEnumerable GetSidebarItems() { Title = "Playlist", Type = SiderbarItemType.View, - Icon = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "icon.png"), + Icon = new TextBlock + { + Text = "\ueca6", // Circled play button + FontFamily = ResourceProvider.GetResource("FontIcoFont") as FontFamily, + }, Opened = () => { return playlistView; } }; } public override IEnumerable GetGameMenuItems(GetGameMenuItemsArgs args) { yield return new GameMenuItem + { + Description = "Add to Playlist", + Action = (itemArgs) => { - Description = "Add to playlist", - Action = (itemArgs) => + foreach (Game game in args.Games) { - foreach (Game game in args.Games) - { - playlistViewModel.PlaylistGames.AddMissing(game); - } + playlistViewModel.PlaylistGames.AddMissing(game); } + } }; } @@ -53,6 +58,10 @@ public override IEnumerable GetGameMenuItems(GetGameMenuItemsArgs public Playlist(IPlayniteAPI api) : base(api) { + // Ensure the library loaded now, relative to the extension DLL. + // If the XAML trys to load it later it will incorrectly load it relative to Playnite's executable + Assembly.Load("GongSolutions.WPF.DragDrop"); + playlistGames = new List(); settings = new PlaylistSettingsViewModel(this); playniteApi = api; diff --git a/Playlist.csproj b/Playlist.csproj index e62291d..7371862 100644 --- a/Playlist.csproj +++ b/Playlist.csproj @@ -31,6 +31,9 @@ 4 + + packages\gong-wpf-dragdrop.2.4.1\lib\net462\GongSolutions.WPF.DragDrop.dll + packages\PlayniteSDK.6.0.0-preview3\lib\net462\Playnite.SDK.dll diff --git a/PlaylistView.xaml b/PlaylistView.xaml index 24d04c6..7b0ae18 100644 --- a/PlaylistView.xaml +++ b/PlaylistView.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:dd="urn:gong-wpf-dragdrop" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="600"> @@ -10,46 +11,44 @@