Browse Source

ColorReplacer wip

Krzysztof Krysiński 3 năm trước cách đây
mục cha
commit
7bf4e57db9

BIN
PixiEditor/Images/Arrow-right.png


+ 3 - 3
PixiEditor/Models/DataHolders/Surface.cs

@@ -135,9 +135,9 @@ namespace PixiEditor.Models.DataHolders
 
             float normalizedAlpha = color.Alpha / 255.0f;
 
-            ptr[0] = (Half)(color.Red * normalizedAlpha);
-            ptr[1] = (Half)(color.Green * normalizedAlpha);
-            ptr[2] = (Half)(color.Blue * normalizedAlpha);
+            ptr[0] = (Half)(color.Red / 255f * normalizedAlpha);
+            ptr[1] = (Half)(color.Green / 255f * normalizedAlpha);
+            ptr[2] = (Half)(color.Blue / 255f * normalizedAlpha);
             ptr[3] = (Half)(normalizedAlpha);
         }
 

+ 2 - 0
PixiEditor/PixiEditor.csproj

@@ -134,6 +134,7 @@
 
 	<ItemGroup>
 		<None Remove="Images\AnchorDot.png" />
+		<None Remove="Images\Arrow-right.png" />
 		<None Remove="Images\CheckerTile.png" />
 		<None Remove="Images\ChevronDown.png" />
 		<None Remove="Images\ChevronsDown.png" />
@@ -214,6 +215,7 @@
 	</ItemGroup>
 	<ItemGroup>
 		<Resource Include="Images\AnchorDot.png" />
+		<Resource Include="Images\Arrow-right.png" />
 		<Resource Include="Images\CheckerTile.png" />
 		<Resource Include="Images\ChevronDown.png" />
 		<Resource Include="Images\ChevronsDown.png" />

+ 0 - 1
PixiEditor/ViewModels/SubViewModels/Main/DebugViewModel.cs

@@ -26,7 +26,6 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
         public void OpenFolder(object parameter)
         {
             ProcessHelpers.ShellExecuteEV(parameter as string);
-            Owner.BitmapManager.ActiveDocument.ReplaceColor(SKColors.White, SKColors.Blue);
         }
 
         public static void OpenInstallLocation(object parameter)

+ 6 - 1
PixiEditor/Views/UserControls/Layers/LayersManager.xaml

@@ -86,6 +86,11 @@
             </TreeView>
             <Border Name="dropBorder" DragEnter="Grid_DragEnter" DragLeave="Grid_DragLeave" AllowDrop="True" Drop="Grid_Drop" Background="Transparent" BorderThickness="0, 5, 0, 0"></Border>
         </DockPanel>
-        <layerUserControls:ReferenceLayer Visibility="{Binding Path=OpacityInputEnabled, ElementName=layersManager, Converter={BoolToVisibilityConverter}}" Background="{StaticResource MainColor}" Layer="{Binding LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument.ReferenceLayer, ElementName=layersManager, Mode=TwoWay}" Grid.Row="3" VerticalAlignment="Bottom"/>
+        <layerUserControls:ReferenceLayer 
+            Visibility="{Binding Path=OpacityInputEnabled, ElementName=layersManager, 
+            Converter={BoolToVisibilityConverter}}" 
+            Background="{StaticResource MainColor}" 
+            Layer="{Binding LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument.ReferenceLayer, ElementName=layersManager, Mode=TwoWay}"
+            Grid.Row="3" VerticalAlignment="Bottom"/>
     </Grid>
 </UserControl>

+ 3 - 3
PixiEditor/Views/UserControls/Layers/ReferenceLayer.xaml

@@ -12,7 +12,7 @@
         </i:Interaction.Behaviors>
         <Grid>
             <Grid Background="Transparent"/>
-        <Grid Grid.Row="1" Grid.RowSpan="3" VerticalAlignment="Center">
+        <Grid Grid.Row="0"  VerticalAlignment="Center">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="30"/>
                     <ColumnDefinition Width="*"/>
