Browse Source

注释 - 外部UI属性更改

chenrongqian@kdanmobile.com 2 years ago
parent
commit
5c19962b28

+ 8 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/AnnotBasePropertyVM.cs

@@ -121,6 +121,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         {
             strDashStyle = str;
         }
+
+        //外部UI引用,其他:例如形状注释类型
+        public string strOtherTag { get; private set; }
+        //VM赋值
+        public void SetOtherTag(string str)
+        {
+            strOtherTag = str;
+        }
         #endregion
 
         #region 多选

+ 112 - 27
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -1,8 +1,10 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
 using PDF_Office.ViewModels.Tools;
+using PDFSettings;
 using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -172,8 +174,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 BasicVm.FillOpacity = (double)obj;
                 BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
 
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
-                AnnotEvent?.UpdateAnnot();
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
                 PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, BasicVm.FillOpacity);
             }
         }
@@ -221,34 +222,130 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot;
-                if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
+                BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
+
+                if (BasicVm.IsMultiSelected)
                 {
-                    BasicVm.IsMultiSelected = true;
+                    IsAttributeEquals();
+
+                    BasicVm.SetStrDashStyle("None");
                 }
                 else
                 {
-                    BasicVm.IsMultiSelected = false;
+                    GetAnnotProperty();
+                }
+                   
+            }
+        }
+
+        private List<FreehandAnnotArgs> ConvertLists()
+        {
+            List<FreehandAnnotArgs> Lists = new List<FreehandAnnotArgs>();
+            foreach (var item in PropertyPanel.annotlists)
+            {
+                var selecteditem = item as FreehandAnnotArgs;
+                if (selecteditem != null)
+                {
+                    Lists.Add(selecteditem);
                 }
+            }
 
-                if (BasicVm.IsMultiSelected)
+            if (Lists.Count != PropertyPanel.annotlists.Count)
+                return null;
+            else
+                return Lists;
+        }
+        private void IsAttributeEquals()
+        {
+            var list = ConvertLists();
+            if (list != null)
+            {
+                var temp = list[0];
+                Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
+                isNoEqualsDir.Add("Color", false);
+                isNoEqualsDir.Add("Thickness", false);
+                isNoEqualsDir.Add("FontStyleFontWeight", false);
+                isNoEqualsDir.Add("ThickSolidDashStyle", false);
+
+                foreach (var item in list)
                 {
-                    double thickness = 0;
-                    foreach(var item in PropertyPanel.annotlists)
+                    if (item == list[0])
+                        continue;
+
+                    if (isNoEqualsDir["Color"] == false)
                     {
-                        if ((item as FreehandAnnotArgs).LineWidth >= thickness)
-                            thickness = (item as FreehandAnnotArgs).LineWidth;
+                        if (temp.InkColor.A != item.InkColor.A || temp.InkColor.R != item.InkColor.R || temp.InkColor.G != item.InkColor.G || temp.InkColor.B != item.InkColor.B)
+                        {
+                            BasicVm.FontColor = new SolidColorBrush(Colors.Transparent);
+                            isNoEqualsDir["Color"] = true;
+                        }
                     }
 
-                    BasicVm.AnnotThickness = thickness;
-                    BasicVm.SetStrDashStyle("None");
+
+                    if (isNoEqualsDir["Thickness"] == false)
+                    {
+                        isNoEqualsDir["Thickness"] = true;
+                        if (temp.LineWidth > item.LineWidth)
+                        {
+                            BasicVm.AnnotThickness = temp.LineWidth;
+                        }
+                        else
+                        {
+                            BasicVm.AnnotThickness = item.LineWidth;
+                        }
+                    }
+
+
+                    if(isNoEqualsDir["ThickSolidDashStyle"] == false)
+                    {
+                        if(isSolidStyle(temp) != isSolidStyle(item))
+                        {
+                            isNoEqualsDir["ThickSolidDashStyle"] = true;
+                        }
+                    }
+
+                }
+
+                if (isNoEqualsDir["Color"] == false)
+                {
+                    BasicVm.FontColor = new SolidColorBrush(temp.InkColor);
+                }
+
+                if (isNoEqualsDir["Thickness"] == false)
+                {
+                    BasicVm.AnnotThickness = temp.LineWidth;
+                }
+
+                if(isNoEqualsDir["ThickSolidDashStyle"] == true)
+                {
+                    var isSolid = isSolidStyle(temp);
+                    BasicVm.SetStrDashStyle(isSolid ? "Solid" : "Dash");
                 }
                 else
                 {
-                    GetAnnotProperty();
+                    BasicVm.SetStrDashStyle("None");
                 }
-                   
             }
         }
