Browse Source

Improve UI a bit more

Equbuxu 3 years ago
parent
commit
f577f8f741

+ 20 - 5
PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs

@@ -3,7 +3,6 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Input;
 using System.Windows.Interactivity;
 using System.Windows.Interactivity;
-using PixiEditor.Models.Controllers.Shortcuts;
 
 
 namespace PixiEditor.Helpers.Behaviours
 namespace PixiEditor.Helpers.Behaviours
 {
 {
@@ -12,11 +11,19 @@ namespace PixiEditor.Helpers.Behaviours
         // Using a DependencyProperty as the backing store for FillSize.  This enables animation, styling, binding, etc...
         // Using a DependencyProperty as the backing store for FillSize.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty FillSizeProperty =
         public static readonly DependencyProperty FillSizeProperty =
             DependencyProperty.Register(
             DependencyProperty.Register(
-                "FillSize",
+                nameof(FillSize),
                 typeof(bool),
                 typeof(bool),
                 typeof(TextBoxFocusBehavior),
                 typeof(TextBoxFocusBehavior),
                 new PropertyMetadata(false));
                 new PropertyMetadata(false));
 
 
+        // Using a DependencyProperty as the backing store for FillSize.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty SelectOnFocusProperty =
+            DependencyProperty.Register(
+                nameof(SelectOnFocus),
+                typeof(bool),
+                typeof(TextBoxFocusBehavior),
+                new PropertyMetadata(true));
+
         private string oldText; // Value of textbox before editing
         private string oldText; // Value of textbox before editing
         private bool valueConverted; // This bool is used to avoid double convertion if enter is hitted
         private bool valueConverted; // This bool is used to avoid double convertion if enter is hitted
 
 
@@ -26,6 +33,12 @@ namespace PixiEditor.Helpers.Behaviours
             set => SetValue(FillSizeProperty, value);
             set => SetValue(FillSizeProperty, value);
         }
         }
 
 
+        public bool SelectOnFocus
+        {
+            get => (bool)GetValue(SelectOnFocusProperty);
+            set => SetValue(SelectOnFocusProperty, value);
+        }
+
         protected override void OnAttached()
         protected override void OnAttached()
         {
         {
             base.OnAttached();
             base.OnAttached();
@@ -74,7 +87,8 @@ namespace PixiEditor.Helpers.Behaviours
             object sender,
             object sender,
             KeyboardFocusChangedEventArgs e)
             KeyboardFocusChangedEventArgs e)
         {
         {
-            AssociatedObject.SelectAll();
+            if (SelectOnFocus)
+                AssociatedObject.SelectAll();
             if (FillSize)
             if (FillSize)
             {
             {
                 valueConverted = false;
                 valueConverted = false;
@@ -86,7 +100,8 @@ namespace PixiEditor.Helpers.Behaviours
             object sender,
             object sender,
             MouseEventArgs e)
             MouseEventArgs e)
         {
         {
-            AssociatedObject.SelectAll();
+            if (SelectOnFocus)
+                AssociatedObject.SelectAll();
         }
         }
 
 
         private void AssociatedObjectPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         private void AssociatedObjectPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
@@ -127,4 +142,4 @@ namespace PixiEditor.Helpers.Behaviours
             valueConverted = true;
             valueConverted = true;
         }
         }
     }
     }
-}
+}

+ 4 - 4
PixiEditor/Views/MainWindow.xaml

@@ -63,7 +63,7 @@
             <cmd:EventToCommand Command="{Binding CloseWindowCommand}" PassEventArgsToCommand="True" />
             <cmd:EventToCommand Command="{Binding CloseWindowCommand}" PassEventArgsToCommand="True" />
         </i:EventTrigger>
         </i:EventTrigger>
     </i:Interaction.Triggers>
     </i:Interaction.Triggers>
-    <Grid Name="mainGrid" Margin="5" Focusable="True">
+    <Grid Name="mainGrid" Margin="5" Focusable="True" >
         <Grid.ColumnDefinitions>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="45" />
             <ColumnDefinition Width="45" />
             <ColumnDefinition Width="1*" />
             <ColumnDefinition Width="1*" />
@@ -256,10 +256,10 @@
                 </ItemsControl.ItemTemplate>
                 </ItemsControl.ItemTemplate>
             </ItemsControl>
             </ItemsControl>
         </StackPanel>
         </StackPanel>
-        <Grid Grid.Column="1" Grid.Row="2" Background="#303030">
+        <Grid Grid.Column="1" Grid.Row="2" Background="#303030" >
             <Grid AllowDrop="True" Drop="MainWindow_Drop">
             <Grid AllowDrop="True" Drop="MainWindow_Drop">
