Browse Source

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

ZhouJieSheng 2 years ago
parent
commit
fa5b312419

+ 152 - 2
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -1,12 +1,162 @@
-using System;
+using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.Model;
+using PDF_Office.ViewModels.Tools;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Controls.Primitives;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-    internal class FreehandAnnotPropertyViewModel
+    public class FreehandAnnotPropertyViewModel : BindableBase, INavigationAware
     {
+
+
+        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
+        public Brush SelectColor
+        {
+            get { return selectColor; }
+            set { SetProperty(ref selectColor, value); SetAnnotProperty(); }
+        }
+
+        private double annotOpacity = 1;
+        public double AnnotOpacity
+        {
+            get { return annotOpacity; }
+            set
+            {
+                SetProperty(ref annotOpacity, value);
+            }
+        }
+
+
+        private double thicknessLine = 1;
+        public double ThicknessLine
+        {
+            get { return thicknessLine; }
+            set
+            {
+                SetProperty(ref thicknessLine, value); SetAnnotProperty();
+            }
+        }
+
+
+        private FreehandAnnotArgs Annot;
+        private AnnotPropertyPanel PropertyPanel;
+        public DelegateCommand<object> EraseCommand { get; set; }
+        public DelegateCommand<object> PenCommand { get; set; }
+
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> SelectedValueChangedCommand { get; set; }
+        public FreehandAnnotPropertyViewModel()
+        {
+            EraseCommand = new DelegateCommand<object>(Erase_Command);
+            PenCommand = new DelegateCommand<object>(Pen_Command);
+
+            SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
+            SelectedValueChangedCommand = new DelegateCommand<object>(SelectedValueChanged_Command);
+        }
+
+        private void SelectedValueChanged_Command(object obj)
+        {
+            if (obj != null)
+            {
+                annotOpacity = (double)obj;
+                    SelectColor.Opacity = annotOpacity;
+
+                SetAnnotProperty();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotArgsType.AnnotFreehand] = annotOpacity;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+        }
+
+        private void SelectedColorChanged_Click(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    SelectColor = new SolidColorBrush(colorValue);
+                    SelectColor.Opacity = AnnotOpacity;
+
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotArgsType.AnnotFreehand] = obj;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+            }
+        }
+
+        private void Erase_Command(object obj)
+        {
+            var btn = obj as ToggleButton;
+            if(btn.IsChecked == true)
+            {
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotArgsType.AnnotErase] = btn;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+        }
+
+        private void Pen_Command(object obj)
+        {
+            var btn = obj as ToggleButton;
+            if (btn.IsChecked == true)
+            {
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotArgsType.AnnotErase] = btn;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+        }
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            if (PropertyPanel != null)
+            {
+                Annot = PropertyPanel.annot as FreehandAnnotArgs;
+            }
+        }
+
+        private void SetAnnotProperty()
+        {
+            if (Annot != null)
+            {
+                if (Annot is FreehandAnnotArgs)
+                {
+                    if (Annot.Transparency != AnnotOpacity)
+                        Annot.Transparency = AnnotOpacity;
+
+                    if (Annot.LineWidth != ThicknessLine)
+                        Annot.LineWidth = ThicknessLine;
+
+                    var c = (SelectColor as SolidColorBrush).Color;
+                    if (Annot.InkColor.A != c.A || Annot.InkColor.B != c.B || Annot.InkColor.G != c.G || Annot.InkColor.R != c.R)
+                        Annot.InkColor = (SelectColor as SolidColorBrush).Color;
+
+                }
+            }
+        }
+
     }
 }

+ 29 - 9
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -80,26 +80,46 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
         public DelegateCommand<object> OpacityItemCommand { get; set; }
         public DelegateCommand<object> OpacityValueChangedCommand { get; set; }
+        public DelegateCommand<object> SelectedValueChangedCommand { get; set; }
 
         public TextAnnotPropertyViewModel()
         {
             SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
             OpacityItemCommand = new DelegateCommand<object>(OpacityItemCommand_Click);
             OpacityValueChangedCommand = new DelegateCommand<object>(OpacityValueChanged_Command);
+            SelectedValueChangedCommand = new DelegateCommand<object>(SelectedValueChanged_Command);
+        }
+
+        private void SelectedValueChanged_Command(object obj)
+        {
+            if (obj != null)
+            {
+                annotOpacity = (double)obj;
+                if (AnnotType == AnnotArgsType.AnnotHighlight)
+                    SampleTextBg.Opacity = annotOpacity;
+                else
+                    SelectColor.Opacity = annotOpacity;
+   
+                SetAnnotProperty();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotType] = annotOpacity;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
         }
 
         private void OpacityItemCommand_Click(object obj)
         {
-            if(obj!= null)
+            if (obj != null)
             {
-                int opacity = -1;
-                if(int.TryParse((string)obj, out opacity))
-                {
-                    AnnotOpacity = opacity/100D;
-                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                    changeData[AnnotType] = AnnotOpacity;
-                    PropertyPanel.DataChangedInvoke(this, changeData);
-                }
+                if (AnnotType == AnnotArgsType.AnnotHighlight)
+                    SampleTextBg.Opacity = annotOpacity;
+                else
+                    SelectColor.Opacity = annotOpacity;
+
+                SetAnnotProperty();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotType] = annotOpacity;
+                PropertyPanel.DataChangedInvoke(this, changeData);
             }
         }
 

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

