Browse Source

I'm just passing wips between computers

flabbet 3 years ago
parent
commit
d81ff44da3

+ 4 - 2
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml

@@ -26,16 +26,18 @@
                         <Grid Visibility="{Binding ElementName=VisibilityCheckbox, Path=IsChecked, Converter={InverseBoolToVisibilityConverter}}"  Background="Transparent"/>
                     </Grid>
                     <StackPanel Name="MiddleStackPanel" Height="40" Orientation="Horizontal" HorizontalAlignment="Center">
-                        <local:PaletteColor Height="35" Width="35" AllowDrop="True" Drop="UIElement_OnDrop"/>
+                        <local:PaletteColor Color="{Binding ElementName=uc, Path=ColorToReplace}"
+                            Height="35" Width="35" AllowDrop="True" Drop="UIElement_OnDrop"/>
                     <Image Source="/Images/Arrow-right.png" Height="20" Width="20" Margin="10 0"/>
                     <colorPicker:PortableColorPicker 
                         UseHintColor="True"
+                        Color="{Binding ElementName=uc, Path=ColorToReplace, Mode=TwoWay}"
                         HintColor="{Binding ElementName=uc, Path=HintColor}"
                         Height="20"
                         Style="{StaticResource DefaultColorPickerStyle}"
                         Width="50" Focusable="False" Margin="0 0 10 0"
                         ShowAlpha="False"/>
-                    <Button Content="Replace" Style="{StaticResource AccentDarkRoundButton}"/>
+                    <Button Content="Replace" Style="{StaticResource AccentDarkRoundButton}" Height="30" Width="60"/>
                         </StackPanel>
                     <CheckBox Focusable="False" Panel.ZIndex="10" Name="VisibilityCheckbox" Margin="0,0,5,0" Height="16" HorizontalAlignment="Right">
                         <CheckBox.Triggers>

+ 28 - 2
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml.cs

@@ -1,4 +1,5 @@
-using System.Windows;
+using SkiaSharp;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
 
@@ -9,6 +10,16 @@ namespace PixiEditor.Views.UserControls.Palettes
     /// </summary>
     public partial class ColorReplacer : UserControl
     {
+        public SKColor ColorToReplace
+        {
+            get { return (SKColor)GetValue(ColorToReplaceProperty); }
+            set { SetValue(ColorToReplaceProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for ColorToReplace.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty ColorToReplaceProperty =
+            DependencyProperty.Register("ColorToReplace", typeof(SKColor), typeof(ColorReplacer), new PropertyMetadata(SKColors.Transparent));
+
 
         public Color HintColor
         {
@@ -16,13 +27,28 @@ namespace PixiEditor.Views.UserControls.Palettes
             set { SetValue(HintColorProperty, value); }
         }
 
+        public Color NewColor
+        {
+            get { return (Color)GetValue(NewColorProperty); }
+            set { SetValue(NewColorProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for NewColor.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty NewColorProperty =
+            DependencyProperty.Register("NewColor", typeof(Color), typeof(ColorReplacer), new PropertyMetadata(Colors.Black));
+
+
         // 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(ColorReplacer), new PropertyMetadata(Colors.Transparent));
 
         private void UIElement_OnDrop(object sender, DragEventArgs e)
         {
-            throw new System.NotImplementedException();
+            if (e.Data.GetDataPresent(PaletteViewer.PaletteColorDaoFormat))
+            {
+                string hex = (string)e.Data.GetData(PaletteViewer.PaletteColorDaoFormat);
+                ColorToReplace = SKColor.Parse(hex);
+            }
         }
 
         public ColorReplacer()