+        //外部UI控件选中状态
+        private bool isSolidStyle(FreehandAnnotArgs annot)
+        {
+            bool isSolid = true;
+            if (annot.LineDash != null && annot.LineDash.Dashes.Count > 0)
+            {
+                foreach (var item in annot.LineDash.Dashes)
+                {
+                    if (item > 0)
+                    {
+                      
+                        isSolid = false;
+                        break;
+                    }
+                }
+            }
+            return isSolid;
+            
+        }
 
         private void GetAnnotProperty()
         {
@@ -261,19 +358,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     BasicVm.FontColor = new SolidColorBrush(annot.InkColor);
                     BasicVm.AnnotThickness = annot.LineWidth;
                     BasicVm.Dash = annot.LineDash;
-                    bool isSolid = true;
-                    if(annot.LineDash != null && annot.LineDash.Dashes.Count > 0)
-                    {
-                        foreach(var item in annot.LineDash.Dashes)
-                        {
-                            if(item > 0)
-                            {
-                                isSolid = false;
-                                break;
-                            }
-                        }
-                    }
-                    
+                    var isSolid = isSolidStyle(annot);
                     BasicVm.SetStrDashStyle(isSolid ? "Solid" : "Dash");
                     IsPen = true;
                 }

+ 110 - 52
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -191,9 +191,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 BasicVm.FillOpacity = (double)obj;
                 BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
-
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
-                AnnotEvent?.UpdateAnnot();
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
             }
         }
 
@@ -203,9 +201,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 BasicVm.FillOpacity = (double)obj;
                 BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
-
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
-                AnnotEvent?.UpdateAnnot();
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
             }
         }
         
@@ -249,8 +245,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 if (colorValue != null)
                 {
                     FontVm.FontColor = new SolidColorBrush(colorValue);
-                    AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, colorValue);
-                    AnnotEvent?.UpdateAnnot();
+                    PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontColor, colorValue);
                 }
             }
         }
@@ -343,65 +338,128 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 LoadPropertyHandler?.Invoke(this, Annot);
 
                 BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
+                if (BasicVm.IsMultiSelected)
+                {
+                    IsAttributeEquals();
+                    BasicVm.SetStrDashStyle("None");
+                }
+                else
+                {
+                    GetAnnotProperty();
+                }
+            }
+        }
+
+       
+        private List<FreeTextAnnotArgs> ConvertLists()
+        {
+            List<FreeTextAnnotArgs> FreeTextLists = new List<FreeTextAnnotArgs>();
+            foreach (var item in PropertyPanel.annotlists)
+            {
+                var itemFreeText = item as FreeTextAnnotArgs;
+                if (itemFreeText != null)
+                {
+                    FreeTextLists.Add(itemFreeText);
+                }
+            }
 
-                if(BasicVm.IsMultiSelected)
+            if (FreeTextLists.Count != PropertyPanel.annotlists.Count)
+                return null;
+            else
+                return FreeTextLists;
+        }
+        private void IsAttributeEquals()
+        {
+            var list = ConvertLists();
+            if (list != null)
+            {
+                var temp = list[0];
+                Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
+                isNoEqualsDir.Add("FontFamily", false);
+                isNoEqualsDir.Add("FontSize", false);
+                isNoEqualsDir.Add("FontStyleFontWeight", false);
+                isNoEqualsDir.Add("FontColor", false);
+                isNoEqualsDir.Add("FillColor", false);
+
+                foreach (var item in list)
                 {
-                    bool isDifferentFontFamily = false;
-                    bool isDifferentFontSize = false;
-                    bool isDifferentFontStyle = false;
+                    if (item == list[0])
+                        continue;
+
+                    if (temp.FontFamily != item.FontFamily)
+                    {
+                        isNoEqualsDir["FontFamily"] = true;
+                        FontVm.CurrentFontFamily = null;
+                    }
+
+                    if (temp.FontSize != item.FontSize)
+                    {
+                        isNoEqualsDir["FontSize"] = true;
+                        FontVm.CurrentFontSize = null;
+                    }
 
-                    FreeTextAnnotArgs tempAnnot = null;
-                    foreach (var item in PropertyPanel.annotlists)
+                    if (temp.FontStyle != item.FontStyle || temp.FontWeight != item.FontWeight)
                     {
-                       var itemFreeText = item as FreeTextAnnotArgs;
-                        if(itemFreeText != null)
+                        isNoEqualsDir["FontStyleFontWeight"] = true;
+                        FontVm.CurrrentFontWeightStyle = null;
+                    }
+
+                    if (isNoEqualsDir["FontFamily"] == true || isNoEqualsDir["FontSize"] == true || isNoEqualsDir["FontStyleFontWeight"] == true)
+                    {
+                        FontVm.CurrentPresetFont = null;
+                    }
+
+                    if (isNoEqualsDir["FontColor"] == false)
+                    {
+                        if (temp.FontColor.A != item.FontColor.A || temp.FontColor.R != item.FontColor.R || temp.FontColor.G != item.FontColor.G || temp.FontColor.B != item.FontColor.B)
                         {
-                            if (tempAnnot == null)
-                            {
-                                tempAnnot = itemFreeText;
-                            }
-                            else
-                            {
-
-                                if (itemFreeText.FontFamily != tempAnnot.FontFamily)
-                                {
-                                    isDifferentFontFamily = true;
-                                }
-
-                                if (itemFreeText.FontSize != tempAnnot.FontSize)
-                                {
-                                    isDifferentFontSize = true;
-                                }
-
-                                if (itemFreeText.FontStyle != tempAnnot.FontStyle || itemFreeText.FontWeight != tempAnnot.FontWeight)
-                                {
-                                    isDifferentFontStyle = true;
-                                }
-                                tempAnnot = itemFreeText;
-                            }
-                           
+                            FontVm.FontColor = new SolidColorBrush(Colors.Transparent);
+                            isNoEqualsDir["FontColor"] = true;
                         }
-                        
                     }
 
-                    if (isDifferentFontFamily || isDifferentFontSize || isDifferentFontStyle)
-                        FontVm.CurrentPresetFont = null;
+                    if (isNoEqualsDir["FillColor"] == false)
+                    {
+                        if (temp.BgColor.A != item.BgColor.A || temp.BgColor.R != item.BgColor.R || temp.BgColor.G != item.BgColor.G || temp.BgColor.B != item.BgColor.B)
+                        {
+                            BasicVm.FillColor = new SolidColorBrush(Colors.Transparent);
+                            isNoEqualsDir["FillColor"] = true;
+                        }
+                    }
 
-                    if(isDifferentFontFamily)
-                    FontVm.CurrentFontFamily = null;
 
-                    if (isDifferentFontSize)
-                        FontVm.CurrentFontSize = null;
+                }
 
-                    if (isDifferentFontStyle)
-                        FontVm.CurrrentFontWeightStyle = null;
+                ////以下是多选注释的属性相等时
+
+                if (isNoEqualsDir["FontFamily"] == false)
+                {
+                    FontVm.GetCurrentFontFamily(temp.FontFamily.ToString(), temp.FontFamily.ToString());
 
-                    BasicVm.SetStrDashStyle("None");
                 }
-                else
+
+                if (isNoEqualsDir["FontSize"] == false)
                 {
-                    GetAnnotProperty();
+                    FontVm.GetCurrentFontSize((int)temp.FontSize);
                 }
+
+                if (isNoEqualsDir["FontStyleFontWeight"] == false)
+                {
+                    FontVm.GetFontWeights_Style(temp.FontStyle, temp.FontWeight);
+                }
+               
+                if (isNoEqualsDir["FontColor"] == false)
+                {
+                    FontVm.FontColor = new SolidColorBrush(temp.FontColor);
+
+                }
+
+                if (isNoEqualsDir["FillColor"] == false)
+                {
+                    FontVm.FontColor = new SolidColorBrush(temp.BgColor);
+
+                }
+
             }
         }
 