@@ -20,6 +20,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.Tools
@@ -185,6 +186,98 @@ namespace PDF_Office.ViewModels.Tools
                                 StrikeoutOpacity = (double)e[argsType];
                             }
                             break;
+
+                        case AnnotArgsType.AnnotFreehand:
+                            if (e[argsType] is Color)
+                            {
+                               // FreehandPath.Fill = new SolidColorBrush((Color)e[argsType]);
+                            }
+                            if (e[argsType] is double)
+                            {
+                              //  FreehandPath.Opacity = (double)e[argsType];
+                            }
+                            break;
+                        case AnnotArgsType.AnnotErase:
+                            if (e[argsType] is ToggleButton)
+                            {
+                                ToggleButton clickBtn = e[argsType] as ToggleButton;
+                                //PDFViewerCtrl viewCtrl = GetCurrentViewer();
+                               // ClearSelectedToolPanel(BtnFreeHand);
+                           //     if (viewCtrl != null && viewCtrl.PdfViewer != null)
+                                {
+                                    if (clickBtn.IsChecked == true)
+                                    {
+                                        if (clickBtn.Tag.ToString() == "PenBtn")
+                                        {
+                                            CustomIconToggleBtn btn = new CustomIconToggleBtn();
+                                            btn.Tag = "Freehand"; btn.IsChecked = true;
+                                            BtnMyTools_Click(btn);
+                                            break;
+                                        }
+                                        EraseArgs eraseArgs = new EraseArgs();
+                                        eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
+                                        eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
+                                        eraseArgs.Thickness = 10;
+                                        DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
+                                        if (annotProperty != null)
+                                        {
+                                            eraseArgs.Thickness = annotProperty.Thickness;
+                                        }
+
+                                        PDFViewer.ClearSelectAnnots(false);
+                                        PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                                        PDFViewer.SetToolParam(eraseArgs);
+
+                                        //清空选中注释
+                                        //viewCtrl.PdfViewer.ClearSelectAnnots(false);
+                                        //viewCtrl.PdfViewer.SetMouseMode(MouseModes.AnnotCreate);
+                                        //viewCtrl.PdfViewer.SetToolParam(eraseArgs);
+                                        //if (viewCtrl.PropPanel.Children.Count > 0)
+                                        //{
+                                        //    FreehandAnnotProperty freehandPropPanel = viewCtrl.PropPanel.Children[0] as FreehandAnnotProperty;
+                                        //    if (freehandPropPanel == null)
+                                        //    {
+                                        //        viewCtrl.PropPanel.Children.Clear();
+                                        //        freehandPropPanel = new FreehandAnnotProperty();
+                                        //        freehandPropPanel.EraseSet = true;
+                                        //        freehandPropPanel.SetInkThickness(eraseArgs.Thickness);
+                                        //        freehandPropPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                                        //        viewCtrl.PropPanel.Children.Add(freehandPropPanel);
+                                        //    }
+                                        //    Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
+                                        //    annotAttribsList[AnnotAttrib.Color] = eraseArgs.UIBorderColor;
+                                        //    annotAttribsList[AnnotAttrib.FillColor] = eraseArgs.UIFillColor;
+                                        //    annotAttribsList[AnnotAttrib.Thickness] = eraseArgs.Thickness;
+                                        //    freehandPropPanel.AnnotEvent = null;
+                                        //    freehandPropPanel.SetEraseMode(true);
+                                        //    freehandPropPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(eraseArgs, annotAttribsList);
+                                        //}
+                                        //else
+                                        //{
+                                        //    FreehandAnnotProperty freehandProperty = new FreehandAnnotProperty();
+                                        //    freehandProperty.DataChanged += AnnotPropertyPanel_DataChanged;
+                                        //    Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
+                                        //    annotAttribsList[AnnotAttrib.Color] = eraseArgs.UIBorderColor;
+                                        //    annotAttribsList[AnnotAttrib.FillColor] = eraseArgs.UIFillColor;
+                                        //    annotAttribsList[AnnotAttrib.Thickness] = eraseArgs.Thickness;
+                                        //    freehandProperty.SetInkThickness(eraseArgs.Thickness);
+                                        //    freehandProperty.EraseSet = true;
+                                        //    freehandProperty.SetEraseMode(true);
+                                        //    freehandProperty.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(eraseArgs, annotAttribsList);
+                                        //    viewCtrl.AddAnnotPropertyPanel(freehandProperty);
+
+                                        //}
+                                    }
+                                    else
+                                    {
+                                      
+                                          
+                                      //  BtnFreeHand.IsChecked = true;
+                                      //   BtnTool_Click(BtnFreeHand, new RoutedEventArgs());
+                                    }
+                                }
+                            }
+                            break;
                     }
                 }
             }

