Browse Source

注释 - 调整更改注释属性值的逻辑

chenrongqian 2 years ago
parent
commit
8a6ad05048

+ 2 - 2
PDF Office/Styles/CustomBtnStyle.xaml

@@ -70,12 +70,12 @@
                             <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}" />
                             <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}" />
                             <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}" />
                             <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}" />
                         </Trigger>
                         </Trigger>
-                        <Trigger Property="IsEnabled" Value="false">
+                        <!--<Trigger Property="IsEnabled" Value="false">
                             <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Disabled.Background}" />
                             <Setter TargetName="border" Property="Background" Value="{StaticResource Button.Disabled.Background}" />
                             <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Border}" />
                             <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Border}" />
                             <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{StaticResource Button.Disabled.Foreground}" />
                             <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{StaticResource Button.Disabled.Foreground}" />
                             <Setter TargetName="contentPresenter" Property="Opacity" Value="0.5" />
                             <Setter TargetName="contentPresenter" Property="Opacity" Value="0.5" />
-                        </Trigger>
+                        </Trigger>-->
                     </ControlTemplate.Triggers>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>
                 </ControlTemplate>
             </Setter.Value>
             </Setter.Value>

+ 13 - 24
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -1,4 +1,5 @@
-using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
 using PDF_Office.Model;
 using PDF_Office.Model;
 using PDF_Office.ViewModels.Tools;
 using PDF_Office.ViewModels.Tools;
 using Prism.Commands;
 using Prism.Commands;
@@ -22,7 +23,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public Brush SelectColor
         public Brush SelectColor
         {
         {
             get { return selectColor; }
             get { return selectColor; }
-            set { SetProperty(ref selectColor, value); SetAnnotProperty(); }
+            set { SetProperty(ref selectColor, value); 
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (SelectColor as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+            }
         }
         }
 
 
         private double annotOpacity = 1;
         private double annotOpacity = 1;
@@ -42,11 +46,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             get { return thicknessLine; }
             get { return thicknessLine; }
             set
             set
             {
             {
-                SetProperty(ref thicknessLine, value); SetAnnotProperty();
+                SetProperty(ref thicknessLine, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, thicknessLine);
+                AnnotEvent?.UpdateAnnot();
             }
             }
         }
         }
 
 
 
 
+        public AnnotAttribEvent AnnotEvent { get; set; }
         private FreehandAnnotArgs Annot;
         private FreehandAnnotArgs Annot;
         private AnnotPropertyPanel PropertyPanel;
         private AnnotPropertyPanel PropertyPanel;
         public DelegateCommand<object> EraseCommand { get; set; }
         public DelegateCommand<object> EraseCommand { get; set; }
@@ -70,7 +77,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 annotOpacity = (double)obj;
                 annotOpacity = (double)obj;
                     SelectColor.Opacity = annotOpacity;
                     SelectColor.Opacity = annotOpacity;
 
 
-                SetAnnotProperty();
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
+                AnnotEvent?.UpdateAnnot();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 changeData[AnnotArgsType.AnnotFreehand] = annotOpacity;
                 changeData[AnnotArgsType.AnnotFreehand] = annotOpacity;
                 PropertyPanel.DataChangedInvoke(this, changeData);
                 PropertyPanel.DataChangedInvoke(this, changeData);
@@ -134,29 +142,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
             navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
             if (PropertyPanel != null)
             if (PropertyPanel != null)
             {
             {
+                AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot as FreehandAnnotArgs;
                 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;
-
-                }
-            }
-        }
-
     }
     }
 }
 }