+ 134 - 38
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -205,6 +205,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if (isFromToolsBtn == false)
                 PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
 
+            BasicVm.SetOtherTag(tag);
         }
 
         private void LineStyle_Command(object obj)
@@ -353,7 +354,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
                 if(BasicVm.IsMultiSelected)
                 {
-
+                    IsAttributeEquals();
                 }
                 else
                 {
@@ -365,6 +366,136 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         }
 
+        private List<SquareAnnotArgs> ConvertLists()
+        {
+            List<SquareAnnotArgs> FreeTextLists = new List<SquareAnnotArgs>();
+            foreach (var item in PropertyPanel.annotlists)
+            {
+                var itemFreeText = item as SquareAnnotArgs;
+                if (itemFreeText != null)
+                {
+                    FreeTextLists.Add(itemFreeText);
+                }
+            }
+
+            if (FreeTextLists.Count != PropertyPanel.annotlists.Count)
+                return null;
+            else
+                return FreeTextLists;
+        }
+        private void IsAttributeEquals()
+        {
+            var list = ConvertLists();
+            if (list != null)
+            {
+                var temp = list[0];
+                Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
+                isNoEqualsDir.Add("FillColor", false);
+                isNoEqualsDir.Add("LineColor", false);
+                isNoEqualsDir.Add("Thickness", false);
+                isNoEqualsDir.Add("ThickSolidDashStyle", false);
+
+                foreach (var item in list)
+                {
+                    if (item == list[0])
+                        continue;
+
+                    if (isNoEqualsDir["FillColor"] == false)
+                    {
+                        if (temp.BgColor.A != item.BgColor.A || temp.BgColor.R != item.BgColor.R || temp.BgColor.G != item.BgColor.G || temp.BgColor.B != item.BgColor.B)
+                        {
+                            BasicVm.FillColor = new SolidColorBrush(Colors.Transparent);
+                            isNoEqualsDir["FillColor"] = true;
+                        }
+                    }
+
+                    if (isNoEqualsDir["LineColor"] == false)
+                    {
+                        if (temp.LineColor.A != item.LineColor.A || temp.LineColor.R != item.LineColor.R || temp.LineColor.G != item.LineColor.G || temp.LineColor.B != item.LineColor.B)
+                        {
+                            BasicVm.BorderColor = new SolidColorBrush(Colors.Transparent);
+                            isNoEqualsDir["LineColor"] = true;
+                        }
+                    }
+
+
+                    if (isNoEqualsDir["Thickness"] == false)
+                    {
+                        isNoEqualsDir["Thickness"] = true;
+                        if (temp.LineWidth > item.LineWidth)
+                        {
+                            BasicVm.AnnotThickness = temp.LineWidth;
+                        }
+                        else
+                        {
+                            BasicVm.AnnotThickness = item.LineWidth;
+                        }
+                    }
+
+                    if (isNoEqualsDir["ThickSolidDashStyle"] == false)
+                    {
+                        if (IsSolidStyle(temp) != IsSolidStyle(item))
+                        {
+                            isNoEqualsDir["ThickSolidDashStyle"] = true;
+                        }
+                    }
+                }
+
+                ////以下是多选注释的属性相等时
+                if (isNoEqualsDir["FillColor"] == false)
+                {
+                    BasicVm.FillColor = new SolidColorBrush(temp.BgColor);
+
+                }
+
+                if (isNoEqualsDir["LineColor"] == false)
+                {
+                    BasicVm.BorderColor = new SolidColorBrush(temp.LineColor);
+
+                }
+
+                if (isNoEqualsDir["Thickness"] == false)
+                {
+                    BasicVm.AnnotThickness = temp.LineWidth;
+                }
+
+                if (isNoEqualsDir["ThickSolidDashStyle"] == true)
+                {
+                    var isSolid = IsSolidStyle(temp);
+                    BasicVm.SetStrDashStyle(isSolid ? "Solid" : "Dash");
+                }
+                else
+                {
+                    BasicVm.SetStrDashStyle("None");
+                }
+
+
+            }
+        }
+
+
+        private bool IsSolidStyle(AnnotHandlerEventArgs annot)
+        {
+            bool isSolid = true;
+            if (annot is SquareAnnotArgs)
+            {
+                var Square = Annot as SquareAnnotArgs;
+                isSolid = PropertyPanel.IsSolidStyle(Square.LineDash);
+            }
+            else if(annot is CircleAnnotArgs)
+            {
+                var Circle = Annot as CircleAnnotArgs;
+                isSolid = PropertyPanel.IsSolidStyle(Circle.LineDash);
+            }
+            else if(annot is LineAnnotArgs)
+            {
+                var line = Annot as LineAnnotArgs;
+                isSolid = PropertyPanel.IsSolidStyle(line.LineDash);
+            }
+
+            return isSolid;
+        }
+
         private void GetAnnotProperty()
         {
             if (Annot != null)
@@ -383,20 +514,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             BasicVm.AnnotThickness = Square.LineWidth;
                             Dash = Square.LineDash;
                             SharpsType("Rect",true);
-                           
-                            if (Square.LineDash != null && Square.LineDash.Dashes.Count > 0)
-                            {
-                                foreach (var item in Square.LineDash.Dashes)
-                                {
-                                    if (item > 0)
-                                    {
-                                        isSolid = false;
-                                        break;
-                                    }
-                                }
-                            }
-
-                           
                         }
                         break;
 