+ 10 - 3
PDF Office/Views/PropertyPanel/AnnotPanel/CommonControls/SlidContent.xaml.cs

@@ -75,8 +75,8 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel.CommonControls
         private bool layerAdded = false;
         private Canvas popCanvas;
         private SlidContentPop colorPop;
-        public event EventHandler<Color?> SelectedColorChanged;
-        public event PropertyChangedEventHandler PropertyChanged;
+        public  EventHandler<double> SelectedValueChanged;
+        public event PropertyChangedEventHandler PropertyChanged; 
         protected void OnPropertyChanged([CallerMemberName] string name = null)
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
@@ -105,6 +105,12 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel.CommonControls
             Unloaded += ColorDropBox_Unloaded;
             MouseDown += ColorDropBox_MouseDown;
             colorPop = new SlidContentPop();
+            colorPop.OpacityValueChangedHandler += colorPop_OpacityValueChangedHandler;
+        }
+
+        private void colorPop_OpacityValueChangedHandler(object sender, double e)
+        {
+            SelectedValueChanged?.Invoke(this, e);
         }
 
         private void ColorDropBox_Unloaded(object sender, RoutedEventArgs e)
@@ -236,7 +242,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel.CommonControls
                 //    TransparentRectControl.Visibility = Visibility.Visible;
                 //}
                 SelectedColor = e;
-                SelectedColorChanged?.Invoke(this, SelectedColor);
+              //  SelectedValueChanged?.Invoke(this, SelectedColor);
             }
             RemoveFromLayer();
         }
@@ -267,6 +273,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel.CommonControls
                 //}
             }
         }
+
         //public List<Color> GetThemeColors()
         //{
         //    if (colorPop != null)

+ 2 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/CommonControls/SlidContentPop.xaml

@@ -5,6 +5,7 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel.CommonControls"
              mc:Ignorable="d" 
+             x:Name="usercontorls"
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
         <ResourceDictionary>
@@ -27,7 +28,7 @@
                     <ColumnDefinition Width="auto"/>
                 </Grid.ColumnDefinitions>
                 <Slider Name="OpacitySlider" HorizontalAlignment="Left" VerticalAlignment="Center" Minimum="0" Maximum="1" IsSelectionRangeEnabled="True" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True"
-                     Value="50"
+                     Value="50" ValueChanged="OpacitySlider_ValueChanged"
                     Style="{StaticResource RoundThumbSlider}" Width="148" TickFrequency="0.01" 
                    >
                     <Slider.Resources>

+ 6 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/CommonControls/SlidContentPop.xaml.cs

@@ -20,9 +20,15 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel.CommonControls
     /// </summary>
     public partial class SlidContentPop : UserControl
     {
+        public event EventHandler<double> OpacityValueChangedHandler;
         public SlidContentPop()
         {
             InitializeComponent();
         }
+
+        private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+        {
+            OpacityValueChangedHandler?.Invoke(this, e.NewValue);
+        }
     }
 }

+ 38 - 75
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml

@@ -28,63 +28,12 @@
                 </Setter>
             </Style>
 
-            <DataTemplate x:Key="listboxData">
-                <Ellipse Height="20" Width="20" Fill="{Binding}"/>
-            </DataTemplate>
-
-            <ContextMenu x:Key="FlyoutMenu" FontSize="14"
-                        >
-                <ContextMenu.ItemContainerStyle>
-                    <Style TargetType="MenuItem">
-                        <Setter Property="Padding" Value="0,7,0,7"/>
-                        <Setter Property="VerticalContentAlignment" Value="Center"/>
-                    </Style>
-                </ContextMenu.ItemContainerStyle>
-                <MenuItem Name="ChangeColorMenuItem" Click="ChangeColorMenuItem_Click" Header="更改颜色" IsEnabled="True">
-                </MenuItem>
-                <MenuItem Name="BackColorMenuItem"  Header="恢复默认颜色" IsEnabled="True">
-                </MenuItem>
-            </ContextMenu>
-
-            <Style x:Key="listboxItemStyle" TargetType="{x:Type ListBoxItem}">
-                <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
-                <Setter Property="HorizontalContentAlignment" Value="Center"/>
-                <Setter Property="Margin" Value="2,0,2,0"/>
-            </Style>
+     
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
         <StackPanel>
             <TextBlock Name="AnnotTypeTitle" FontFamily="SegoeUI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="10,8,0,0">Freehand</TextBlock>