@@ -65,8 +65,8 @@
                         <BeginStoryboard>
                             <Storyboard>
                                 <DoubleAnimation Storyboard.TargetName="middleStackPanel" Storyboard.TargetProperty="Height" From="0" To="40" Duration="0:0:0.15"/>
-                                    <DoubleAnimation Storyboard.TargetName="layerVisibilityCheckboxGrid" Storyboard.TargetProperty="Height" From="0" To="16" Duration="0:0:0.15"/>
-                                </Storyboard>
+                                <DoubleAnimation Storyboard.TargetName="layerVisibilityCheckboxGrid" Storyboard.TargetProperty="Height" From="0" To="16" Duration="0:0:0.15"/>
+                            </Storyboard>
                         </BeginStoryboard>
                         </EventTrigger>
 

+ 83 - 0
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml

@@ -0,0 +1,83 @@
+<UserControl x:Class="PixiEditor.Views.UserControls.Palettes.ColorReplacer"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PixiEditor.Views.UserControls.Palettes"
+             xmlns:userControls="clr-namespace:PixiEditor.Views.UserControls"
+             xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
+             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
+             xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
+             xmlns:colorPicker="clr-namespace:ColorPicker;assembly=ColorPicker"
+             mc:Ignorable="d" Name="uc"
+             d:DesignHeight="50" d:DesignWidth="300">
+    <Border BorderBrush="{StaticResource DarkerAccentColor}" 
+            Background="{StaticResource MainColor}"
+            BorderThickness="0 2 0 0" MinWidth="60" Focusable="True">
+            <i:Interaction.Behaviors>
+                <behaviours:ClearFocusOnClickBehavior/>
+            </i:Interaction.Behaviors>
+            <Grid>
+                <Grid Grid.Row="0"  VerticalAlignment="Center">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="*"/>
+                    </Grid.ColumnDefinitions>
+                    <Grid Grid.ColumnSpan="2" Grid.RowSpan="2">
+                        <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"/>
+                    <Image Source="/Images/Arrow-right.png" Height="20" Width="20" Margin="10 0"/>
+                    <colorPicker:PortableColorPicker 
+                        UseHintColor="True"
+                        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}"/>
+                        </StackPanel>
+                    <CheckBox Focusable="False" Panel.ZIndex="10" Name="VisibilityCheckbox" Margin="0,0,5,0" Height="16" HorizontalAlignment="Right">
+                        <CheckBox.Triggers>
+                            <EventTrigger RoutedEvent="CheckBox.Checked">
+                                <BeginStoryboard>
+                                    <Storyboard>
+                                        <DoubleAnimation Storyboard.TargetName="MiddleStackPanel" Storyboard.TargetProperty="Height" From="40" To="0" Duration="0:0:0.15"/>
+                                    </Storyboard>
+                                </BeginStoryboard>
+                            </EventTrigger>
+                            <EventTrigger RoutedEvent="CheckBox.Unchecked">
+                                <BeginStoryboard>
+                                    <Storyboard>
+                                        <DoubleAnimation Storyboard.TargetName="MiddleStackPanel" Storyboard.TargetProperty="Height" From="0" To="40" Duration="0:0:0.15"/>
+                                    </Storyboard>
+                                </BeginStoryboard>
+                            </EventTrigger>
+
+                        </CheckBox.Triggers>
+                        <CheckBox.Template>
+                            <ControlTemplate TargetType="{x:Type CheckBox}">
+                                <StackPanel Orientation="Horizontal" Focusable="False">
+                                    <Image Focusable="False" Width="14" Cursor="Hand" x:Name="checkboxImage" Source="/Images/ChevronDown.png">
+                                        <Image.RenderTransform>
+                                            <RotateTransform Angle="0"/>
+                                        </Image.RenderTransform>
+                                    </Image>
+                                    <ContentPresenter Focusable="False"/>
+                                </StackPanel>
+                                <ControlTemplate.Triggers>
+                                    <Trigger Property="IsChecked" Value="True">
+                                        <Setter TargetName="checkboxImage" Property="RenderTransform">
+                                            <Setter.Value>
+                                                <RotateTransform Angle="180" CenterX="7" CenterY="4"/>
+                                            </Setter.Value>
+                                        </Setter>
+                                    </Trigger>
+                                </ControlTemplate.Triggers>
+                            </ControlTemplate>
+                        </CheckBox.Template>
+                    </CheckBox>
+                </Grid>
+            </Grid>
+        </Border>
+</UserControl>