@@ -412,18 +529,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             Dash = Circle.LineDash;
                             SharpsType("Circle", true);
 
-                            if (Circle.LineDash != null && Circle.LineDash.Dashes.Count > 0)
-                            {
-                                foreach (var item in Circle.LineDash.Dashes)
-                                {
-                                    if (item > 0)
-                                    {
-                                        isSolid = false;
-                                        break;
-                                    }
-                                }
-                            }
-
                         }
                         break;
 
@@ -443,22 +548,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             else
                                 SharpsType("Line", true);
 
-                            if (line.LineDash != null && line.LineDash.Dashes.Count > 0)
-                            {
-                                foreach (var item in line.LineDash.Dashes)
-                                {
-                                    if (item > 0)
-                                    {
-                                        isSolid = false;
-                                        break;
-                                    }
-                                }
-                            }
+                           
                         }
 
                         break;
                 }
 
+                isSolid = IsSolidStyle(Annot);
                 BasicVm.SetStrDashStyle(isSolid ? "Solid" : "Dash");
 
             }

+ 93 - 17
PDF Office/ViewModels/PropertyPanel/AnnotPanel/StickyNotePropertyViewModel.cs

@@ -16,7 +16,10 @@ using System.Windows.Media;
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
     public class StickyNotePropertyViewModel : BindableBase, INavigationAware
-    {
+    { 
+        //外部UI引用
+        public string strOtherTag { get; private set; }
+
         private double _transpent;
         public double Transpent
         {
@@ -35,7 +38,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public Brush SharpColor
         {
             get { return _sharpColor; }
-            set { SetProperty(ref _sharpColor, value); }
+            set { SetProperty(ref _sharpColor, value); SharpCurrentColor = _sharpColor; }
+        }
+
+        private Brush _sharpCurrentColor;
+        public Brush SharpCurrentColor
+        {
+            get { return _sharpCurrentColor; }
+            set { SetProperty(ref _sharpCurrentColor, value); }
         }
 
         private bool _isMultiSelected = false;
@@ -72,8 +82,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 double value = (double)obj;
                 Transpent = value;
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, value);
-                AnnotEvent?.UpdateAnnot();
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, value);
             }
         }
 
@@ -83,9 +92,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 var color = (Color)obj;
                 SharpColor =new SolidColorBrush(color);
-
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, color);
-                AnnotEvent?.UpdateAnnot();
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Color, color);
             }
         }
 
@@ -94,11 +101,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if (obj != null)
             {
                 var tag = (string)obj;
+                if (tag == (Annot as StickyAnnotArgs).StickyNote)
+                    return;
+
                 var data = StickyNoteTypes[tag];
                 var converter = TypeDescriptor.GetConverter(typeof(Geometry));
                 ExmpleData = (Geometry)converter.ConvertFrom(data);
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.StickyIcon, tag);
-                AnnotEvent?.UpdateAnnot();
+
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.StickyIcon, tag);
             }
         }
 