+ 109 - 2
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -1,12 +1,119 @@
-using System;
+using ComPDFKitViewer;
+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.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using System.Windows.Media;
 
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
 {
-    internal class FreetextAnnotPropertyViewModel
+    public class FreetextAnnotPropertyViewModel : BindableBase, INavigationAware
     {
     {
+        private double fillOpacity = 1;
+        public double FillOpacity
+        {
+            get { return fillOpacity; }
+            set
+            {
+                SetProperty(ref fillOpacity, value);
+            }
+        }
+
+        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
+        public Brush SelectColor
+        {
+            get { return selectColor; }
+            set
+            {
+                SetProperty(ref selectColor, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, (selectColor as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+        private Brush fillColor = new SolidColorBrush(Colors.Transparent);
+        public Brush FillColor
+        {
+            get { return fillColor; }
+            set
+            {
+                SetProperty(ref fillColor, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, (fillColor as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+        public DelegateCommand<object> SelectedColorCommand { get; set; }
+        public DelegateCommand<object> SelectedFillColorCommand { get; set; }
+        public FreetextAnnotPropertyViewModel()
+        {
+            SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
+            SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColor_Command);
+        }
+
+        private void SelectedFillColor_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    FillColor = new SolidColorBrush(colorValue);
+                    FillColor.Opacity = FillOpacity;
+
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotArgsType.AnnotFreehand] = obj;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+            }
+        }
+
+        private void SelectedColor_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    SelectColor = new SolidColorBrush(colorValue);
+                    SelectColor.Opacity = FillOpacity;
+
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotArgsType.AnnotFreehand] = obj;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        public AnnotAttribEvent AnnotEvent { get; set; }
+        private FreeTextAnnotArgs Annot;
+        private AnnotPropertyPanel PropertyPanel;
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            if (PropertyPanel != null)
+            {
+                AnnotEvent = PropertyPanel.AnnotEvent;
+                Annot = PropertyPanel.annot as FreeTextAnnotArgs;
+            }
+        }
     }
     }
 }
 }

+ 221 - 2
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -1,12 +1,231 @@
-using System;
+using ComPDFKitViewer;
+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.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using System.Windows.Media;
 
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
 {
-    internal class SharpsAnnotPropertyViewModel
+    public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
     {
     {
+        private AnnotArgsType annotType;
+        public AnnotArgsType AnnotType
+        {
+            get { return annotType; }
+            set
+            {
+                SetProperty(ref annotType, value);
+                SetAnnotType();
+            }
+        }
+
+        private string annotTypeTitle;
+        public string AnnotTypeTitle
+        {
+            get { return annotTypeTitle; }
+            set
+            {
+                SetProperty(ref annotTypeTitle, value);
+            }
+        }
+
+        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
+        public Brush SelectColor
+        {
+            get { return selectColor; }
+            set
+            {
+                SetProperty(ref selectColor, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+        private Brush fillColor = new SolidColorBrush(Colors.Transparent);
+        public Brush FillColor
+        {
+            get { return fillColor; }
+            set { 
+                SetProperty(ref fillColor, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, (fillColor as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+
+        private double borderOpacity = 1;
+        public double BorderOpacity
+        {
+            get { return borderOpacity; }
+            set
+            {
+                SetProperty(ref borderOpacity, value);
+            }
+        }
+
+        private double fillOpacity = 1;
+        public double FillOpacity
+        {
+            get { return fillOpacity; }
+            set
+            {
+                SetProperty(ref fillOpacity, value);
+            }
+        }
+
+        private double lineWidth = 1;
+        public double LineWidth
+        {
+            get { return lineWidth; }
+            set
+            {
+                SetProperty(ref lineWidth, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, lineWidth);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+        public DelegateCommand<object> SelectedThickCommand { get; set; }
+        public DelegateCommand<object> SelectedColorCommand { get; set; }
+
+        public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
+        public DelegateCommand<object> SelectedFillColorCommand { get; set; }
+
+        public DelegateCommand<object> LineStyleCommand { get; set; }
+        public SharpsAnnotPropertyViewModel()
+        {
+            SelectedThickCommand = new DelegateCommand<object>(SelectedThick_Command);
+            SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
+            SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity_Command);
+            SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColor_Command);
+            LineStyleCommand = new DelegateCommand<object>(LineStyle_Command);
+
+        }
+
+        private void LineStyle_Command(object obj)
+        {
+            if(obj!= null)
+            {
+                var tag = obj as string;
+                if(tag == "Solid")
+                {
+
+                }
+                else
+                {
+
+                }
+            }
+        }
+
+        private void SelectedFillColor_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    FillColor = new SolidColorBrush(colorValue);
+                    FillColor.Opacity = FillOpacity;
+
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotArgsType.AnnotFreehand] = obj;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+            }
+           
+        }
+
+        private void SelectedFillOpacity_Command(object obj)
+        {
+            if (obj != null)
+            {
+                FillOpacity = (double)obj;
+                SelectColor.Opacity = FillOpacity;
+
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, FillOpacity);
+                AnnotEvent?.UpdateAnnot();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+        }
+
+        private void SelectedColor_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    SelectColor = new SolidColorBrush(colorValue);
+                    SelectColor.Opacity = FillOpacity;
+
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotArgsType.AnnotFreehand] = obj;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+            }
+        }
+
+        private void SelectedThick_Command(object obj)
+        {
+          
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+        private void SetAnnotType()
+        {
+            switch (AnnotType)
+            {
+                case AnnotArgsType.AnnotCircle:
+                    AnnotTypeTitle = "圆";
+                    break;
+                case AnnotArgsType.AnnotSquare:
+                    AnnotTypeTitle = "矩形";
+                    break;
+                case AnnotArgsType.AnnotLine:
+                    AnnotTypeTitle = "线";
+                  var annotLine =  Annot as LineAnnotArgs;
+                    if (annotLine != null)
+                    {
+                        
+                    }
+                    break;
+            }
+        }
+
+        public AnnotAttribEvent AnnotEvent { get; set; }
+        private AnnotHandlerEventArgs Annot;
+        private AnnotPropertyPanel PropertyPanel;
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            if (PropertyPanel != null)
+            {
+                AnnotEvent = PropertyPanel.AnnotEvent;
+                AnnotType = PropertyPanel.annot.EventType;
+                Annot = PropertyPanel.annot;
+            }
+        }
+
     }
     }
 }
 }

+ 24 - 71
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -1,4 +1,5 @@
-using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
 using PDF_Office.Model;
 using PDF_Office.Model;
 using PDF_Office.ViewModels.Tools;
 using PDF_Office.ViewModels.Tools;
 using PDFSettings;
 using PDFSettings;
@@ -62,7 +63,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public Brush SampleTextBg
         public Brush SampleTextBg
         {
         {
             get { return sampleTextBg; }
             get { return sampleTextBg; }
-            set { SetProperty(ref sampleTextBg, value); SetAnnotProperty(); }
+            set { SetProperty(ref sampleTextBg, value); 
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (sampleTextBg as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+            }
         }
         }
 
 
 
 
@@ -70,11 +74,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public Brush SelectColor
         public Brush SelectColor
         {
         {
             get { return selectColor; }
             get { return selectColor; }
-            set { SetProperty(ref selectColor, value); SetAnnotProperty(); }
+            set { 
+                SetProperty(ref selectColor, value);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
+                AnnotEvent?.UpdateAnnot();
+               // SetAnnotProperty(); 
+            }
         }
         }
 
 
         #endregion
         #endregion
 
 
+        public AnnotAttribEvent AnnotEvent { get; set; }
         private AnnotHandlerEventArgs Annot;
         private AnnotHandlerEventArgs Annot;
         private AnnotPropertyPanel PropertyPanel;
         private AnnotPropertyPanel PropertyPanel;
         public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
         public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
@@ -99,8 +109,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     SampleTextBg.Opacity = annotOpacity;
                     SampleTextBg.Opacity = annotOpacity;
                 else
                 else
                     SelectColor.Opacity = annotOpacity;
                     SelectColor.Opacity = annotOpacity;
-   
-                SetAnnotProperty();
+
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
+                AnnotEvent?.UpdateAnnot();
+           
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 changeData[AnnotType] = annotOpacity;
                 changeData[AnnotType] = annotOpacity;
                 PropertyPanel.DataChangedInvoke(this, changeData);
                 PropertyPanel.DataChangedInvoke(this, changeData);
@@ -116,7 +128,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 else
                 else
                     SelectColor.Opacity = annotOpacity;
                     SelectColor.Opacity = annotOpacity;
 
 
-                SetAnnotProperty();
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
+                AnnotEvent?.UpdateAnnot();
+      
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 changeData[AnnotType] = annotOpacity;
                 changeData[AnnotType] = annotOpacity;
                 PropertyPanel.DataChangedInvoke(this, changeData);
                 PropertyPanel.DataChangedInvoke(this, changeData);
@@ -132,7 +146,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 else
                 else
                     SelectColor.Opacity = annotOpacity;
                     SelectColor.Opacity = annotOpacity;
 
 
-                SetAnnotProperty();
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
+                AnnotEvent?.UpdateAnnot();
+               
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 changeData[AnnotType] = annotOpacity;
                 changeData[AnnotType] = annotOpacity;
                 PropertyPanel.DataChangedInvoke(this, changeData);
                 PropertyPanel.DataChangedInvoke(this, changeData);
@@ -209,6 +225,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
           //  navigationContext.Parameters.TryGetValue<ComPDFKitViewer.PdfViewer.CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
           //  navigationContext.Parameters.TryGetValue<ComPDFKitViewer.PdfViewer.CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             if(PropertyPanel != null)
             if(PropertyPanel != null)
             {
             {
+                AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot;
                 Annot = PropertyPanel.annot;
                 AnnotType = Annot.EventType;
                 AnnotType = Annot.EventType;
                 GetAnnotProperty();
                 GetAnnotProperty();
@@ -254,69 +271,5 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
                 }
             }
             }
         }
         }
