Bläddra i källkod

便签 - 添加便签属性面板

chenrongqian@kdanmobile.com 2 år sedan
förälder
incheckning
06bf8eba82

+ 8 - 0
PDF Office/PDF Office.csproj

@@ -485,6 +485,7 @@
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureAnnotPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureCreateDialogViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SnapshotEditMenuViewModel.cs" />
+    <Compile Include="ViewModels\PropertyPanel\AnnotPanel\StickyNotePropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\ImageEditPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\ImageTextEditPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\PDFEditVM.cs" />
@@ -990,6 +991,9 @@
     <Compile Include="Views\PropertyPanel\AnnotPanel\StampAnnotProperty.xaml.cs">
       <DependentUpon>StampAnnotProperty.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\PropertyPanel\AnnotPanel\StickyNoteProperty.xaml.cs">
+      <DependentUpon>StickyNoteProperty.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\PropertyPanel\AnnotPanel\TextAnnotProperty.xaml.cs">
       <DependentUpon>TextAnnotProperty.xaml</DependentUpon>
     </Compile>
@@ -1705,6 +1709,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\PropertyPanel\AnnotPanel\StickyNoteProperty.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\PropertyPanel\AnnotPanel\TextAnnotProperty.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 128 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/StickyNotePropertyViewModel.cs


+ 19 - 12
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -376,29 +376,36 @@ namespace PDF_Office.ViewModels.Tools
             return freetextArgs;
         }
 
-        private AnnotHandlerEventArgs GetStickyNote()
+        private AnnotHandlerEventArgs GetStickyNote(StickyAnnotArgs selectedStickyArgs = null)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             StickyAnnotArgs stickyAnnotArgs = new StickyAnnotArgs();
-            stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
-            stickyAnnotArgs.StickyNote = string.Empty;
-            stickyAnnotArgs.Transparency = 1;
-            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSticky);
-            if (annotProperty != null)
+
+            if (selectedStickyArgs == null)
+            {
+                stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
+                stickyAnnotArgs.StickyNote = string.Empty;
+                stickyAnnotArgs.Transparency = 1;
+                DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSticky);
+                if (annotProperty != null)
+                {
+                    stickyAnnotArgs.Color = annotProperty.ForgoundColor;
+                    stickyAnnotArgs.StickyNote = annotProperty.NoteText;
+                    stickyAnnotArgs.Transparency = annotProperty.Opacity;
+                }
+            }
+            else
             {
-                stickyAnnotArgs.Color = annotProperty.ForgoundColor;
-                stickyAnnotArgs.StickyNote = annotProperty.NoteText;
-                stickyAnnotArgs.Transparency = annotProperty.Opacity;
+                stickyAnnotArgs = selectedStickyArgs;
             }
 
             annotAttribsList[AnnotAttrib.Color] = stickyAnnotArgs.Color;
             annotAttribsList[AnnotAttrib.Transparency] = stickyAnnotArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = stickyAnnotArgs.StickyNote;
-
-            AddToPropertyPanel("FreetextAnnotProperty", "StickyNote", stickyAnnotArgs, annotAttribsList);
+            annotAttribsList[AnnotAttrib.StickyIcon] = stickyAnnotArgs.IconName;
+            AddToPropertyPanel("StickyNoteProperty", "StickyNote", stickyAnnotArgs, annotAttribsList);
             return stickyAnnotArgs;
         }
-
         private AnnotHandlerEventArgs GetRect(SquareAnnotArgs selectedsquareArgs = null)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();

+ 4 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -677,6 +677,10 @@ namespace PDF_Office.ViewModels.Tools
                         case AnnotArgsType.AnnotLink:
                             GetLink(annot as LinkAnnotArgs, e);
                             break;
+
+                        case AnnotArgsType.AnnotSticky:
+                            GetStickyNote(annot as StickyAnnotArgs);
+                            break;
                     }
 
                     ShowPropertyPanel();

+ 49 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNoteProperty.xaml