@@ -108,8 +118,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 double value = (double)obj;
                 Transpent = value;
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, value);
-                AnnotEvent?.UpdateAnnot();
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, value);
             }
         }
 
@@ -148,28 +157,94 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot;
+                IsMultiSelected = PropertyPanel.IsMultiSelected;
 
-                if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
+                if (IsMultiSelected)
                 {
-                    IsMultiSelected = true;
+                    IsAttributeEquals();
                 }
                 else
                 {
-                    IsMultiSelected = false;
+                    GetAnnotProperty();
                 }
 
-                if (IsMultiSelected)
+            }
+        }
+
+
+        private List<StickyAnnotArgs> ConvertLists()
+        {
+            List<StickyAnnotArgs> FreeTextLists = new List<StickyAnnotArgs>();
+            foreach (var item in PropertyPanel.annotlists)
+            {
+                var itemFreeText = item as StickyAnnotArgs;
+                if (itemFreeText != null)
                 {
+                    FreeTextLists.Add(itemFreeText);
+                }
+            }
+
+            if (FreeTextLists.Count != PropertyPanel.annotlists.Count)
+                return null;
+            else
+                return FreeTextLists;
+        }
+        private void IsAttributeEquals()
+        {
+            var list = ConvertLists();
+            if (list != null)
+            {
+                var temp = list[0];
+                Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
+                isNoEqualsDir.Add("SharpColor", false);
+                isNoEqualsDir.Add("tag", false);
+
+                foreach (var item in list)
+                {
+                    if (item == list[0])
+                        continue;
+
+                    if (isNoEqualsDir["SharpColor"] == false)
+                    {
+                        if (temp.Color.A != item.Color.A || temp.Color.R != item.Color.R || temp.Color.G != item.Color.G || temp.Color.B != item.Color.B)
+                        {
+                            SharpColor = new SolidColorBrush(Colors.Transparent);
+                            isNoEqualsDir["SharpColor"] = true;
+                        }
+                    }
+                    if (isNoEqualsDir["tag"] == false)
+                    {
+                        if (temp.IconName != item.IconName)
+                        {
+                            isNoEqualsDir["tag"] = true;
+                        }
+                    }
+
+
+
+
 
                 }
-                else
+
+                ////以下是多选注释的属性相等时
+                if (isNoEqualsDir["SharpColor"] == false)
                 {
-                    GetAnnotProperty();
+                    SharpColor = new SolidColorBrush(temp.Color);
+
                 }
 
+                if (isNoEqualsDir["tag"] == false)
+                {
+                    strOtherTag = temp.IconName;
+                }
+                else
+                {
+                    strOtherTag = "None";
+                }
             }
         }
 
+
         private void GetAnnotProperty()
         {
             if (Annot is StickyAnnotArgs)
@@ -179,6 +254,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 {
                     SharpColor = new SolidColorBrush(annot.Color);
                     Transpent = annot.Transparency;
+                    strOtherTag = annot.IconName;
                 }
                 
             }

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

@@ -94,10 +94,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 BasicVm.FillOpacity = (double)obj;
                 BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
-
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
-                AnnotEvent?.UpdateAnnot();
-                PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
+                PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
+                if (BasicVm.IsMultiSelected == false)
+                {
+                    PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
+                }
             }
         }
 
@@ -157,8 +158,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
             if(PropertyPanel != null)
             {
-
-                readyData();
+                AnnotEvent = PropertyPanel.AnnotEvent;
+                Annot = PropertyPanel.annot;
+                BasicVm.AnnotType = Annot.EventType;
+                BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
                 SetAnnotType();
 
                 //多选注释,默认通用属性颜色为高亮注释的预设颜色
@@ -178,22 +181,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         }
 