-                <DockingManager ActiveContent="{Binding BitmapManager.ActiveDocument, Mode=TwoWay, Converter={StaticResource DockingManagerActiveContentConverter}}" 
-                                           DocumentsSource="{Binding BitmapManager.Documents}">
+                <DockingManager ActiveContent="{Binding BitmapManager.ActiveDocument, Mode=Default, Converter={StaticResource DockingManagerActiveContentConverter}}"
+                                           DocumentsSource="{Binding BitmapManager.Documents}" >
                     <DockingManager.Theme>
                     <DockingManager.Theme>
                         <avalonDockTheme:PixiEditorDockTheme />
                         <avalonDockTheme:PixiEditorDockTheme />
                     </DockingManager.Theme>
                     </DockingManager.Theme>

+ 1 - 1
PixiEditor/Views/UserControls/SizeInput.xaml

@@ -43,7 +43,7 @@
                      d:Text="22">
                      d:Text="22">
                 <i:Interaction.Behaviors>
                 <i:Interaction.Behaviors>
                     <behaviors:GlobalShortcutFocusBehavior/>
                     <behaviors:GlobalShortcutFocusBehavior/>
-                    <behaviors:TextBoxFocusBehavior FillSize="True" />
+                    <behaviors:TextBoxFocusBehavior FillSize="True" SelectOnFocus="{Binding SelectOnFocus, ElementName=uc}" />
                 </i:Interaction.Behaviors>
                 </i:Interaction.Behaviors>
             </TextBox>
             </TextBox>
             <Grid Grid.Column="1" Background="{Binding BorderBrush, ElementName=border}"
             <Grid Grid.Column="1" Background="{Binding BorderBrush, ElementName=border}"

+ 9 - 0
PixiEditor/Views/UserControls/SizeInput.xaml.cs

@@ -39,6 +39,9 @@ namespace PixiEditor.Views
         public static readonly DependencyProperty MaxSizeProperty =
         public static readonly DependencyProperty MaxSizeProperty =
             DependencyProperty.Register(nameof(MaxSize), typeof(int), typeof(SizeInput), new PropertyMetadata(int.MaxValue));
             DependencyProperty.Register(nameof(MaxSize), typeof(int), typeof(SizeInput), new PropertyMetadata(int.MaxValue));
 
 
+        public static readonly DependencyProperty SelectOnFocusProperty =
+            DependencyProperty.Register(nameof(SelectOnFocus), typeof(bool), typeof(SizeInput), new PropertyMetadata(true));
+
         private int loadedAspectRatioSize = -1;
         private int loadedAspectRatioSize = -1;
 
 
         private int loadedSize = -1;
         private int loadedSize = -1;
@@ -49,6 +52,12 @@ namespace PixiEditor.Views
             InitializeComponent();
             InitializeComponent();
         }
         }
 
 
+        public bool SelectOnFocus
+        {
+            get => (bool)GetValue(SelectOnFocusProperty);
+            set => SetValue(SelectOnFocusProperty, value);
+        }
+
         public int Size
         public int Size
         {
         {
             get => (int)GetValue(SizeProperty);
             get => (int)GetValue(SizeProperty);

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

@@ -15,7 +15,7 @@
                              AspectRatioValue="{Binding Path=ChosenHeight, ElementName=uc}"
                              AspectRatioValue="{Binding Path=ChosenHeight, ElementName=uc}"
                              AspectRatioControl="{Binding ElementName=HeightPicker}"
                              AspectRatioControl="{Binding ElementName=HeightPicker}"
                              HorizontalAlignment="Left" Margin="10,0,0,0"
                              HorizontalAlignment="Left" Margin="10,0,0,0"
-                             FontSize="16" MaxSize="9999"
+                             FontSize="16" MaxSize="9999" SelectOnFocus="False"
                              Size="{Binding Path=ChosenWidth, ElementName=uc, Mode=TwoWay}" />
                              Size="{Binding Path=ChosenWidth, ElementName=uc, Mode=TwoWay}" />
         </DockPanel>
         </DockPanel>
         <DockPanel Margin="5,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
         <DockPanel Margin="5,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
@@ -26,7 +26,7 @@
                              AspectRatioValue="{Binding Path=ChosenWidth, ElementName=uc}"
                              AspectRatioValue="{Binding Path=ChosenWidth, ElementName=uc}"
                              AspectRatioControl="{Binding ElementName=WidthPicker}"
                              AspectRatioControl="{Binding ElementName=WidthPicker}"
                              HorizontalAlignment="Left" Width="150" Height="30"
                              HorizontalAlignment="Left" Width="150" Height="30"
-                             FontSize="16" MaxSize="9999"
+                             FontSize="16" MaxSize="9999" SelectOnFocus="False"
                              Size="{Binding ChosenHeight, ElementName=uc, Mode=TwoWay}" />
                              Size="{Binding ChosenHeight, ElementName=uc, Mode=TwoWay}" />
         </DockPanel>
         </DockPanel>
         <CheckBox Name="aspectRatio" Content="Preserve aspect ratio" Foreground="White" HorizontalAlignment="Left"
         <CheckBox Name="aspectRatio" Content="Preserve aspect ratio" Foreground="White" HorizontalAlignment="Left"