Browse Source

调色板 - 调色板通用UI

chenrongqian 2 năm trước cách đây
mục cha
commit
592d96df82

+ 6 - 1
PDF Office/CustomControl/CompositeControl/ColorContent.xaml

@@ -47,7 +47,12 @@
         <Border Width="56" Height="32" Grid.Column="1" Margin="0,0,5,0" BorderThickness="1" CornerRadius="4" BorderBrush="#E2E3E6"  HorizontalAlignment="Right" >
             <StackPanel Orientation="Horizontal">
 
-                <Ellipse x:Name="ElcustomColor" Fill="Transparent" Width="20" Height="20" PreviewMouseLeftButtonDown="ElcustomColor_PreviewMouseLeftButtonDown"></Ellipse>
+                <Ellipse x:Name="ElcustomColor" Fill="Transparent" Width="20" Height="20" StrokeThickness="1"
+                         PreviewMouseLeftButtonDown="ElcustomColor_PreviewMouseLeftButtonDown">
+                    <Ellipse.Stroke>
+                        <SolidColorBrush Color="#000000" Opacity="0.1"/>
+                    </Ellipse.Stroke>
+                </Ellipse>
                 <cus:ColorDropBox x:Name="ColorDropPicker" SelectedColorChanged="ColorDropPicker_SelectedColorChanged">
                 </cus:ColorDropBox>
             </StackPanel>

+ 25 - 0
PDF Office/CustomControl/CompositeControl/ColorSubContent.xaml

@@ -0,0 +1,25 @@
+<UserControl x:Class="PDF_Office.CustomControl.CompositeControl.ColorSubContent"
+             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:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:local="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+        <Border Width="56" Height="32" Grid.Column="1" Margin="0,0,5,0" BorderThickness="1" CornerRadius="4" BorderBrush="#E2E3E6"  HorizontalAlignment="Right" >
+            <StackPanel Orientation="Horizontal">
+
+                <Ellipse x:Name="ElcustomColor" Fill="Transparent" Width="20" Height="20" StrokeThickness="1"
+                         PreviewMouseLeftButtonDown="ElcustomColor_PreviewMouseLeftButtonDown">
+                    <Ellipse.Stroke>
+                        <SolidColorBrush Color="#000000" Opacity="0.1"/>
+                    </Ellipse.Stroke>
+                </Ellipse>
+                <cus:ColorDropBox x:Name="ColorDropPicker" SelectedColorChanged="ColorDropPicker_SelectedColorChanged">
+                </cus:ColorDropBox>
+            </StackPanel>
+        </Border>
+    </Grid>
+</UserControl>

+ 42 - 0
PDF Office/CustomControl/CompositeControl/ColorSubContent.xaml.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl.CompositeControl
+{
+    /// <summary>
+    /// ColorSubContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class ColorSubContent : UserControl
+    {
+        public event EventHandler<Color> SelectedColorHandler;
+        public ColorSubContent()
+        {
+            InitializeComponent();
+        }
+
+        private void ElcustomColor_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            SelectedColorHandler?.Invoke(this, (ElcustomColor.Fill as SolidColorBrush).Color);
+        }
+
+        private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
+        {
+           
+            SelectedColorHandler?.Invoke(this, e.Value);
+            ElcustomColor.Fill = new SolidColorBrush(e.Value);
+        }
+
+    }
+}

+ 7 - 0
PDF Office/PDF Office.csproj

@@ -198,6 +198,9 @@
     <Compile Include="CustomControl\CommonWritableComboBox.xaml.cs">
       <DependentUpon>CommonWritableComboBox.xaml</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\CompositeControl\ColorSubContent.xaml.cs">
+      <DependentUpon>ColorSubContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\CustomIconToggleBtn.cs" />
     <Compile Include="CustomControl\CustomImageControl.cs" />
     <Compile Include="CustomControl\DialogContent.cs" />
@@ -716,6 +719,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="CustomControl\CompositeControl\ColorSubContent.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="CustomControl\LoadingControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>