-        private void readyData()
-        {
-            AnnotEvent = PropertyPanel.AnnotEvent;
-            Annot = PropertyPanel.annot;
-            BasicVm.AnnotType = Annot.EventType;
-            if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
-            {
-                BasicVm.IsMultiSelected = true;
-            }
-            else
-            {
-                BasicVm.IsMultiSelected = false;
-            }
-        }
-
-
         private void GetAnnotProperty()
         {
             if (Annot != null)

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

@@ -35,6 +35,28 @@ namespace PDF_Office.ViewModels.Tools
         public AnnotPropertyPanel()
         { }
 
+        //外部UI控件选中状态
+        public bool IsSolidStyle(DashStyle LineDash)
+        {
+            bool isSolid = true;
+            if (LineDash == null || LineDash.Dashes.Count == 0)
+            {
+                return isSolid;
+            }
+
+            foreach (var item in LineDash.Dashes)
+            {
+                if (item > 0)
+                {
+
+                    isSolid = false;
+                    break;
+                }
+            }
+            return isSolid;
+
+        }
+
         //单个属性更改
         public void UpdateAnnotAAttrib(AnnotAttrib annotAttrib, object obj)
         {

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

@@ -139,6 +139,7 @@
                         <RowDefinition/>
                     </Grid.RowDefinitions>
                     <CompositeControl:SlidContent x:Name="layerThick" HorizontalAlignment="Right"
+                                         InitValue="{Binding BasicVm.FillOpacity,Mode=OneWay}"       
                                           Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"        
                                                   >
                         <i:Interaction.Triggers>

+ 63 - 182
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -116,127 +116,97 @@
                     </Grid.ColumnDefinitions>
 
 
-                    <ToggleButton
-                        Name="SharpRectBtn"
-                        Width="40.5"
-                        Background="Transparent"
-                        BorderThickness="0"
-                        Click="SharpsBtn_Click"
-                        Command="{Binding SharpsTypeCommand}"
-                        CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}"
-                        Tag="Rect">
-                        <Rectangle
+                    <RadioButton x:Name="SharpRectBtn" Tag="Rect" GroupName="Shape" 
+                                 Width="32" Height="32" Margin="0,0" 
+                                 VerticalContentAlignment="Center" Background="Transparent"
+                                 Style="{DynamicResource GreyBgRadioBtnStyle}">
+                        <RadioButton.Content>
+                            <Rectangle
                             Width="16"
                             Height="16"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             Stroke="#273C62" />
-                    </ToggleButton>
+                        </RadioButton.Content>
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </RadioButton>
 
-                    <Line
-                        Name="line1"
-                        Grid.Column="1"
-                        HorizontalAlignment="Left"
-                        VerticalAlignment="Center"
-                        Stroke="#33000000"
-                        StrokeThickness="1"
-                        X1="0"
-                        X2="0"
-                        Y1="0"
-                        Y2="16" />
 
-                    <ToggleButton
-                        Name="SharpCircleBtn"
-                        Grid.Column="1"
-                        Width="40.5"
-                        Margin="0,0,0,0"
-                        Background="Transparent"
-                        BorderThickness="0"
-                        Click="SharpsBtn_Click"
-                        Command="{Binding SharpsTypeCommand}"
-                        CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}"
-                        Tag="Circle">
-                        <Ellipse
+
+                    <RadioButton x:Name="SharpCircleBtn" Tag="Circle" GroupName="Shape"  Grid.Column="1"
+                                 Width="32" Height="32" Margin="0,0" 
+                                 VerticalContentAlignment="Center" Background="Transparent"
+                                 Style="{DynamicResource GreyBgRadioBtnStyle}">
+                        <RadioButton.Content>
+                            <Ellipse
                             Width="16"
                             Height="16"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             Stroke="#273C62" />
-                    </ToggleButton>
+                        </RadioButton.Content>
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </RadioButton>
 
 
-                    <Line
-                        Name="line2"
-                        Grid.Column="2"
-                        HorizontalAlignment="Left"
-                        VerticalAlignment="Center"
-                        Stroke="#33000000"
-                        StrokeThickness="1"
-                        Style="{StaticResource line2Style}"
-                        X1="0"
-                        X2="0"
-                        Y1="0"
-                        Y2="16" />
-                    <ToggleButton
-                        Name="SharpArrowBtn"
-                        Grid.Column="2"
-                        Width="40.5"
-                        Background="Transparent"
-                        BorderThickness="0"
-                        Click="SharpsBtn_Click"
-                        Command="{Binding SharpsTypeCommand}"
-                        CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}"
-                        Tag="Arrow">
-                        <Path
+
+
+                    <RadioButton x:Name="SharpArrowBtn" Tag="Arrow" GroupName="Shape"  Grid.Column="2"
+                                 Width="32" Height="32" Margin="0,0" 
+                                 VerticalContentAlignment="Center" Background="Transparent"
+                                 Style="{DynamicResource GreyBgRadioBtnStyle}">
+                        <RadioButton.Content>
+                            <Path
                             Width="16"
                             Height="16"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             Fill="#273C62">
-                            <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
-                            </Path.Data>
-                        </Path>
-                    </ToggleButton>
+                                <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
+                                </Path.Data>
+                            </Path>
+                        </RadioButton.Content>
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </RadioButton>
 
-                    <Line
-                        x:Name="line3"
-                        Grid.Column="3"
-                        HorizontalAlignment="Left"
-                        VerticalAlignment="Center"
-                        Stroke="#33000000"
-                        StrokeThickness="1"
-                        Style="{StaticResource line3Style}"
-                        X1="0"
-                        X2="0"
-                        Y1="0"
-                        Y2="16" />
-                    <ToggleButton
-                        Name="SharpLineBtn"
-                        Grid.Column="3"
-                        Width="40.5"
-                        Background="Transparent"
-                        BorderThickness="0"
-                        Click="SharpsBtn_Click"
-                        Command="{Binding SharpsTypeCommand}"
-                        CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}"
-                        Tag="Line">
-                        <Polygon
+                    <RadioButton x:Name="SharpLineBtn" Tag="Line" GroupName="Shape"  Grid.Column="3"
+                                 Width="32" Height="32" Margin="0,0" 
+                                 VerticalContentAlignment="Center" Background="Transparent"
+                                 Style="{DynamicResource GreyBgRadioBtnStyle}">
+                        <RadioButton.Content>
+                            <Polygon
                             Width="16"
                             Height="16"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             Fill="#273C62">
