Browse Source

Added open palettes folder

Krzysztof Krysiński 3 years ago
parent
commit
a95420f313

+ 1 - 2
PixiEditor/Models/DataHolders/Palettes/FilteringSettings.cs

@@ -23,8 +23,7 @@ namespace PixiEditor.Models.DataHolders.Palettes
         public bool Filter(Palette palette)
         {
             // Lexical comparison
-            bool result = palette.Title.Contains(Name, StringComparison.OrdinalIgnoreCase);
-            if (string.IsNullOrWhiteSpace(Name)) result = true;
+            bool result = string.IsNullOrWhiteSpace(Name) || palette.Title.Contains(Name, StringComparison.OrdinalIgnoreCase);
 
             switch (ColorsNumberMode)
             {

+ 1 - 1
PixiEditor/Models/DataProviders/LocalPalettesFetcher.cs

@@ -13,7 +13,7 @@ namespace PixiEditor.Models.DataProviders
 {
     public class LocalPalettesFetcher : PaletteListDataSource
     {
-        public string PathToPalettesFolder { get; private set; } = Path.Join(
+        public static string PathToPalettesFolder { get; } = Path.Join(
             Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
             "PixiEditor", "Palettes");
 

+ 12 - 4
PixiEditor/Views/Dialogs/PalettesBrowser.xaml

@@ -7,7 +7,7 @@
              mc:Ignorable="d" 
              xmlns:gif="http://wpfanimatedgif.codeplex.com" xmlns:usercontrols="clr-namespace:PixiEditor.Views.UserControls" xmlns:views="clr-namespace:PixiEditor.Views"
              xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
-             Title="Palettes Browser" WindowStartupLocation="CenterScreen" MinWidth="200" Height="600" Width="800" WindowStyle="None"
+             Title="Palettes Browser" WindowStartupLocation="CenterScreen" MinWidth="200" Height="600" Width="825" WindowStyle="None"
              Name="palettesBrowser">
     <Window.Resources>
         <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
@@ -35,8 +35,8 @@
                     WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close"
                     Command="{x:Static SystemCommands.CloseWindowCommand}" />
         </DockPanel>
-        <StackPanel Background="{StaticResource MainColor}" Orientation="Horizontal" Grid.Row="1">
-            <StackPanel Margin="10" Orientation="Horizontal" VerticalAlignment="Center">
+        <DockPanel Background="{StaticResource MainColor}" Grid.Row="1">
+            <StackPanel HorizontalAlignment="Left" Margin="10" Orientation="Horizontal" VerticalAlignment="Center">
                 <Label Content="Sort by:" Style="{StaticResource BaseLabel}" VerticalAlignment="Center" FontSize="16"/>
                 <ComboBox Name="sortingComboBox" FontSize="16" VerticalAlignment="Center" SelectionChanged="SortingComboBox_SelectionChanged">
                     <ComboBoxItem IsSelected="True">Default</ComboBoxItem>
@@ -85,7 +85,15 @@
                                    FocusNext="True"
                                    Value="{Binding ElementName=palettesBrowser, Path=ColorsNumber, Mode=TwoWay}"/>
             </StackPanel>
-        </StackPanel>
+            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 0 10 0">
+                <Button Cursor="Hand" Margin="10 0" Style="{StaticResource ImageButtonStyle}" Width="24" Height="24">
+                    <Image Source="/Images/Plus-square.png"/>
+                </Button>
+                <Button Cursor="Hand" Click="OpenFolder_OnClick" Style="{StaticResource ImageButtonStyle}" Width="24" Height="24">
+                    <Image Source="/Images/Folder.png"/>
+                </Button>
+            </StackPanel>
+        </DockPanel>
         <Grid Grid.Row="2" Margin="10">
             <TextBlock Text="Couldn't fetch palettes" Foreground="White" FontSize="20" HorizontalAlignment="Center" 
                        VerticalAlignment="Center" Visibility="{Binding ElementName=itemsControl, 

+ 15 - 0
PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs

@@ -4,6 +4,8 @@ using PixiEditor.Models.DataProviders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Events;
 using System;
+using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
@@ -283,5 +285,18 @@ namespace PixiEditor.Views.Dialogs
                 SortedResults = new WpfObservableRangeCollection<Palette>(sorted);
             }
         }
+
+        private void OpenFolder_OnClick(object sender, RoutedEventArgs e)
+        {
+            if (Directory.Exists(LocalPalettesFetcher.PathToPalettesFolder))
+            {
+                Process.Start(new ProcessStartInfo
+                {
+                    FileName = LocalPalettesFetcher.PathToPalettesFolder,
+                    UseShellExecute = true,
+                    Verb = "open"
+                });
+            }
+        }
     }
 }