Browse Source

Removed tags

Krzysztof Krysiński 3 years ago
parent
commit
04fb57ab6e

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

@@ -8,15 +8,12 @@ namespace PixiEditor.Models.DataHolders.Palettes
     {
         public ColorsNumberMode ColorsNumberMode { get; set; }
         public int ColorsCount { get; set; }
-        public string[] Tags { get; set; }
-
         public string Name { get; set; }
 
-        public FilteringSettings(ColorsNumberMode colorsNumberMode, int colorsCount, string[] tags, string name)
+        public FilteringSettings(ColorsNumberMode colorsNumberMode, int colorsCount, string name)
         {
             ColorsNumberMode = colorsNumberMode;
             ColorsCount = colorsCount;
-            Tags = tags;
             Name = name;
         }
 
@@ -42,11 +39,6 @@ namespace PixiEditor.Models.DataHolders.Palettes
                     throw new ArgumentOutOfRangeException();
             }
 
-            if (Tags.Length > 0)
-            {
-                result = Tags.All(tag => palette.Tags.Contains(tag));
-            }
-
             return result;
         }
     }

+ 6 - 6
PixiEditor/Views/Dialogs/PalettesBrowser.xaml

@@ -68,12 +68,12 @@
                     </Image>
                 </ToggleButton>
                 <Label Margin="10 0 0 0" Content="Name:" Style="{StaticResource BaseLabel}" VerticalAlignment="Center" FontSize="16"/>
-                <usercontrols:InputBox OnSubmit="NameInput_OnSubmit" FontSize="16" VerticalAlignment="Center"
-                                       Style="{StaticResource DarkTextBoxStyle}" Width="125" />
+                <usercontrols:InputBox FontSize="16"
+                                       Text="{Binding ElementName=palettesBrowser, Path=NameFilter,
+                                       Delay=100, UpdateSourceTrigger=PropertyChanged}"
+                                       VerticalAlignment="Center"
+                                       Style="{StaticResource DarkTextBoxStyle}" Width="200" />
 
-                <Label Margin="10 0 0 0" Content="Tags:" Style="{StaticResource BaseLabel}" VerticalAlignment="Center" FontSize="16"/>
-                <usercontrols:InputBox OnSubmit="TagsInput_OnSubmit" FontSize="16" VerticalAlignment="Center" 
-                                       Style="{StaticResource DarkTextBoxStyle}" Width="125" />
                 <Label Margin="10 0 0 0" Content="Colors:" Style="{StaticResource BaseLabel}" VerticalAlignment="Center" FontSize="16"/>
                 <ComboBox Name="colorsComboBox" FontSize="16" VerticalAlignment="Center" SelectionChanged="ColorsComboBox_SelectionChanged">
                     <ComboBoxItem IsSelected="True">Any</ComboBoxItem>
@@ -86,7 +86,7 @@
                                    Value="{Binding ElementName=palettesBrowser, Path=ColorsNumber, Mode=TwoWay}"/>
             </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">
+                <Button Click="AddFromPalette_OnClick" 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">

+ 16 - 19
PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs

@@ -95,7 +95,8 @@ namespace PixiEditor.Views.Dialogs
         }
 
         public static readonly DependencyProperty NameFilterProperty = DependencyProperty.Register(
-            "NameFilter", typeof(string), typeof(PalettesBrowser), new PropertyMetadata(default(string)));
+            "NameFilter", typeof(string), typeof(PalettesBrowser),
+            new PropertyMetadata(default(string), OnNameFilterChanged));
 
         public string NameFilter
         {
@@ -105,11 +106,10 @@ namespace PixiEditor.Views.Dialogs
 
         public string SortingType { get; set; } = "Default";
         public ColorsNumberMode ColorsNumberMode { get; set; } = ColorsNumberMode.Any;
-        public string[] Tags { get; set; } = Array.Empty<string>();
 
         private FilteringSettings _filteringSettings;
 
-        public FilteringSettings Filtering => _filteringSettings ??= new FilteringSettings(ColorsNumberMode, ColorsNumber, Tags, NameFilter);
+        public FilteringSettings Filtering => _filteringSettings ??= new FilteringSettings(ColorsNumberMode, ColorsNumber, NameFilter);
 
         private char[] _separators = new char[] { ' ', ',' };
 
@@ -176,6 +176,14 @@ namespace PixiEditor.Views.Dialogs
             return src;
         }
 
+        private static async void OnNameFilterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var browser = (PalettesBrowser)d;
+            browser.Filtering.Name = browser.NameFilter;
+            await browser.UpdatePaletteList();
+            browser.scrollViewer.ScrollToHome();
+        }
+
         private async void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
         {
             if (PaletteList?.Palettes == null) return;
@@ -207,22 +215,6 @@ namespace PixiEditor.Views.Dialogs
             }
         }
 
-        private async void TagsInput_OnSubmit(object sender, InputBoxEventArgs e)
-        {
-            Tags = e.Input.Split(_separators, options: StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
-            Filtering.Tags = Tags;
-            await UpdatePaletteList();
-            scrollViewer.ScrollToHome();
-        }
-
-        private async void NameInput_OnSubmit(object sender, InputBoxEventArgs e)
-        {
-            NameFilter = e.Input;
-            Filtering.Name = NameFilter;
-            await UpdatePaletteList();
-            scrollViewer.ScrollToHome();
-        }
-
         private async void ColorsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (e.AddedItems is { Count: > 0 } && e.AddedItems[0] is ComboBoxItem item && item.Content is string value)
@@ -298,5 +290,10 @@ namespace PixiEditor.Views.Dialogs
                 });
             }
         }
+
+        private void AddFromPalette_OnClick(object sender, RoutedEventArgs e)
+        {
+            
+        }
     }
 }