-                            <Polygon.Points>
-                                13.1757359 1.97573593 14.0242641 2.82426407 2.82426407 14.0242641 1.97573593 13.1757359
-                            </Polygon.Points>
-                        </Polygon>
-                    </ToggleButton>
-
+                                <Polygon.Points>
+                                    13.1757359 1.97573593 14.0242641 2.82426407 2.82426407 14.0242641 1.97573593 13.1757359
+                                </Polygon.Points>
+                            </Polygon>
+                        </RadioButton.Content>
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="Checked">
+                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
+                    </RadioButton>
                 </Grid>
             </Border>
 
-
             <Grid x:Name="GridFill" Margin="0,18,0,0">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="auto" />
@@ -293,95 +263,6 @@
                 </i:Interaction.Triggers>
             </CompositeControl:SlidComboControl>
 
-
-            <!--<Grid>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="*" />
-                    <ColumnDefinition Width="auto" />
-                </Grid.ColumnDefinitions>
-                <Slider
-                    Name="BorderSlider"
-                    Margin="12,0,4,0"
-                    VerticalAlignment="Center"
-                    IsMoveToPointEnabled="True"
-                    IsSelectionRangeEnabled="True"
-                    IsSnapToTickEnabled="True"
-                    Maximum="12"
-                    Minimum="1"
-                    Style="{StaticResource RoundThumbSlider}"
-                    TickFrequency="1"
-                    Value="{Binding LineWidth}">
-                    <Slider.Resources>
-                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
-                        <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
-                    </Slider.Resources>
-                </Slider>
-
-                <Border
-                    Grid.Column="1"
-                    Width="80"
-                    Height="32"
-                    Margin="0,0,12,0"
-                    BorderBrush="#E2E3E6"
-                    BorderThickness="0">
-                    <Grid>
-                        <ComboBox
-                            Name="BorderDropBox"
-                            Padding="10,10,0,0"
-                            Background="Transparent"
-                            BorderBrush="#FFE2E3E6"
-                            BorderThickness="1">
-                            <ComboBox.ItemContainerStyle>
-                                <Style TargetType="{x:Type ComboBoxItem}">
-                                    <Setter Property="Padding" Value="10,0,0,0" />
-                                </Style>
-                            </ComboBox.ItemContainerStyle>
-                            <ComboBoxItem
-                                Height="32"
-                                VerticalContentAlignment="Center"
-                                Content="1"
-                                Template="{StaticResource comboxitem}" />
-                            <ComboBoxItem
-                                Height="32"
-                                VerticalContentAlignment="Center"
-                                Content="3"
-                                Template="{StaticResource comboxitem}" />
-                            <ComboBoxItem
-                                Height="32"
-                                VerticalContentAlignment="Center"
-                                Content="6"
-                                Template="{StaticResource comboxitem}" />
-                            <ComboBoxItem
-                                Height="32"
-                                VerticalContentAlignment="Center"
-                                Content="9"
-                                Template="{StaticResource comboxitem}" />
-                            <ComboBoxItem
-                                Height="32"
-                                VerticalContentAlignment="Center"
-                                Content="12"
-                                Template="{StaticResource comboxitem}" />
-                            <i:Interaction.Triggers>
-                                <i:EventTrigger EventName="SelectionChanged">
-                                    <i:InvokeCommandAction Command="{Binding ThicknessChangedCommand}" CommandParameter="{Binding ElementName=BorderDropBox, Path=SelectedItem}" />
-                                </i:EventTrigger>
-                            </i:Interaction.Triggers>
-                        </ComboBox>
-                        <TextBox
-                            Height="20"
-                            Margin="10,0,35,0"
-                            VerticalAlignment="Center"
-                            Background="White"
-                            BorderThickness="0"
-                            FontFamily="Segoe UI"
-                            FontSize="14"
-                            IsReadOnly="True"
-                            Text="{Binding ElementName=BorderSlider, Path=Value}"
-                            TextAlignment="Left" />
-                    </Grid>
-                </Border>
-            </Grid>-->
-
             <StackPanel  x:Name="PnlLineStyle" Orientation="Horizontal" Margin="0,20,0,0">
 
                 <RadioButton x:Name="BtnSolid" Tag="Solid" GroupName="LineMode"

+ 14 - 115
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml.cs

@@ -50,127 +50,26 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
                     BtnSolid.IsChecked = false;
                     BtnDashed.IsChecked = false;
                 }