@@ -0,0 +1,49 @@
+<UserControl x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.StickyNoteProperty"
+             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:PDF_Office.Views.PropertyPanel.AnnotPanel"
+             xmlns:AnnotPanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
+             d:DataContext="{d:DesignInstance Type=AnnotPanel:StickyNotePropertyViewModel}"
+             xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             xmlns:Convert="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
+             mc:Ignorable="d" 
+             Loaded="UserControl_Loaded"
+             Unloaded="UserControl_Unloaded"
+             d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../Styles/SliderStyle.xaml"></ResourceDictionary>
+            </ResourceDictionary.MergedDictionaries>
+            <Convert:AnnotArgsTypeConverter x:Key="AnnotArgsTypeConverter"/>
+
+        </ResourceDictionary>
+
+    </UserControl.Resources>
+    <Grid  VerticalAlignment="Stretch" Background="#F3F3F3">
+        <StackPanel Margin="12 0 12 0">
+            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="0,16,0,8"
+                       Text="便签"
+                       ></TextBlock>
+            <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
+                <Grid VerticalAlignment="Center" HorizontalAlignment="Center">
+                    <Path Data="{Binding ExmpleData}" Fill="{Binding SharpColor}" Opacity="{Binding Transpent}"/>
+                </Grid>
+            </Border>
+
+
+            <Grid Margin="0,18,0,0">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="auto"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <CompositeControl:SlidContent x:Name="SlidOpacity" HorizontalAlignment="Right">
+                </CompositeControl:SlidContent>
+                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor" />
+            </Grid>
+
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 107 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNoteProperty.xaml.cs

@@ -0,0 +1,107 @@
+using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+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.Views.PropertyPanel.AnnotPanel
+{
+    /// <summary>
+    /// StickyNoteProperty.xaml 的交互逻辑
+    /// </summary>
+    public partial class StickyNoteProperty : UserControl
+    {
+        private StickyNotePropertyViewModel ViewModel => DataContext as StickyNotePropertyViewModel;
+        public StickyNoteProperty()
+        {
+            InitializeComponent();
+            
+        }
+
+        private void ViewModel_LoadPropertyHandler(object sender, object e)
+        {
+            var item = e as AnnotHandlerEventArgs;
+            switch (item.EventType)
+            {
+                case AnnotArgsType.AnnotHighlight:
+                    {
+                        var annot = item as TextHighlightAnnotArgs;
+                        if (annot != null)
+                        {
+                            cusColor.SelectedColor = annot.Color;
+                            SlidOpacity.SetSliOpacity(annot.Transparency);
+                        }
+                        break;
+                    }
+
+                case AnnotArgsType.AnnotUnderline:
+                    {
+                        var annot = item as TextUnderlineAnnotArgs;
+                        if (annot != null)
+                        {
+                            cusColor.SelectedColor = annot.Color;
+                            SlidOpacity.SetSliOpacity(annot.Transparency);
+                        }
+                        break;
+                    }
+
+                case AnnotArgsType.AnnotStrikeout:
+                    {
+                        var annot = item as TextStrikeoutAnnotArgs;
+                        if (annot != null)
+                        {
+                            cusColor.SelectedColor = annot.Color;
+                            SlidOpacity.SetSliOpacity(annot.Transparency);
+                        }
+                        break;
+                    }
+            }
+        }
+
+        private void SlidOpacity_SelectedValue(object sender, double e)
+        {
+            if (ViewModel != null)
+            {
+                ViewModel.SelectedValueChangedCommand?.Execute(e);
+            }
+        }
+
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            if (ViewModel != null)
+            {
+                ViewModel.SelectedColorChangedCommand?.Execute(e);
+            }
+        }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            cusColor.SelectedColorHandler -= cusColor_SelectedColor;
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+
+            SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
+            SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
+
+            ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
+            ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
+        }
+
+        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
+        {
+            cusColor.SelectedColorHandler -= cusColor_SelectedColor;
+            SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
+            ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
+        }
+    }
+}