-
-
-        private void SetAnnotProperty()
-        {
-            if (Annot != null)
-            {
-                switch (Annot.EventType)
-                {
-                    case AnnotArgsType.AnnotHighlight:
-                        if (Annot is TextHighlightAnnotArgs)
-                        {
-                            var Hightlight = Annot as TextHighlightAnnotArgs;
-
-                            if (Hightlight.Transparency != AnnotOpacity)
-                                Hightlight.Transparency = AnnotOpacity;
-
-                            var c = (SampleTextBg as SolidColorBrush).Color;
-                            if (Hightlight.Color.A != c.A || Hightlight.Color.B != c.B || Hightlight.Color.G != c.G || Hightlight.Color.R != c.R)
-                                Hightlight.Color = (SampleTextBg as SolidColorBrush).Color;
-
-                        }
-                        break;
-
-                    case AnnotArgsType.AnnotUnderline:
-                        {
-                            var Underline = Annot as TextUnderlineAnnotArgs;
-
-                            if (Underline.Transparency != AnnotOpacity)
-                                Underline.Transparency = AnnotOpacity;
-
-                            var c = (SelectColor as SolidColorBrush).Color;
-                            if (Underline.Color.A != c.A || Underline.Color.B != c.B || Underline.Color.G != c.G || Underline.Color.R != c.R)
-                                Underline.Color = (SelectColor as SolidColorBrush).Color;
-                        }
-                        break;
-
-                    case AnnotArgsType.AnnotSquiggly:
-                        {
-                            var Squiggly = Annot as TextSquigglyAnnotArgs;
-                            if (Squiggly.Transparency != AnnotOpacity)
-                                AnnotOpacity = Squiggly.Transparency;
-
-                            var c = (SelectColor as SolidColorBrush).Color;
-                            if (Squiggly.Color.A != c.A || Squiggly.Color.B != c.B || Squiggly.Color.G != c.G || Squiggly.Color.R != c.R)
-                                Squiggly.Color = (SelectColor as SolidColorBrush).Color;
-                        }
-                        break;
-
-                    case AnnotArgsType.AnnotStrikeout:
-                        {
-                            var Strikeout = Annot as TextStrikeoutAnnotArgs;
-                            if (Strikeout.Transparency != AnnotOpacity)
-                                Strikeout.Transparency = AnnotOpacity;
-
-                            var c = (SelectColor as SolidColorBrush).Color;
-                            if (Strikeout.Color.A != c.A || Strikeout.Color.B != c.B || Strikeout.Color.G != c.G || Strikeout.Color.R != c.R)
-                                Strikeout.Color = (SelectColor as SolidColorBrush).Color;
-                        }
-                        break;
-
-                }
-            }
-        }
-
     }
     }
 }
 }

+ 16 - 13
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -139,7 +139,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
 
 
-            AddToPropertyPanel(highlightArgs, "HighLight", "TextAnnotProperty");
+            AddToPropertyPanel(highlightArgs, "HighLight", "TextAnnotProperty", annotAttribsList);
             return highlightArgs;
             return highlightArgs;
         }
         }
 
 
@@ -160,7 +160,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
           
           
-            AddToPropertyPanel(underlineArgs, "UnderLine", "TextAnnotProperty");
+            AddToPropertyPanel(underlineArgs, "UnderLine", "TextAnnotProperty", annotAttribsList);
             return underlineArgs;
             return underlineArgs;
         }
         }
 
 
@@ -181,7 +181,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
 
 
-            AddToPropertyPanel(squigglyArgs, "Squiggly", "TextAnnotProperty");
+            AddToPropertyPanel(squigglyArgs, "Squiggly", "TextAnnotProperty", annotAttribsList);
             return squigglyArgs;
             return squigglyArgs;
         }
         }
 
 
