Browse Source

binded all interaction UI items

Krzysztof Krysiński 3 years ago
parent
commit
1b8fc77119

+ 13 - 3
PixiEditor/Models/DataHolders/Palettes/Palette.cs

@@ -7,9 +7,15 @@ using System.Text.RegularExpressions;
 
 namespace PixiEditor.Models.DataHolders.Palettes
 {
-    public class Palette
+    public class Palette : NotifyableObject
     {
-        public string Name { get; set; }
+        private string _name;
+
+        public string Name
+        {
+            get => _name;
+            set => SetProperty(ref _name, value);
+        }
         public List<string> Colors { get; set; }
 
         private string? fileName;
@@ -17,7 +23,11 @@ namespace PixiEditor.Models.DataHolders.Palettes
         public string? FileName
         {
             get => fileName;
-            set => fileName = ReplaceInvalidChars(value);
+            set
+            {
+                fileName = ReplaceInvalidChars(value);
+                RaisePropertyChanged(nameof(FileName));
+            }
         }
 
         public bool IsFavourite { get; set; }

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

@@ -461,6 +461,7 @@ namespace PixiEditor.Views.Dialogs
             if (string.IsNullOrWhiteSpace(e.NewText) || e.NewText == item.Palette.Name)
             {
                 item.Palette.FileName = oldFileName;
+                item.Palette.Name = e.OldText;
                 return;
             }
 
@@ -469,6 +470,7 @@ namespace PixiEditor.Views.Dialogs
             if (!File.Exists(oldPath))
             {
                 item.Palette.FileName = oldFileName;
+                item.Palette.Name = e.OldText;
                 return;
             }
 
@@ -481,6 +483,7 @@ namespace PixiEditor.Views.Dialogs
                 if (finalNewName == oldFileName)
                 {
                     item.Palette.FileName = oldFileName;
+                    item.Palette.Name = e.OldText;
                     return;
                 }
                 newPath = Path.Join(LocalPalettesFetcher.PathToPalettesFolder, finalNewName);

+ 2 - 2
PixiEditor/Views/UserControls/EditableTextBlock.xaml

@@ -10,10 +10,10 @@
         <TextBlock Foreground="Snow" MouseLeftButtonDown="TextBlock_MouseDown"
                    TextTrimming="CharacterEllipsis" Name="textBlock"
                    Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
-                   Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
+                   Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Mode=TwoWay}" />
         <TextBox Style="{StaticResource DarkTextBoxStyle}"
                  LostFocus="TextBox_LostFocus"
-                 Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
+                 Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Mode=TwoWay}"
                  KeyDown="TextBox_KeyDown"
                  LostKeyboardFocus="TextBox_LostKeyboardFocus"
                  Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}},