+ 33 - 0
PixiEditor/Views/UserControls/Palettes/ColorReplacer.xaml.cs

@@ -0,0 +1,33 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace PixiEditor.Views.UserControls.Palettes
+{
+    /// <summary>
+    /// Interaction logic for ColorReplacer.xaml
+    /// </summary>
+    public partial class ColorReplacer : UserControl
+    {
+
+        public Color HintColor
+        {
+            get { return (Color)GetValue(HintColorProperty); }
+            set { SetValue(HintColorProperty, value); }
+        }
+
+        // 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();
+        }
+
+        public ColorReplacer()
+        {
+            InitializeComponent();
+        }
+    }
+}

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

@@ -27,7 +27,7 @@
                 </VisualBrush>
             </Border.Background>
         </Border>
-        <Border CornerRadius="{Binding ElementName=uc, Path=CornerRadius}" BorderThickness="0 0 0 0.1" BorderBrush="White" Cursor="Hand">
+        <Border CornerRadius="{Binding ElementName=uc, Path=CornerRadius}" BorderThickness="0 0 0 0.1" BorderBrush="White">
             <Border.Background>
                 <SolidColorBrush Color="{Binding Color, Converter={StaticResource SKColorToMediaColorConverter}, ElementName=uc}" />
             </Border.Background>

+ 3 - 1
PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml

@@ -14,6 +14,7 @@
             <RowDefinition Height="37.5"/>
             <RowDefinition Height="5"/>
             <RowDefinition Height="*"/>
+            <RowDefinition Height="50"/>
         </Grid.RowDefinitions>
         <StackPanel Orientation="Vertical" Grid.Row="0" Background="{StaticResource MainColor}">
             <DockPanel VerticalAlignment="Center" Margin="0 5 0 0">
@@ -67,7 +68,7 @@
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                     <DataTemplate>
-                        <palettes:PaletteColor ToolTip="Click to select as main color. Drag and drop onto another palette color to swap them." AllowDrop="True" Color="{Binding}" 
+                        <palettes:PaletteColor Cursor="Hand" ToolTip="Click to select as main color. Drag and drop onto another palette color to swap them." AllowDrop="True" Color="{Binding}" 
                                                Margin="2.5" MouseMove="PaletteColor_MouseMove"
                                             Drop="PaletteColor_Drop"
                                             AssociatedKey="{Binding Path=(ItemsControl.AlternationIndex), 
@@ -91,5 +92,6 @@
                </ItemsControl.ItemTemplate>
             </ItemsControl>
         </ScrollViewer>
+        <palettes:ColorReplacer Grid.Row="3" VerticalAlignment="Bottom" HintColor="{Binding ElementName=paletteControl, Path=HintColor}"/>
     </Grid>
 </UserControl>

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

@@ -34,7 +34,7 @@
             </ItemsControl.ItemsPanel>
             <ItemsControl.ItemTemplate>
                 <DataTemplate>
-                    <palettes:PaletteColor Color="{Binding}" Margin="0 5 5 5">
+                    <palettes:PaletteColor Cursor="Hand" Color="{Binding}" Margin="0 5 5 5">
                         <i:Interaction.Triggers>
                             <i:EventTrigger EventName="MouseLeftButtonUp">
                                 <i:InvokeCommandAction