@@ -202,7 +202,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
 
 
-            AddToPropertyPanel(strikeoutArgs, "Strikeout", "TextAnnotProperty");
+            AddToPropertyPanel(strikeoutArgs, "Strikeout", "TextAnnotProperty", annotAttribsList);
             return strikeoutArgs;
             return strikeoutArgs;
         }
         }
 
 
@@ -226,7 +226,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
             annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
             annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
             annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
 
 
-            AddToPropertyPanel(freehandArgs, "Freehand", "FreehandAnnotProperty");
+            AddToPropertyPanel(freehandArgs, "Freehand", "FreehandAnnotProperty", annotAttribsList);
             return freehandArgs;
             return freehandArgs;
         }
         }
 
 
@@ -279,7 +279,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
             annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
             annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
             annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
 
 
-            AddToPropertyPanel(freetextArgs, "Freetext", "FreetextAnnotProperty");
+            AddToPropertyPanel(freetextArgs, "Freetext", "FreetextAnnotProperty", annotAttribsList);
             return freetextArgs;
             return freetextArgs;
         }
         }
 
 
@@ -303,7 +303,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = stickyAnnotArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = stickyAnnotArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = stickyAnnotArgs.StickyNote;
             annotAttribsList[AnnotAttrib.NoteText] = stickyAnnotArgs.StickyNote;
 
 
-            AddToPropertyPanel(stickyAnnotArgs, "StickyNote", "FreetextAnnotProperty");
+            AddToPropertyPanel(stickyAnnotArgs, "StickyNote", "FreetextAnnotProperty", annotAttribsList);
             return stickyAnnotArgs;
             return stickyAnnotArgs;
         }
         }
 
 
@@ -346,7 +346,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = squareArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = squareArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = squareArgs.Content;
             annotAttribsList[AnnotAttrib.NoteText] = squareArgs.Content;
 
 
-            AddToPropertyPanel(squareArgs, "Rect", "SharpsAnnotProperty");
+            AddToPropertyPanel(squareArgs, "Rect", "SharpsAnnotProperty", annotAttribsList);
             return squareArgs;
             return squareArgs;
         }
         }
 
 
@@ -389,7 +389,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = circleAnnotArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = circleAnnotArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = circleAnnotArgs.Content;
             annotAttribsList[AnnotAttrib.NoteText] = circleAnnotArgs.Content;
 
 
-            AddToPropertyPanel(circleAnnotArgs, "Circle", "SharpsAnnotProperty");
+            AddToPropertyPanel(circleAnnotArgs, "Circle", "SharpsAnnotProperty", annotAttribsList);
             return circleAnnotArgs;
             return circleAnnotArgs;
         }
         }
 
 
@@ -451,7 +451,7 @@ namespace PDF_Office.ViewModels.Tools
             annotAttribsList[AnnotAttrib.Transparency] = lineArgs.Transparency;
             annotAttribsList[AnnotAttrib.Transparency] = lineArgs.Transparency;
             annotAttribsList[AnnotAttrib.NoteText] = lineArgs.Content;
             annotAttribsList[AnnotAttrib.NoteText] = lineArgs.Content;
 
 
-            AddToPropertyPanel(lineArgs, TagStr, "SharpsAnnotProperty");
+            AddToPropertyPanel(lineArgs, TagStr, "SharpsAnnotProperty", annotAttribsList);
             return lineArgs;
             return lineArgs;
         }
         }
 
 
@@ -465,7 +465,7 @@ namespace PDF_Office.ViewModels.Tools
 
 
             annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
             annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
 
 
-            AddToPropertyPanel(stampAnnotArgs, null, "StampAnnotProperty");
+            AddToPropertyPanel(stampAnnotArgs, null, "StampAnnotProperty", annotAttribsList);
             return stampAnnotArgs;
             return stampAnnotArgs;
         }
         }
 
 
@@ -485,12 +485,12 @@ namespace PDF_Office.ViewModels.Tools
               
               
             }
             }
 
 
-            AddToPropertyPanel(stampArgs, null, "ImageAnnotProperty");
+            AddToPropertyPanel(stampArgs, null, "ImageAnnotProperty", annotAttribsList);
             return stampArgs;
             return stampArgs;
         }
         }
 
 
 
 