-            <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
-                <Grid>
-                    <Path Name="FreehandPath" Fill="Red"
-                  Data="M89.6572823,33.0006836 C92.423623,33.0142613 94.9660238,33.2143167 97.6072943,33.6499257 L98.4450428,33.7953737 C99.2868308,33.9487663 100.141867,
-                  34.1261641 101.020317,34.3291126 L101.906948,34.5406353 L102.811448,34.7695353 L103.736075,35.016156 C103.891982,35.0587552 104.048822,35.1021072 104.206642,
-                  35.1462189 L105.165696,35.4200646 L106.150524,35.7124896 L107.163387,36.0238374 L108.206543,36.3544513 L109.833019,36.8872476 L110.961791,37.2675295 L112.128763,
-                  37.6682797 L113.955787,38.3085341 L117.402465,39.5399202 L119.211464,40.1769086 L120.364856,40.5761585 L122.021403,41.1378013 L123.079875,41.487923 L124.104139,
-                  41.8190107 L125.096343,42.1314171 C125.259158,42.1819476 125.420727,42.2317145 125.581094,42.280725 L126.529238,42.5657708 L127.450693,42.833017 L128.347609,
-                  43.0828164 L129.222133,43.3155218 L130.076415,43.5314857 L130.912603,43.7310609 C131.050579,43.7629773 131.187891,43.7942255 131.324583,43.8248129 L132.137658,
-                  44.0004665 L132.938011,44.160613 L133.727789,44.3056054 L134.509141,44.4357963 C134.638784,44.4562809 134.768165,44.4761635 134.897329,44.4954514 L135.670072,
-                  44.6041013 C136.183976,44.6718555 136.695845,44.7303299 137.208542,44.7799948 L137.978566,44.8479436 C138.492808,44.8889165 139.00931,44.921315 139.530938,
-                  44.9456093 L140.317582,44.9760315 C140.976918,44.9964163 141.646502,45.0045057 142.331927,45.0012184 C154.775594,44.9415382 164.257125,42.4510186 170.805372,
-                  37.5853682 L171.166146,37.3126111 L173,39.6890769 C165.853529,45.1864148 155.625487,47.9374967 142.34636,48.0011838 L141.913337,48.0018385 L141.058707,
-                  47.9944256 C140.63492,47.9877681 140.216149,47.9766406 139.801147,47.960847 L138.975797,47.9229799 C137.333671,47.8345703 135.738542,47.6694101 134.110611,
-                  47.4149484 L133.293542,47.2802176 C133.020028,47.232788 132.745234,47.1828197 132.46879,47.1302546 L131.634137,46.9647107 C130.793795,46.7912602 129.935277,
-                  46.5939154 129.048609,46.3711075 L128.152187,46.1397538 C128.001097,46.0997609 127.849132,46.0590461 127.696246,46.0176023 L126.767518,45.7601317 C126.610766,
-                  45.7157424 126.453,45.6706095 126.294176,45.6247256 L125.328153,45.3403539 L124.334496,45.0376121 L123.310988,44.7161518 L122.255414,44.3756242 L121.165555,
-                  44.0156808 L120.039195,43.6359728 L118.874118,43.2361517 L117.668107,42.8158688 L116.418945,42.3747755 L112.974241,41.1440673 L111.779131,
-                  40.7235819 L110.063231,40.1313765 L108.432894,39.5843521 L107.389894,39.2441882 L106.379456,38.9232327 L105.399396,38.6211366 L104.447526,38.3375511 C104.291109,
-                  38.29181 104.135775,38.2468257 103.981479,38.2025908 L103.067797,37.9461172 C102.917471,37.9048512 102.768092,37.8643201 102.619615,37.8245166 L101.739201,
-                  37.5943699 L100.878235,37.3813385 C99.6002783,37.0744533 98.3805774,36.8241548 97.1859334,36.6251448 L96.3928518,36.5000117 C95.6027538,36.3823605 94.8205132,
-                  36.2869811 94.0362933,36.2123035 L93.2510493,36.1444683 L92.4622998,36.0900856 C91.9348126,36.0582371 91.4035311,36.0351242 90.8655406,36.020282 L90.053159,
-                  36.0041634 C89.916802,36.0024914 89.7799346,36.0013218 89.6425113,36.0006473 C77.496861,35.941034 68.0266419,38.4266795 61.1957691,43.4127083 L60.8119345,
-                  43.6976064 L59,41.3044387 C66.3048995,35.7911443 76.3008484,33.037972 88.9517247,33 L89.6572823,33.0006836 Z" >
-                    </Path>
-                    <Ellipse Name="ErasePath" Fill="#1A000000" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed"></Ellipse>
-                </Grid>
-            </Border>
-
 
             <Border Width="128" Height="32" Margin="0,12,0,0" BorderThickness="1" BorderBrush="#FFE2E3E6">
                 <Grid Name="ToolGrid">
