ソースを参照

More issues addressed

flabbet 3 年 前
コミット
262122c428

+ 26 - 0
PixiEditor/Helpers/BindingProxy.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PixiEditor.Helpers
+{
+    public class BindingProxy : Freezable
+    {
+        protected override Freezable CreateInstanceCore()
+        {
+            return new BindingProxy();
+        }
+
+        public object Data
+        {
+            get { return (object)GetValue(DataProperty); }
+            set { SetValue(DataProperty, value); }
+        }
+
+        public static readonly DependencyProperty DataProperty =
+            DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
+    }
+}

+ 1 - 1
PixiEditor/Styles/DarkCheckboxStyle.xaml

@@ -11,7 +11,7 @@
                 <ControlTemplate TargetType="CheckBox">
                     <BulletDecorator Background="Transparent">
                         <BulletDecorator.Bullet>
-                            <Border x:Name="Border" Width="24" Height="24" CornerRadius="2.5" Background="#FF1B1B1B"
+                            <Border x:Name="Border" Width="20" Height="20" CornerRadius="2.5" Background="#FF1B1B1B"
                                     BorderThickness="1">
                                 <Path Width="9" Height="9" x:Name="CheckMark" SnapsToDevicePixels="False" Stroke="{StaticResource UIElementBlue}" StrokeThickness="1.5" Data="M 0 4 L 3 8 8 0" />
                             </Border>

+ 7 - 3
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml

@@ -27,15 +27,19 @@
                     </Grid>
                     <StackPanel Name="MiddleStackPanel" Height="40" Orientation="Horizontal" HorizontalAlignment="Center">
                         <local:PaletteColor Color="{Binding ElementName=uc, Path=ColorToReplace}"
-                            Height="35" Width="35" AllowDrop="True" Drop="UIElement_OnDrop"/>
+                            Height="35" 
+                            Width="35" 
+                            ToolTip="Right click on palette color and choose 'Replace' or drop it here."
+                            AllowDrop="True" Drop="UIElement_OnDrop"/>
                     <Image Source="/Images/Arrow-right.png" Height="20" Width="20" Margin="10 0"/>
                     <colorPicker:PortableColorPicker 
                         UseHintColor="True"
                         SelectedColor="{Binding ElementName=uc, Path=NewColor, Mode=TwoWay}"
                         HintColor="{Binding ElementName=uc, Path=HintColor}"
-                        Height="20"
+                        Height="37"
                         Style="{StaticResource DefaultColorPickerStyle}"
-                        Width="50" Focusable="False" Margin="0 0 10 0"
+                        Width="37" Focusable="False" Margin="0 0 10 0"
+                        ToolTip="Click to choose the color"
                         ShowAlpha="False"/>
                     <Button Click="ReplaceButton_OnClick" ToolTip="Replace color"
                             Style="{StaticResource ToolButtonStyle}" Cursor="Hand" Height="20" Width="20">

+ 2 - 1
PixiEditor/Views/UserControls/Palettes/CompactPaletteViewer.xaml

@@ -28,7 +28,8 @@
                 </ItemsControl.ItemsPanel>
                 <ItemsControl.ItemTemplate>
                     <DataTemplate>
-                        <local:PaletteColor ToolTip="Click to select as main color. Drag and drop onto another palette color to swap them." 
+                        <local:PaletteColor ToolTip="Click to select as main color. Drag and drop onto another palette color to swap them."
+                                            Cursor="Hand"
                                             Color="{Binding}" Width="20" Height="20" CornerRadius="0">
                             <b:Interaction.Triggers>
                                 <b:EventTrigger EventName="MouseLeftButtonUp">

+ 2 - 2
PixiEditor/Views/UserControls/Palettes/PaletteColor.xaml

@@ -13,8 +13,8 @@
     </UserControl.Resources>
     <UserControl.Style>
         <Style TargetType="{x:Type palettes:PaletteColor}">
-            <Setter Property="Width" Value="45"/>
-            <Setter Property="Height" Value="45"/>
+            <Setter Property="Width" Value="36"/>
+            <Setter Property="Height" Value="36"/>
         </Style>
     </UserControl.Style>
     <Grid Width="{Binding ElementName=uc, Path=Width}" Height="{Binding ElementName=uc, Path=Height}">

+ 11 - 1
PixiEditor/Views/UserControls/Palettes/PaletteColorAdder.xaml.cs

@@ -38,7 +38,17 @@ namespace PixiEditor.Views.UserControls.Palettes
 
         // Using a DependencyProperty as the backing store for HintColor.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty HintColorProperty =
-            DependencyProperty.Register("HintColor", typeof(Color), typeof(PaletteColorAdder), new PropertyMetadata(System.Windows.Media.Colors.Transparent));
+            DependencyProperty.Register("HintColor", typeof(Color), typeof(PaletteColorAdder), new PropertyMetadata(System.Windows.Media.Colors.Transparent, OnHintColorChanged));
+
+        private static void OnHintColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var adder = (PaletteColorAdder)d;
+            Color newColor = (Color) e.NewValue;
+            if (newColor.A < 255)
+            {
+                adder.HintColor = Color.FromArgb(255, newColor.R, newColor.G, newColor.B);
+            }
+        }
 
         public static readonly DependencyProperty SwatchesProperty = DependencyProperty.Register(
             "Swatches", typeof(WpfObservableRangeCollection<SKColor>), typeof(PaletteColorAdder), new PropertyMetadata(default(WpfObservableRangeCollection<SKColor>), OnSwatchesChanged));

+ 5 - 2
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml

@@ -6,6 +6,7 @@
              xmlns:local="clr-namespace:PixiEditor.Views.UserControls"
              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters" xmlns:palettes="clr-namespace:PixiEditor.Views.UserControls.Palettes"
+             xmlns:helpers="clr-namespace:PixiEditor.Helpers"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="300" Name="paletteControl">
     <Grid AllowDrop="True" PreviewDragEnter="Grid_PreviewDragEnter" PreviewDragLeave="Grid_PreviewDragLeave"
@@ -83,9 +84,11 @@
                             </b:Interaction.Triggers>
                             <palettes:PaletteColor.ContextMenu>
                                         <ContextMenu>
+                                    <MenuItem Header="Choose" Foreground="White" Click="MenuItem_OnClick"
+                                              CommandParameter="{Binding}"/>
                                             <MenuItem Header="Remove" Foreground="White"
-                                              Click="RemoveColorMenuItem_OnClick"
-                                              CommandParameter="{Binding}" />
+                                                      Click="RemoveColorMenuItem_OnClick"
+                                                      CommandParameter="{Binding}" />
                                             <MenuItem Header="Replace" Foreground="White"
                                                       CommandParameter="{Binding}"
                                                       Click="ReplaceColor_OnClick"/>

+ 9 - 0
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml.cs

@@ -241,5 +241,14 @@ namespace PixiEditor.Views.UserControls.Palettes
             Replacer.ColorToReplace = color;
             Replacer.VisibilityCheckbox.IsChecked = false;
         }
+
+        private void MenuItem_OnClick(object sender, RoutedEventArgs e)
+        {
+            MenuItem origin = (MenuItem)sender;
+            if (SelectColorCommand.CanExecute(origin.CommandParameter))
+            {
+                SelectColorCommand.Execute(origin.CommandParameter);
+            }
+        }
     }
 }