-        private void AddToPropertyPanel(AnnotHandlerEventArgs annot, string toolTag, string viewContent)
+        private void AddToPropertyPanel(AnnotHandlerEventArgs annot, string toolTag, string viewContent, Dictionary<AnnotAttrib, object> annotAttribsList)
         {
         {
             if (string.IsNullOrEmpty(toolTag) == false)
             if (string.IsNullOrEmpty(toolTag) == false)
             {
             {
@@ -503,6 +503,9 @@ namespace PDF_Office.ViewModels.Tools
             if (annot != null)
             if (annot != null)
                 propertyPanel.annot = annot;
                 propertyPanel.annot = annot;
 
 
+            if (annotAttribsList != null)
+                propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
+
             if (string.IsNullOrEmpty(viewContent) == false)
             if (string.IsNullOrEmpty(viewContent) == false)
             {
             {
                 viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
                 viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);

+ 1 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -17,6 +17,7 @@ namespace PDF_Office.ViewModels.Tools
     /// </summary>
     /// </summary>
     public class AnnotPropertyPanel
     public class AnnotPropertyPanel
     {
     {
+        public AnnotAttribEvent AnnotEvent { get; set; }
         public AnnotHandlerEventArgs annot;
         public AnnotHandlerEventArgs annot;
         public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
         public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
         public event EventHandler<object> DefaultStored;
         public event EventHandler<object> DefaultStored;

File diff suppressed because it is too large
+ 9 - 2
PDF Office/Views/PropertyPanel/AnnotPanel/CommonControls/SlidContent.xaml


+ 1 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml

@@ -94,7 +94,7 @@
             
             
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
                 <Grid>
                 <Grid>
-                    <Path Name="FreehandPath" Fill="Red"
+                    <Path Name="FreehandPath" Fill="{Binding SelectColor}" Stroke="{Binding SelectColor}" StrokeThickness="{Binding ThicknessLine}"
                   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,
                   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,
                   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,
                   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,

+ 0 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/FreehandAnnotProperty.xaml.cs

@@ -34,7 +34,6 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             if (data != null)
             if (data != null)
             {
             {
                 data.SelectedValueChangedCommand?.Execute(e);
                 data.SelectedValueChangedCommand?.Execute(e);
-                // data.SelectColor = e;
             }
             }
         }
         }
 
 

+ 8 - 8
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -8,7 +8,7 @@
              xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
              xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
              xmlns:cus="clr-namespace:PDF_Office.CustomControl"
              xmlns:cus="clr-namespace:PDF_Office.CustomControl"
              mc:Ignorable="d" 
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+             d:DesignHeight="850" d:DesignWidth="800">
     <UserControl.Resources>
     <UserControl.Resources>
         <ResourceDictionary>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary.MergedDictionaries>
@@ -56,11 +56,11 @@
     </UserControl.Resources>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
     <Grid Background="#F3F3F3">
         <StackPanel>
         <StackPanel>
-            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="18" LineHeight="24" HorizontalAlignment="Center" Margin="0,8,0,0">Freetext</TextBlock>
+            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="10,8,0,0">Freetext</TextBlock>
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
                 <Grid>
                 <Grid>
                     <Border Name="FreeTextBorder" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="5">
                     <Border Name="FreeTextBorder" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="5">
-                        <TextBlock Name="SampleText" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="SemiBold" FontFamily="Segoe UI Semibold" FontSize="24">
+                        <TextBlock Name="SampleText" Foreground="{Binding SelectColor}" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="SemiBold" FontFamily="Segoe UI Semibold" FontSize="24">
                         </TextBlock>
                         </TextBlock>
                     </Border>
                     </Border>
 
 
@@ -160,12 +160,12 @@
                     </Grid>
                     </Grid>
                 </Border>
                 </Border>
 
 
-                <cus:ColorDropBox x:Name="FontColorBox" Grid.Column="1" Grid.Row="1" BorderThickness="1" BorderBrush="#E2E3E6" Width="80" Height="32" HorizontalAlignment="Left"
+                <cus:ColorDropBox x:Name="FontColorBox" Grid.Column="1" Grid.Row="1" SelectedColorChanged="FontColorBox_SelectedColorChanged" BorderThickness="1" BorderBrush="#E2E3E6" Width="80" Height="32" HorizontalAlignment="Left"
                                    ></cus:ColorDropBox>
                                    ></cus:ColorDropBox>
 
 
                 <Border Grid.Row="1" BorderBrush="#E2E3E6"  Width="148" Height="32" Margin="12,8,4,0"  BorderThickness="0">
                 <Border Grid.Row="1" BorderBrush="#E2E3E6"  Width="148" Height="32" Margin="12,8,4,0"  BorderThickness="0">
                     <Grid>
                     <Grid>
-                        <ComboBox Name="FontStyleBox" IsReadOnly="True" BorderThickness="1" BorderBrush="#FFE2E3E6" Padding="10 10 0 0" Background="Transparent" >
+                        <ComboBox Name="FontStyleBox" IsReadOnly="True" BorderThickness="1" BorderBrush="#FFE2E3E6" Padding="10 10 0 0" Background="Transparent">
                             <ComboBox.ItemContainerStyle>
                             <ComboBox.ItemContainerStyle>
                                 <Style TargetType="{x:Type ComboBoxItem}">
                                 <Style TargetType="{x:Type ComboBoxItem}">
                                     <Setter Property="Padding" Value="10 0 0 0"/>
                                     <Setter Property="Padding" Value="10 0 0 0"/>
@@ -301,14 +301,14 @@
             </Grid>
             </Grid>
 
 
 
 
-            <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
-                <cus:CustomIconToggleBtn x:Name="BtnListMode" Tag="Line" Width="110" Height="32"
+            <StackPanel x:Name="PnlLineStyle" Orientation="Horizontal" Margin="0,20,0,0">
+                <cus:CustomIconToggleBtn x:Name="BtnSolidLine" Tag="Solid" Width="110" Height="32" Click="BtnLineStyle_Click"
                                               Style="{StaticResource ToggleBtnViewModeStyle}">
                                               Style="{StaticResource ToggleBtnViewModeStyle}">
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30">
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30">
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" />
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" />
                     </Border>
                     </Border>
                 </cus:CustomIconToggleBtn>
                 </cus:CustomIconToggleBtn>
-                <cus:CustomIconToggleBtn x:Name="BtnListMode1" Tag="Line" Width="110" Height="32"
+                <cus:CustomIconToggleBtn x:Name="BtnDottedLine" Tag="Dotted" Width="110" Height="32" Click="BtnLineStyle_Click"
                                               Style="{StaticResource ToggleBtnViewModeStyle}">
                                               Style="{StaticResource ToggleBtnViewModeStyle}">
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30" >
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30" >
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" StrokeDashArray="2"/>
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" StrokeDashArray="2"/>

+ 85 - 1
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

@@ -1,4 +1,6 @@
-using System;
+using PDF_Office.CustomControl;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
@@ -25,9 +27,61 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         public FreetextAnnotProperty()
         public FreetextAnnotProperty()
         {
         {
             InitializeComponent();
             InitializeComponent();
+            FontFamilyBox.SelectionChanged += FontFamilyBox_SelectionChanged;
+            FontStyleBox.SelectionChanged += FontStyleBox_SelectionChanged;
+            FontSizeBox.SelectionChanged += FontSizeBox_SelectionChanged;
+            ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged;
+            this.Loaded += usercontrol_Loaded;
+            cusColor.SelectedColorHandler += cusColor_SelectedColorHandler;
+        }
+
+        private void usercontrol_Loaded(object sender, RoutedEventArgs e)
+        {
+            FontFamilyBox.SelectedIndex = 0;
+            FontStyleBox.SelectedIndex = 0;
+            FontSizeBox.SelectedIndex = 0;
+            ThicknessBox.SelectedIndex = 0;
+        }
+
+        private void ThicknessBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listItem = ThicknessBox.ItemContainerGenerator.ContainerFromItem(ThicknessBox.SelectedItem) as ComboBoxItem;
+            if (listItem != null)
+                ThicknessText.Text = listItem.Content.ToString();
+            else
+                ThicknessText.Text = "1";
+           
+        }
+
+        private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listItem = FontSizeBox.ItemContainerGenerator.ContainerFromItem(FontSizeBox.SelectedItem) as ComboBoxItem;
+            if (listItem != null)
+                FontSizeText.Text = listItem.Content.ToString();
+            else
+                FontSizeText.Text = "6";
+           
+        }
+
+        private void FontStyleBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listItem = FontStyleBox.ItemContainerGenerator.ContainerFromItem(FontStyleBox.SelectedItem) as ComboBoxItem;
+            if (listItem != null)
+                FontStyleText.Text = listItem.Content.ToString();
+            else
+                FontStyleText.Text = "Regular";
           
           
         }
         }
 
 
+        private void FontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var listItem = FontFamilyBox.ItemContainerGenerator.ContainerFromItem(FontFamilyBox.SelectedItem) as ComboBoxItem;
+            if (listItem != null)
+                FontFamilyText.Text = (listItem.Content as TextBlock).Text;
+            else
+                FontFamilyText.Text = "Courier New";
+        }
+
         private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
         private void BtnTextAlign_Click(object sender, RoutedEventArgs e)
         {
         {
 
 
@@ -45,5 +99,35 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             }
             }
            
            
         }
         }