@@ -94,7 +43,7 @@
                     </Grid.ColumnDefinitions>
 
 
-                    <ToggleButton Name="PenBtn" IsChecked="True" IsEnabled="False" Tag="PenBtn" Background="Transparent"  BorderThickness="0"  >
+                    <ToggleButton Name="PenBtn" IsChecked="True" IsEnabled="True" Tag="PenBtn" Background="Transparent"  BorderThickness="0" Click="PenBtn_Click"  Command="{Binding PenCommand}" CommandParameter="{Binding ElementName=PenBtn}" >
                         <Image Width="16" Height="16">
                             <Image.Source>
                                 <DrawingImage>
@@ -129,7 +78,7 @@
 
                     <Line HorizontalAlignment="Left" Style="{StaticResource lineStyle}" VerticalAlignment="Center" Grid.Column="1" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
 
-                    <ToggleButton Name="EraseBtn" Tag="EraseBtn" Background="Transparent" Grid.Column="1" BorderThickness="0" >
+                    <ToggleButton Name="EraseBtn" Tag="EraseBtn" Background="Transparent" Grid.Column="1" BorderThickness="0" Click="EraseBtn_Click" Command="{Binding EraseCommand}" CommandParameter="{Binding ElementName=EraseBtn}">
                         <Path Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#000000" Data="M11,1.796875 L16.703125,7.5 L9.2109375,15 L5.0390625,15 L2.3984375,
                           12.3515625 L2.30688477,12.2502441 C2.22143555,12.1452637 2.15429688,12.0292969 2.10546875,11.9023438 C2.04036458,11.7330729 2.0078125,11.5572917 2.0078125,
                           11.375 C2.0078125,11.1927083 2.04036458,11.0169271 2.10546875,10.8476562 C2.15429688,10.7207031 2.2199707,
@@ -142,31 +91,45 @@
                 </Grid>
             </Border>
 
-            <StackPanel>
+            
+            <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
+                <Grid>
+                    <Path Name="FreehandPath" Fill="Red"
+                  Data="M89.6572823,33.0006836 C92.423623,33.0142613 94.9660238,33.2143167 97.6072943,33.6499257 L98.4450428,33.7953737 C99.2868308,33.9487663 100.141867,
+                  34.1261641 101.020317,34.3291126 L101.906948,34.5406353 L102.811448,34.7695353 L103.736075,35.016156 C103.891982,35.0587552 104.048822,35.1021072 104.206642,
+                  35.1462189 L105.165696,35.4200646 L106.150524,35.7124896 L107.163387,36.0238374 L108.206543,36.3544513 L109.833019,36.8872476 L110.961791,37.2675295 L112.128763,
+                  37.6682797 L113.955787,38.3085341 L117.402465,39.5399202 L119.211464,40.1769086 L120.364856,40.5761585 L122.021403,41.1378013 L123.079875,41.487923 L124.104139,
+                  41.8190107 L125.096343,42.1314171 C125.259158,42.1819476 125.420727,42.2317145 125.581094,42.280725 L126.529238,42.5657708 L127.450693,42.833017 L128.347609,
+                  43.0828164 L129.222133,43.3155218 L130.076415,43.5314857 L130.912603,43.7310609 C131.050579,43.7629773 131.187891,43.7942255 131.324583,43.8248129 L132.137658,
+                  44.0004665 L132.938011,44.160613 L133.727789,44.3056054 L134.509141,44.4357963 C134.638784,44.4562809 134.768165,44.4761635 134.897329,44.4954514 L135.670072,
+                  44.6041013 C136.183976,44.6718555 136.695845,44.7303299 137.208542,44.7799948 L137.978566,44.8479436 C138.492808,44.8889165 139.00931,44.921315 139.530938,
+                  44.9456093 L140.317582,44.9760315 C140.976918,44.9964163 141.646502,45.0045057 142.331927,45.0012184 C154.775594,44.9415382 164.257125,42.4510186 170.805372,
+                  37.5853682 L171.166146,37.3126111 L173,39.6890769 C165.853529,45.1864148 155.625487,47.9374967 142.34636,48.0011838 L141.913337,48.0018385 L141.058707,
+                  47.9944256 C140.63492,47.9877681 140.216149,47.9766406 139.801147,47.960847 L138.975797,47.9229799 C137.333671,47.8345703 135.738542,47.6694101 134.110611,
+                  47.4149484 L133.293542,47.2802176 C133.020028,47.232788 132.745234,47.1828197 132.46879,47.1302546 L131.634137,46.9647107 C130.793795,46.7912602 129.935277,
+                  46.5939154 129.048609,46.3711075 L128.152187,46.1397538 C128.001097,46.0997609 127.849132,46.0590461 127.696246,46.0176023 L126.767518,45.7601317 C126.610766,
+                  45.7157424 126.453,45.6706095 126.294176,45.6247256 L125.328153,45.3403539 L124.334496,45.0376121 L123.310988,44.7161518 L122.255414,44.3756242 L121.165555,
+                  44.0156808 L120.039195,43.6359728 L118.874118,43.2361517 L117.668107,42.8158688 L116.418945,42.3747755 L112.974241,41.1440673 L111.779131,
+                  40.7235819 L110.063231,40.1313765 L108.432894,39.5843521 L107.389894,39.2441882 L106.379456,38.9232327 L105.399396,38.6211366 L104.447526,38.3375511 C104.291109,
+                  38.29181 104.135775,38.2468257 103.981479,38.2025908 L103.067797,37.9461172 C102.917471,37.9048512 102.768092,37.8643201 102.619615,37.8245166 L101.739201,
+                  37.5943699 L100.878235,37.3813385 C99.6002783,37.0744533 98.3805774,36.8241548 97.1859334,36.6251448 L96.3928518,36.5000117 C95.6027538,36.3823605 94.8205132,
+                  36.2869811 94.0362933,36.2123035 L93.2510493,36.1444683 L92.4622998,36.0900856 C91.9348126,36.0582371 91.4035311,36.0351242 90.8655406,36.020282 L90.053159,
+                  36.0041634 C89.916802,36.0024914 89.7799346,36.0013218 89.6425113,36.0006473 C77.496861,35.941034 68.0266419,38.4266795 61.1957691,43.4127083 L60.8119345,
+                  43.6976064 L59,41.3044387 C66.3048995,35.7911443 76.3008484,33.037972 88.9517247,33 L89.6572823,33.0006836 Z" >
+                    </Path>
+                    <Ellipse Name="ErasePath" Fill="#1A000000" Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed"></Ellipse>
+                </Grid>
+            </Border>
+
+            <StackPanel x:Name="PnlPen">
                 <Grid Margin="0,18,0,0">
                     <Grid.RowDefinitions>
                         <RowDefinition Height="auto"/>
                         <RowDefinition/>
                     </Grid.RowDefinitions>
                     <CommonControls:SlidContent x:Name="layerThick" HorizontalAlignment="Right"/>
