|
@@ -8,10 +8,12 @@ using System.Windows.Input;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Navigation;
|
|
using Microsoft.Win32;
|
|
using Microsoft.Win32;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
|
|
+using PixiEditor.Extensions;
|
|
using PixiEditor.Extensions.Common.Localization;
|
|
using PixiEditor.Extensions.Common.Localization;
|
|
using PixiEditor.Extensions.Common.UserPreferences;
|
|
using PixiEditor.Extensions.Common.UserPreferences;
|
|
using PixiEditor.Extensions.Palettes;
|
|
using PixiEditor.Extensions.Palettes;
|
|
using PixiEditor.Extensions.Palettes.Parsers;
|
|
using PixiEditor.Extensions.Palettes.Parsers;
|
|
|
|
+using PixiEditor.Extensions.Windowing;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Models.AppExtensions.Services;
|
|
using PixiEditor.Models.AppExtensions.Services;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.DataHolders;
|
|
@@ -27,8 +29,11 @@ using PaletteColor = PixiEditor.Extensions.Palettes.PaletteColor;
|
|
|
|
|
|
namespace PixiEditor.Views.Dialogs;
|
|
namespace PixiEditor.Views.Dialogs;
|
|
|
|
|
|
-internal partial class PalettesBrowser : Window
|
|
|
|
|
|
+internal partial class PalettesBrowser : Window, IPopupWindow
|
|
{
|
|
{
|
|
|
|
+ public static string UniqueId => "PixiEditor.BrowserPalette";
|
|
|
|
+ string IPopupWindow.UniqueId => UniqueId;
|
|
|
|
+
|
|
private const int ItemsPerLoad = 25;
|
|
private const int ItemsPerLoad = 25;
|
|
|
|
|
|
private readonly LocalizedString[] stopItTexts = new[]
|
|
private readonly LocalizedString[] stopItTexts = new[]
|
|
@@ -66,6 +71,15 @@ internal partial class PalettesBrowser : Window
|
|
set => SetValue(DeletePaletteCommandProperty, value);
|
|
set => SetValue(DeletePaletteCommandProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static readonly DependencyProperty AddFromPaletteCommandProperty = DependencyProperty.Register(
|
|
|
|
+ nameof(AddFromPaletteCommand), typeof(ICommand), typeof(PalettesBrowser), new PropertyMetadata(default(ICommand)));
|
|
|
|
+
|
|
|
|
+ public ICommand AddFromPaletteCommand
|
|
|
|
+ {
|
|
|
|
+ get { return (ICommand)GetValue(AddFromPaletteCommandProperty); }
|
|
|
|
+ set { SetValue(AddFromPaletteCommandProperty, value); }
|
|
|
|
+ }
|
|
|
|
+
|
|
public bool IsFetching
|
|
public bool IsFetching
|
|
{
|
|
{
|
|
get => (bool)GetValue(IsFetchingProperty);
|
|
get => (bool)GetValue(IsFetchingProperty);
|
|
@@ -168,9 +182,10 @@ internal partial class PalettesBrowser : Window
|
|
Instance = this;
|
|
Instance = this;
|
|
DeletePaletteCommand = new RelayCommand<Palette>(DeletePalette, CanDeletePalette);
|
|
DeletePaletteCommand = new RelayCommand<Palette>(DeletePalette, CanDeletePalette);
|
|
ToggleFavouriteCommand = new RelayCommand<Palette>(ToggleFavourite, CanToggleFavourite);
|
|
ToggleFavouriteCommand = new RelayCommand<Palette>(ToggleFavourite, CanToggleFavourite);
|
|
|
|
+ AddFromPaletteCommand = new RelayCommand(AddFromCurrentPalette, CanAddFromPalette);
|
|
Loaded += async (_, _) =>
|
|
Loaded += async (_, _) =>
|
|
{
|
|
{
|
|
- await LocalPalettesFetcher.RefreshCacheAll();
|
|
|
|
|
|
+ await UpdatePaletteList();
|
|
LocalPalettesFetcher.CacheUpdated += LocalCacheRefreshed;
|
|
LocalPalettesFetcher.CacheUpdated += LocalCacheRefreshed;
|
|
};
|
|
};
|
|
Closed += (_, _) =>
|
|
Closed += (_, _) =>
|
|
@@ -182,6 +197,11 @@ internal partial class PalettesBrowser : Window
|
|
IPreferences.Current.AddCallback(PreferencesConstants.FavouritePalettes, OnFavouritePalettesChanged);
|
|
IPreferences.Current.AddCallback(PreferencesConstants.FavouritePalettes, OnFavouritePalettesChanged);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private bool CanAddFromPalette(object param)
|
|
|
|
+ {
|
|
|
|
+ return CurrentEditingPalette != null;
|
|
|
|
+ }
|
|
|
|
+
|
|
private bool CanDeletePalette(Palette palette)
|
|
private bool CanDeletePalette(Palette palette)
|
|
{
|
|
{
|
|
return palette != null && palette.Source.GetType() == typeof(LocalPalettesFetcher);
|
|
return palette != null && palette.Source.GetType() == typeof(LocalPalettesFetcher);
|
|
@@ -520,7 +540,7 @@ internal partial class PalettesBrowser : Window
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private async void AddFromPalette_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
+ private async void AddFromCurrentPalette(object param)
|
|
{
|
|
{
|
|
if (CurrentEditingPalette?.Count == 0)
|
|
if (CurrentEditingPalette?.Count == 0)
|
|
return;
|
|
return;
|