+
+        private void BtnLineStyle_Click(object sender, RoutedEventArgs e)
+        {
+            var btn = sender as CustomIconToggleBtn;
+            foreach (var item in PnlLineStyle.Children)
+            {
+                var btnItem = item as CustomIconToggleBtn;
+                if (btnItem != null)
+                {
+                    if (btn != btnItem)
+                        btnItem.IsChecked = false;
+                    else
+                        btnItem.IsChecked = true;
+                }
+            }
+        }
+
+        private void FontColorBox_SelectedColorChanged(object sender, Color? e)
+        {
+            var data = this.DataContext as FreetextAnnotPropertyViewModel;
+            data.SelectedColorCommand?.Execute(e);
+        }
+
+        private void cusColor_SelectedColorHandler(object sender, Color e)
+        {
+            var data = this.DataContext as FreetextAnnotPropertyViewModel;
+            data.SelectedFillColorCommand?.Execute(e);
+        }
+
+
     }
     }
 }
 }

+ 16 - 73
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -17,10 +17,7 @@
             </ResourceDictionary.MergedDictionaries>
             </ResourceDictionary.MergedDictionaries>
             <Convert:ColorToBrushConverter x:Key="ColorToBrushConvert"></Convert:ColorToBrushConverter>
             <Convert:ColorToBrushConverter x:Key="ColorToBrushConvert"></Convert:ColorToBrushConverter>
             <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert"/>
             <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert"/>
-            <DataTemplate x:Key="listboxData">
-                <Ellipse Height="20" Width="20" Fill="{Binding}"/>
-            </DataTemplate>
-
+         
             <Style x:Key="line1Style" TargetType="{x:Type Line}">
             <Style x:Key="line1Style" TargetType="{x:Type Line}">
                 <Setter Property="Visibility">
                 <Setter Property="Visibility">
                     <Setter.Value>
                     <Setter.Value>
@@ -52,34 +49,11 @@
                 </Setter>
                 </Setter>
             </Style>
             </Style>
 
 
-
-
-
-            <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>
         </ResourceDictionary>
     </UserControl.Resources>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
     <Grid Background="#F3F3F3">
         <StackPanel>
         <StackPanel>
-            <TextBlock Name="AnnotTypeTitle" FontFamily="SegoeUI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Center" Margin="0,8,0,0">Freehand</TextBlock>
+            <TextBlock Name="AnnotTypeTitle" Text="{Binding AnnotTypeTitle}" FontFamily="SegoeUI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="10,8,0,0" />
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
                 <Grid>
                 <Grid>
                     <!--<Path Name="SharpPath" Opacity="{Binding ElementName=OpacitySlider,Path=Value}" StrokeThickness="{Binding ElementName=ThicknessSlider,Path=Value}" 
                     <!--<Path Name="SharpPath" Opacity="{Binding ElementName=OpacitySlider,Path=Value}" StrokeThickness="{Binding ElementName=ThicknessSlider,Path=Value}" 
@@ -101,7 +75,7 @@
                     </Grid.ColumnDefinitions>
                     </Grid.ColumnDefinitions>
 
 
 
 
-                    <ToggleButton Name="SharpRectBtn" Tag="Rect" Width="40.5" Background="Transparent" BorderThickness="0">
+                    <ToggleButton Name="SharpRectBtn" Tag="Rect" Width="40.5" Background="Transparent" BorderThickness="0" Click="SharpsBtn_Click">
                         <Rectangle HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" Stroke="#273C62"></Rectangle>
                         <Rectangle HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" Stroke="#273C62"></Rectangle>
                     </ToggleButton>
                     </ToggleButton>
 
 
@@ -109,13 +83,13 @@
 
 
                     </Line>
                     </Line>
 
 