-                    <Grid Grid.Row="1">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="*"></ColumnDefinition>
-                            <ColumnDefinition Width="auto"></ColumnDefinition>
-                        </Grid.ColumnDefinitions>
-                        <cus:ColorDropBox x:Name="ColorDropPicker"  Grid.Column="1" BorderThickness="1"  HorizontalAlignment="Right"
-                                BorderBrush="#E2E3E6" Width="80" Height="32">
-                        </cus:ColorDropBox>
-                        <ListBox x:Name="ListColor" ItemContainerStyle="{StaticResource listboxItemStyle}" ItemTemplate="{StaticResource listboxData}" BorderThickness="0" Background="Transparent">
-                            <ListBox.ItemsPanel>
-                                <ItemsPanelTemplate>
-                                    <WrapPanel Orientation="Horizontal"/>
-                                </ItemsPanelTemplate>
-                            </ListBox.ItemsPanel>
-
-                        </ListBox>
-                    </Grid>
-
+                    
+                    <CommonControls:ColorContent Grid.Row="1" x:Name="cusColor"/>
                 </Grid>
 
                 <TextBlock x:Name="borderText" LineHeight="20" Margin="12,14,0,0" >Border</TextBlock>
@@ -176,7 +139,7 @@
                         <ColumnDefinition Width="auto"></ColumnDefinition>
                     </Grid.ColumnDefinitions>
                     <Slider Name="BorderSlider" VerticalAlignment="Center" Margin="12,0,4,0"  Minimum="1" Maximum="12" IsSelectionRangeEnabled="True" IsMoveToPointEnabled="True"
-                    Style="{StaticResource RoundThumbSlider}"  TickFrequency="1" IsSnapToTickEnabled="True" >
+                    Style="{StaticResource RoundThumbSlider}"  TickFrequency="1" IsSnapToTickEnabled="True" Value="{Binding ThicknessLine}">
                         <Slider.Resources>
                             <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
                             <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
@@ -223,7 +186,7 @@
 
 
 
-            <StackPanel x:Name="PanelEraser">
+            <StackPanel x:Name="PnlEraser">
                 <TextBlock x:Name="eText" LineHeight="20" Margin="12,14,0,0" >Border</TextBlock>
                 <Grid>
                     <Grid.ColumnDefinitions>