-            }
-        }
-
-        private void ViewModel_LoadPropertyHandler(object sender, object e)
-        {
-            var item = e as AnnotHandlerEventArgs;
-            switch (item.EventType)
-            {
-                case AnnotArgsType.AnnotSquare:
-                    {
-                        var annot = item as SquareAnnotArgs;
-                        if (annot != null)
-                        {
-                            cusColor.SelectedColor = annot.LineColor;
-                            cusFillColor.SelectedColor= annot.BgColor;
-                            layerFill.SetSliOpacity(annot.Transparency);
-                            SharpsBtn_Click(SharpRectBtn, null);
-
-                            SolidLineIschecked(annot.LineDash.Dashes == null || annot.LineDash.Dashes.Count == 0 || annot.LineDash.Dashes[0] == 0);
-                        }
-                        break;
-                    }
-
-                case AnnotArgsType.AnnotCircle:
-                    {
-                        var annot = item as CircleAnnotArgs;
-                        if (annot != null)
-                        {
-                            cusColor.SelectedColor=annot.LineColor;
-                            cusFillColor.SelectedColor=annot.BgColor;
-                            layerFill.SetSliOpacity(annot.Transparency);
-                            SharpsBtn_Click(SharpCircleBtn, null);
-
-                            SolidLineIschecked(annot.LineDash.Dashes == null || annot.LineDash.Dashes.Count == 0 || annot.LineDash.Dashes[0] == 0);
-                        }
-                        break;
-                    }
-
-                case AnnotArgsType.AnnotLine:
-                    {
-                        var annot = item as LineAnnotArgs;
-                        if (annot != null)
-                        {
-                            cusColor.SelectedColor=annot.LineColor;
-                            cusFillColor.SelectedColor=annot.LineColor;
-                            layerFill.SetSliOpacity(annot.Transparency);
-
-                            if (annot.TailLineType == C_LINE_TYPE.LINETYPE_ARROW && annot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE)
-                                SharpsBtn_Click(SharpArrowBtn, null);
-                            else
-                                SharpsBtn_Click(SharpLineBtn, null);
-
-                            SolidLineIschecked(annot.LineDash.Dashes == null || annot.LineDash.Dashes.Count == 0 || annot.LineDash.Dashes[0] == 0);
-
-                        }
-                        break;
-                    }
-            }
-        }
-
-        private void SolidLineIschecked(bool isSolid)
-        {
-            if (isSolid)
-            {
-                BtnSolid.IsChecked = true;
-            }
-            else
-            {
-                BtnDashed.IsChecked = true;
-            }
-        }
-
 
- 
-        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)
+                 str = ViewModel.BasicVm.strOtherTag;
+                if (str == "Rect")
                 {
-                    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;
-                        }
-                    }
+                    SharpRectBtn.IsChecked = true;
                 }
-            }
-        }
-
-        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)
+                else if(str == "Circle")
+                {
+                    SharpCircleBtn.IsChecked = true;
+                }
+                else if(str == "Arrow")
+                {
+                    SharpArrowBtn.IsChecked = true;
+                }
+                else if(str == "Line")
                 {
-                    if (btnItem != btn)
-                    {
-                        btnItem.IsChecked = false;
-                    }
-                    else
-                    {
-                        btnItem.IsChecked = true;
-                        
-                    }
+                    SharpLineBtn.IsChecked = true;
                 }
             }
         }
+
     }
 }

File diff suppressed because it is too large
+ 14 - 8
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNoteProperty.xaml


+ 53 - 14
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNoteProperty.xaml.cs

@@ -71,37 +71,76 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
 
         private void SlidOpacity_SelectedValue(object sender, double e)
         {
-            if (ViewModel != null)
-            {
-                ViewModel.SelectedValueChangedCommand?.Execute(e);
-            }
+            //if (ViewModel != null)
+            //{
+            //    ViewModel.SelectedValueChangedCommand?.Execute(e);
+            //}
         }
 
         private void cusColor_SelectedColor(object sender, Color e)
         {
-            if (ViewModel != null)
-            {
-                ViewModel.SelectedColorChangedCommand?.Execute(e);
-            }
+            //if (ViewModel != null)
+            //{
+            //    ViewModel.SelectedColorChangedCommand?.Execute(e);
+            //}
         }
 
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
-            cusColor.SelectedColorHandler -= cusColor_SelectedColor;
-            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+            if(ViewModel != null)
+            {
+                switch(ViewModel.strOtherTag)
+                {
+                    case "Comment":
+                        BtnComment.IsChecked = true;
+                        break;
+                    case "Note":
+                        BtnNote.IsChecked = true;
+                        break;
+                    case "Key":
+                        BtnKey.IsChecked = true;
+                        break;
+                    case "Help":
+                        BtnHelp.IsChecked = true;
+                        break;
+                    case "Insert":
+                        BtnInsert.IsChecked = true;
+                        break;
+                    case "Paragraph":
+                        BtnParagraph.IsChecked = true;
+                        break;
+                    case "NewParagraph":
+                        BtnNewParagraph.IsChecked = true;
+                        break;
+                    case "None":
+                        BtnComment.IsChecked = false;
+                        BtnNote.IsChecked = false;
+                        BtnKey.IsChecked = false;
+                        BtnHelp.IsChecked = false;
+                        BtnInsert.IsChecked = false;
+                        BtnParagraph.IsChecked = false;
+                        BtnNewParagraph.IsChecked = false;
+                        break;
+                    default:
+                        BtnComment.IsChecked = true;
+                        break;
+                }
+            }
+          //  cusColor.SelectedColorHandler -= cusColor_SelectedColor;
+         //   cusColor.SelectedColorHandler += cusColor_SelectedColor;
 
            // SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
            // SlidOpacity.SelectedValueChanged += SlidOpacity_SelectedValue;
 
-            ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
-            ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
+         //   ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
+         //   ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
         }
 
         private void UserControl_Unloaded(object sender, RoutedEventArgs e)
         {
-            cusColor.SelectedColorHandler -= cusColor_SelectedColor;
+          //  cusColor.SelectedColorHandler -= cusColor_SelectedColor;
            // SlidOpacity.SelectedValueChanged -= SlidOpacity_SelectedValue;
-            ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
+          //  ViewModel.LoadPropertyHandler -= ViewModel_LoadPropertyHandler;
         }
     }
 }