-                    <ToggleButton Name="SharpCircleBtn" Width="40.5" Tag="Circle" Grid.Column="1" Background="Transparent"  BorderThickness="0"  Margin="0,0,0,0">
+                    <ToggleButton Name="SharpCircleBtn" Width="40.5" Tag="Circle" Grid.Column="1" Background="Transparent"  BorderThickness="0"  Margin="0,0,0,0" Click="SharpsBtn_Click">
                         <Ellipse Width="16" Height="16" Stroke="#273C62" HorizontalAlignment="Center" VerticalAlignment="Center"  ></Ellipse>
                         <Ellipse Width="16" Height="16" Stroke="#273C62" HorizontalAlignment="Center" VerticalAlignment="Center"  ></Ellipse>
                     </ToggleButton>
                     </ToggleButton>
 
 
 
 
                     <Line Name="line2" HorizontalAlignment="Left" Style="{StaticResource line2Style}" VerticalAlignment="Center" Grid.Column="2" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
                     <Line Name="line2" 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="SharpArrowBtn" Width="40.5" Tag="Arrow" Grid.Column="2" Background="Transparent"  BorderThickness="0" >
+                    <ToggleButton Name="SharpArrowBtn" Width="40.5" Tag="Arrow" Grid.Column="2" Background="Transparent"  BorderThickness="0" Click="SharpsBtn_Click">
                         <Path HorizontalAlignment="Center" VerticalAlignment="Center"  Fill="#273C62" Width="16" Height="16">
                         <Path HorizontalAlignment="Center" VerticalAlignment="Center"  Fill="#273C62" Width="16" Height="16">
                             <Path.Data>
                             <Path.Data>
                                 M13.4,2.6 L13.4,8 L12.2,8 L12.1997359,4.648 L2.02426407,14.8242641 L1.17573593,13.9757359 L11.3517359,3.799 L8,3.8 L8,2.6 L13.4,2.6 Z
                                 M13.4,2.6 L13.4,8 L12.2,8 L12.1997359,4.648 L2.02426407,14.8242641 L1.17573593,13.9757359 L11.3517359,3.799 L8,3.8 L8,2.6 L13.4,2.6 Z
@@ -124,7 +98,7 @@
                     </ToggleButton>
                     </ToggleButton>
 
 
                     <Line x:Name="line3" HorizontalAlignment="Left" Style="{StaticResource line3Style}" VerticalAlignment="Center" Grid.Column="3" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
                     <Line x:Name="line3" HorizontalAlignment="Left" Style="{StaticResource line3Style}" VerticalAlignment="Center" Grid.Column="3" X1="0" Y1="0" X2="0" Y2="16" StrokeThickness="1" Stroke="#33000000"></Line>
-                    <ToggleButton Name="SharpLineBtn" Width="40.5" Tag="Line" Grid.Column="3" Background="Transparent"  BorderThickness="0">
+                    <ToggleButton Name="SharpLineBtn" Width="40.5" Tag="Line" Grid.Column="3" Background="Transparent"  BorderThickness="0" Click="SharpsBtn_Click">
                         <Polygon Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#273C62">
                         <Polygon Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="#273C62">
                             <Polygon.Points>
                             <Polygon.Points>
                                 13.1757359 1.97573593 14.0242641 2.82426407 2.82426407 14.0242641 1.97573593 13.1757359
                                 13.1757359 1.97573593 14.0242641 2.82426407 2.82426407 14.0242641 1.97573593 13.1757359
@@ -136,30 +110,13 @@
             </Border>
             </Border>
 
 
 
 
-            <Grid Margin="0,18,0,0">
+            <Grid Margin="0,18,0,0" x:Name="GridFill">
                 <Grid.RowDefinitions>
                 <Grid.RowDefinitions>
                     <RowDefinition Height="auto"/>
                     <RowDefinition Height="auto"/>
                     <RowDefinition/>
                     <RowDefinition/>
                 </Grid.RowDefinitions>
                 </Grid.RowDefinitions>
                 <CommonControls:SlidContent x:Name="layerFill" HorizontalAlignment="Right"/>
                 <CommonControls:SlidContent x:Name="layerFill" HorizontalAlignment="Right"/>
-                <Grid Grid.Row="1">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="*"></ColumnDefinition>
-                        <ColumnDefinition Width="auto"></ColumnDefinition>
-                    </Grid.ColumnDefinitions>
-                    <cus:ColorDropBox x:Name="ColorFillDropPicker"  Grid.Column="1" BorderThickness="1"  HorizontalAlignment="Right"
-                                BorderBrush="#E2E3E6" Width="80" Height="32">
-                    </cus:ColorDropBox>
-                    <ListBox x:Name="ListColorFill" 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="cusFillColor"/>
             </Grid>
             </Grid>
 
 
             <Grid Margin="0,18,0,0">
             <Grid Margin="0,18,0,0">
@@ -168,23 +125,7 @@
                     <RowDefinition/>
                     <RowDefinition/>
                 </Grid.RowDefinitions>
                 </Grid.RowDefinitions>
                 <CommonControls:SlidContent x:Name="layerThick" HorizontalAlignment="Right"/>
                 <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>
             </Grid>
 
 
@@ -195,7 +136,7 @@
                     <ColumnDefinition Width="*"></ColumnDefinition>
                     <ColumnDefinition Width="*"></ColumnDefinition>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                 </Grid.ColumnDefinitions>
                 </Grid.ColumnDefinitions>
-                <Slider Name="BorderSlider" VerticalAlignment="Center" Margin="12,0,4,0"  Minimum="1" Maximum="12" IsSelectionRangeEnabled="True" IsMoveToPointEnabled="True"
+                <Slider Name="BorderSlider" VerticalAlignment="Center" Value="{Binding LineWidth}" 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" >
                     <Slider.Resources>
                     <Slider.Resources>
                         <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
                         <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
@@ -225,15 +166,17 @@
             </Grid>
             </Grid>
 
 
 
 