+ 54 - 12
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -20,24 +21,65 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
     /// </summary>
     public partial class FreehandAnnotProperty : UserControl
     {
-        private List<string> colors = new List<string>();
         public FreehandAnnotProperty()
         {
             InitializeComponent();
-            colors.Add("#FFFF10");
-            colors.Add("#FF1010");
-            colors.Add("#10FF10");
-            colors.Add("#1070FF");
-            ListColor.ItemsSource = colors;
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+            layerThick.SelectedValueChanged += layerThick_SelectedValue;
         }
 
-        private void ChangeColorMenuItem_Click(object sender, RoutedEventArgs e)
+        private void layerThick_SelectedValue(object sender, double e)
         {
-            var data = (sender as FrameworkElement).DataContext as string;
-            var listBoxItem = ListColor.ItemContainerGenerator.ContainerFromItem(data) as ListBoxItem;
+            var data = this.DataContext as FreehandAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedValueChangedCommand?.Execute(e);
+                // data.SelectColor = e;
+            }
+        }
+
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as FreehandAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedColorChangedCommand?.Execute(e);
+            }
+        }
+
+        private void EraseBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if (EraseBtn.IsChecked == true)
+            {
+                ErasePath.Visibility = Visibility.Visible;
+                FreehandPath.Visibility = Visibility.Collapsed;
+                PnlPen.Visibility = Visibility.Collapsed;
+                PnlEraser.Visibility = Visibility.Visible;
+
+                PenBtn.IsChecked = !EraseBtn.IsChecked;
+            }
+            else
+            {
+                EraseBtn.IsChecked = true;
+            }
+               
+        }
+
+        private void PenBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if (PenBtn.IsChecked == true)
+            {
+                FreehandPath.Visibility = Visibility.Visible;
+                ErasePath.Visibility = Visibility.Collapsed;
+                PnlPen.Visibility = Visibility.Visible;
+                PnlEraser.Visibility = Visibility.Collapsed;
 
-            if (listBoxItem != null)
-                ColorDropPicker?.ShowLayer(listBoxItem);
+                EraseBtn.IsChecked = !PenBtn.IsChecked;
+            }
+            else
+            {
+                PenBtn.IsChecked = true;
+            }
         }
     }
 }

+ 5 - 47
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -37,27 +37,7 @@
                     </Setter.Value>
                 </Setter>
             </Style>
-
-
-            <DataTemplate x:Key="listboxData">
-                <Ellipse Height="20" Width="20" Fill="{Binding}"/>
-            </DataTemplate>
-
-            <ContextMenu x:Key="FlyoutMenu" FontSize="14"
-                        >
-                <ContextMenu.ItemContainerStyle>
-                    <Style TargetType="MenuItem">
-                        <Setter Property="Padding" Value="0,7,0,7"/>
-                        <Setter Property="VerticalContentAlignment" Value="Center"/>
-                    </Style>
-                </ContextMenu.ItemContainerStyle>
-                <MenuItem Name="ChangeColorMenuItem" Click="ChangeColorMenuItem_Click" Header="更改颜色" IsEnabled="True">
-                </MenuItem>
-                <MenuItem Name="BackColorMenuItem"  Header="恢复默认颜色" IsEnabled="True">
-                </MenuItem>
-            </ContextMenu>
-
-
+            
             <ContextMenu x:Key="BtnFlyoutMenu" FontSize="14"
                         >
                 <ContextMenu.ItemContainerStyle>
@@ -72,11 +52,6 @@
                 </MenuItem>
             </ContextMenu>
 
-            <Style x:Key="listboxItemStyle" TargetType="{x:Type ListBoxItem}">
-                <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>
-                <Setter Property="HorizontalContentAlignment" Value="Center"/>
-                <Setter Property="Margin" Value="2,0,2,0"/>
-            </Style>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
@@ -248,19 +223,19 @@
                             <ColumnDefinition Width="*"></ColumnDefinition>
                         </Grid.ColumnDefinitions>
 
-                        <ToggleButton Name="TextAlignLeftBtn" Tag="AlignLeft" Background="Transparent" BorderThickness="0" >
+                        <ToggleButton Name="TextAlignLeftBtn" Tag="AlignLeft" Background="Transparent" BorderThickness="0" Click="BtnTextAlign_Click">
                             <Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#000000" Data="M10,11 L10,12 L0,12 L0,11 L10,11 Z M16,7 L16,8 L0,8 L0,7 L16,7 Z M13,3 L13,4 L0,4 L0,3 L13,3 Z">
                             </Path>
                         </ToggleButton>
                         <Line HorizontalAlignment="Left" Style="{StaticResource line1Style}" VerticalAlignment="Center" Grid.Column="1" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
 
-                        <ToggleButton Name="TextAlignCenterBtn" Tag="AlignCenter" Grid.Column="1" Background="Transparent"  BorderThickness="0" >
+                        <ToggleButton Name="TextAlignCenterBtn" Tag="AlignCenter" Grid.Column="1" Background="Transparent"  BorderThickness="0"  Click="BtnTextAlign_Click">
                             <Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#000000" Data="M16,11 L16,12 L0,12 L0,11 L16,11 Z M13,7 L13,8 L3,8 L3,7 L13,7 Z M16,3 L16,4 L0,4 L0,3 L16,3 Z">
                             </Path>
                         </ToggleButton>
                         <Line HorizontalAlignment="Left" Style="{StaticResource line2Style}" VerticalAlignment="Center" Grid.Column="2" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
 