-            <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
-                <cus:CustomIconToggleBtn x:Name="BtnListMode" Tag="Line" Width="110" Height="32"
+            <StackPanel x:Name="PnlLineStyle" Orientation="Horizontal" Margin="0,20,0,0">
+                <cus:CustomIconToggleBtn x:Name="BtnSolidLine" Tag="Solid" Width="110" Height="32" Click="BtnLineStyle_Click"
+                                         Command="{Binding LineStyleCommand}" CommandParameter="{Binding ElementName=BtnSolidLine,Path=Tag}"
                                               Style="{StaticResource ToggleBtnViewModeStyle}">
                                               Style="{StaticResource ToggleBtnViewModeStyle}">
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30">
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30">
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" />
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" />
                     </Border>
                     </Border>
                 </cus:CustomIconToggleBtn>
                 </cus:CustomIconToggleBtn>
-                <cus:CustomIconToggleBtn x:Name="BtnListMode1" Tag="Line" Width="110" Height="32"
-                                              Style="{StaticResource ToggleBtnViewModeStyle}">
+                <cus:CustomIconToggleBtn x:Name="BtnDottedLine" Tag="Dotted" Width="110" Height="32"
+                                         Command="{Binding LineStyleCommand}" CommandParameter="{Binding ElementName=BtnDottedLine,Path=Tag}"
+                                              Style="{StaticResource ToggleBtnViewModeStyle}" Click="BtnLineStyle_Click">
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30" >
                     <Border BorderBrush="Black" BorderThickness="1" Padding="8,0,8,0" Width="108" Height="30" >
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" StrokeDashArray="2"/>
                         <Line X1="10" Y1="15" X2="260" Y2="15" Stroke="Black" StrokeThickness="2" StrokeDashArray="2"/>
                     </Border>
                     </Border>

+ 89 - 15
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml.cs

@@ -1,10 +1,13 @@
-using System;
+using PDF_Office.CustomControl;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using System.Windows.Data;
 using System.Windows.Documents;
 using System.Windows.Documents;
 using System.Windows.Input;
 using System.Windows.Input;
@@ -20,28 +23,99 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
     /// </summary>
     /// </summary>
     public partial class SharpsAnnotProperty : UserControl
     public partial class SharpsAnnotProperty : UserControl
     {
     {
-        private List<string> colors = new List<string>();
-        private List<string> colorFills = new List<string>();
         public SharpsAnnotProperty()
         public SharpsAnnotProperty()
         {
         {
             InitializeComponent();
             InitializeComponent();
-            colors.Add("#FFFF10");
-            colors.Add("#FF1010");
-            colors.Add("#10FF10");
-            colors.Add("#1070FF");
-            ListColor.ItemsSource = colors;
-
-            colorFills.Add("#FFFF10");
-            colorFills.Add("#FF1010");
-            colorFills.Add("#10FF10");
-            colorFills.Add("#1070FF");
-            ListColorFill.ItemsSource = colorFills;
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+            layerThick.SelectedValueChanged += layerThick_SelectedValue;
 
 
+            cusFillColor.SelectedColorHandler += cusFillColor_SelectedColor;
+            layerFill.SelectedValueChanged += layerFill_SelectedValue;
         }
         }
 
 
-        private void ChangeColorMenuItem_Click(object sender, RoutedEventArgs e)
+        private void layerFill_SelectedValue(object sender, double e)
         {
         {
+            var data = this.DataContext as SharpsAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedFillOpacityCommand?.Execute(e);
+            }
+        }
+
+        private void cusFillColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as SharpsAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedFillColorCommand?.Execute(e);
+            }
+        }
+
+        private void layerThick_SelectedValue(object sender, double e)
+        {
+            var data = this.DataContext as SharpsAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedThickCommand?.Execute(e);
+            }
+        }
 
 
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            var data = this.DataContext as SharpsAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedColorCommand?.Execute(e);
+            }
+        }
+
+        private void SharpsBtn_Click(object sender, RoutedEventArgs e)
+        {
+            var btn = sender as ToggleButton;
+           foreach(var item in ToolGrid.Children)
+            {
+                var btnItem = item as ToggleButton;
+                if(btnItem != null)
+                {
+                    if(btnItem != btn)
+                    {
+                        btnItem.IsChecked = false;
+                    }
+                    else
+                    {
+                        btnItem.IsChecked = true;
+                        if(btnItem.Tag.ToString() == "Arrow" || btnItem.Tag.ToString() == "Line")
+                        {
+                            GridFill.Visibility = Visibility.Collapsed;
+                        }
+                        else
+                        {
+                            GridFill.Visibility = Visibility.Visible;
+                        }
+                    }
+                }
+            }
+        }
+
+        private void BtnLineStyle_Click(object sender, RoutedEventArgs e)
+        {
+            var btn = sender as CustomIconToggleBtn;
+            foreach (var item in PnlLineStyle.Children)
+            {
+                var btnItem = item as CustomIconToggleBtn;
+                if (btnItem != null)
+                {
+                    if (btnItem != btn)
+                    {
+                        btnItem.IsChecked = false;
+                    }
+                    else
+                    {
+                        btnItem.IsChecked = true;
+                        
+                    }
+                }
+            }
         }
         }
     }
     }
 }
 }

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

@@ -38,12 +38,11 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             if (data != null)
             if (data != null)
             {
             {
                 data.SelectedValueChangedCommand?.Execute(e);
                 data.SelectedValueChangedCommand?.Execute(e);
-                // data.SelectColor = e;
             }
             }
         }
         }
 
 
         private void cusColor_SelectedColor(object sender, Color e)
         private void cusColor_SelectedColor(object sender, Color e)
-        {
+        { 
             var data = this.DataContext as TextAnnotPropertyViewModel;
             var data = this.DataContext as TextAnnotPropertyViewModel;
             if (data != null)
             if (data != null)
             {
             {