-                        <ToggleButton Name="TextAlignRightBtn" Tag="AlignRight" Grid.Column="2" Background="Transparent"  BorderThickness="0" >
+                        <ToggleButton Name="TextAlignRightBtn" Tag="AlignRight" Grid.Column="2" Background="Transparent"  BorderThickness="0"  Click="BtnTextAlign_Click">
                             <Path HorizontalAlignment="Center" VerticalAlignment="Center"  Fill="#000000" Data="M16,11 L16,12 L6.00061035,12 L6.00061035,11 L16,11 Z M16,7 L16,8 L0.0009765625,8 L0.0009765625,7 L16,7 Z M16,3 L16,4 L3.00079346,4 L3.00079346,3 L16,3 Z">
                             </Path>
                         </ToggleButton>
@@ -275,24 +250,7 @@
                     <RowDefinition/>
                 </Grid.RowDefinitions>
                 <CommonControls:SlidContent x:Name="layerThick" HorizontalAlignment="Right"/>
-                <Grid Grid.Row="1">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="*"></ColumnDefinition>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                    </Grid.ColumnDefinitions>
-                    <cus:ColorDropBox x:Name="ColorDropPicker"  Grid.Column="1" BorderThickness="1"  HorizontalAlignment="Right"
-                                BorderBrush="#E2E3E6" Width="80" Height="32" >
-                    </cus:ColorDropBox>
-                    <ListBox x:Name="ListColor" ItemContainerStyle="{StaticResource listboxItemStyle}" ItemTemplate="{StaticResource listboxData}" BorderThickness="0" Background="Transparent">
-                        <ListBox.ItemsPanel>
-                            <ItemsPanelTemplate>
-                                <WrapPanel Orientation="Horizontal"/>
-                            </ItemsPanelTemplate>
-                        </ListBox.ItemsPanel>
-
-                    </ListBox>
-                </Grid>
-
+                <CommonControls:ColorContent Grid.Row="1" x:Name="cusColor"/>
             </Grid>
 
 

+ 17 - 11
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

@@ -5,6 +5,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using System.Windows.Documents;
 using System.Windows.Input;
@@ -20,24 +21,29 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
     /// </summary>
     public partial class FreetextAnnotProperty : UserControl
     {
-        private List<string> colors = new List<string>();
+      
         public FreetextAnnotProperty()
         {
             InitializeComponent();
-            colors.Add("#FFFF10");
-            colors.Add("#FF1010");
-            colors.Add("#10FF10");
-            colors.Add("#1070FF");
-            ListColor.ItemsSource = colors;
+          
         }
 
-        private void ChangeColorMenuItem_Click(object sender, RoutedEventArgs e)
+        private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
         {
-            var data = (sender as FrameworkElement).DataContext as string;
-            var listBoxItem = ListColor.ItemContainerGenerator.ContainerFromItem(data) as ListBoxItem;
 
-            if (listBoxItem != null)
-                ColorDropPicker?.ShowLayer(listBoxItem);
+            var btn = sender as ToggleButton;
+            foreach(var item in ToolGrid.Children)
+            {
+                var btnItem = item as ToggleButton;
+                if(btnItem != null)
+                {
+                    if(btn!= btnItem)
+                        btnItem.IsChecked = false;
+                    else
+                        btnItem.IsChecked = true;
+                }
+            }
+           
         }
     }
 }

+ 7 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml

@@ -62,7 +62,13 @@
                     <RowDefinition Height="auto"/>
                     <RowDefinition/>
                 </Grid.RowDefinitions>
-                <CommonControls:SlidContent x:Name="SlidOpacity" HorizontalAlignment="Right"/>
+                <CommonControls:SlidContent x:Name="SlidOpacity" HorizontalAlignment="Right">
+                    <!--<i:Interaction.Triggers>
+                        <i:EventTrigger EventName="SelectedValueChanged">
+                            <i:InvokeCommandAction Command="{Binding SelectedValueChangedCommand}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>-->
+                </CommonControls:SlidContent>
                 <CommonControls:ColorContent Grid.Row="1" x:Name="cusColor"/>
             </Grid>
 

+ 11 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml.cs

@@ -29,6 +29,17 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         {
             InitializeComponent();
             cusColor.SelectedColorHandler += cusColor_SelectedColor;
+            SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
+        }
+
+        private void SlidOpacity_SelectedValue(object sender, double e)
+        {
+            var data = this.DataContext as TextAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedValueChangedCommand?.Execute(e);
+                // data.SelectColor = e;
+            }
         }
 
         private void cusColor_SelectedColor(object sender, Color e)