Quellcode durchsuchen

注释 - 优化文本注释属性面板

chenrongqian@kdanmobile.com vor 2 Jahren
Ursprung
Commit
7f5480d644

+ 20 - 0
PDF Office/CustomControl/CompositeControl/SlidContent.xaml.cs

@@ -41,6 +41,26 @@ namespace PDF_Office.CustomControl.CompositeControl
         public static readonly DependencyProperty _valueProperty =
       DependencyProperty.Register("Value", typeof(double), typeof(SlidContent), new PropertyMetadata(0.0));
 
+        public double InitValue
+        {
+            get { return (double)GetValue(_initValueProperty); }
+            set { SetValue(_initValueProperty, value); }
+        }
+
+        public static readonly DependencyProperty _initValueProperty =
+      DependencyProperty.Register("InitValue", typeof(double), typeof(SlidContent), new PropertyMetadata(-1.0, InitValuePropertyChanged));
+
+        private static void InitValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var control = d as SlidContent;
+            var newdouble = (double)e.NewValue;
+            if (control != null && newdouble >= 0.0)
+            {
+                control.SlidOpacityPop.SetOpacity(newdouble);
+            }
+        }
+
+
         #endregion
 
         public SlidContent()

+ 28 - 0
PDF Office/CustomControl/CompositeControl/SlidContentPop.xaml.cs

@@ -27,6 +27,34 @@ namespace PDF_Office.CustomControl.CompositeControl
             InitializeComponent();
         }
 
+        public void SetOpacity(double opacity)
+        {
+            bool changeFromDropBox = false;
+            if(opacity == 0.25)
+            {
+                OpacityDropBox.SelectedIndex = 0;
+                changeFromDropBox = true;
+            }
+            else if(opacity == 0.50)
+            {
+                OpacityDropBox.SelectedIndex = 1;
+                changeFromDropBox = true;
+            }
+            else if(opacity == 0.75)
+            {
+                OpacityDropBox.SelectedIndex = 2;
+                changeFromDropBox = true;
+            }
+            else if(opacity ==1)
+            {
+                OpacityDropBox.SelectedIndex = 3;
+                changeFromDropBox = true;
+            }
+
+            if (changeFromDropBox == false)
+                OpacitySlider.Value = opacity;
+
+        }   
         private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
         {
             OpacityValueChangedHandler?.Invoke(this, e.NewValue);

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

@@ -219,9 +219,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
                 AnnotEvent?.UpdateAnnot();
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotArgsType.AnnotFreehand] = annotOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
+                PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, annotOpacity);
             }
         }
 
@@ -246,10 +244,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     {
                         SelectColor = new SolidColorBrush(colorValue);
                         SelectColor.Opacity = AnnotOpacity;
-
-                        Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                        changeData[AnnotArgsType.AnnotFreehand] = obj;
-                        PropertyPanel.DataChangedInvoke(this, changeData);
+                        PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, obj);
                     }
                    
                 }
@@ -261,9 +256,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             var btn = obj as ToggleButton;
             if(btn.IsChecked == true)
             {
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotArgsType.AnnotErase] = btn;
-                PropertyPanel.DataChangedInvoke(this, changeData);
+                PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotErase, btn);
                 IsPen = false;
             }
         }
@@ -273,9 +266,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             var btn = obj as ToggleButton;
             if (btn.IsChecked == true)
             {
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotArgsType.AnnotErase] = btn;
-                PropertyPanel.DataChangedInvoke(this, changeData);
+                PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotErase, btn);
                 IsPen = true;
             }
         }

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

@@ -256,7 +256,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                     Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                     changeData[AnnotArgsType.AnnotFreehand] = obj;
-                    PropertyPanel.DataChangedInvoke(this, changeData);
+                    PropertyPanel.InvokeToMyTools(this, changeData);
                 }
             }
         }
@@ -274,7 +274,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     
                     Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                     changeData[AnnotArgsType.AnnotFreehand] = obj;
-                    PropertyPanel.DataChangedInvoke(this, changeData);
+                    PropertyPanel.InvokeToMyTools(this, changeData);
                 }
             }
         }

+ 31 - 14
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -20,7 +20,6 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-
     public class DashStyleConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -151,25 +150,43 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             set
             {
                 SetProperty(ref dash, value);
-                if(dash.Dashes != null && dash.Dashes.Count > 0)
+                if (IsMultiSelected)
                 {
-                    if (dash.Dashes[0] == 0)
-                    {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
-                    }
-                    else
+                    foreach (var item in PropertyPanel.AnnotEvents)
                     {
-                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dash);
+                        UpdateDash(item);
                     }
+                }
+                else
+                {
+                    UpdateDash(AnnotEvent);
+                }
+
+               
+            }
+        }
 
+        private void UpdateDash(AnnotAttribEvent attribEvent)
+        {
+            if (Dash.Dashes != null && Dash.Dashes.Count > 0)
+            {
+
+                if (Dash.Dashes[0] == 0)
+                {
+                    attribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
                 }
                 else
                 {
-                    AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
+                    attribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dash);
                 }
 
-                AnnotEvent?.UpdateAnnot();
             }
+            else
+            {
+                attribEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
+            }
+
+            attribEvent?.UpdateAnnot();
         }
 
         private bool _isMultiSelected = false;
@@ -321,7 +338,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                     Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                     changeData[AnnotArgsType.AnnotFreehand] = obj;
-                    PropertyPanel.DataChangedInvoke(this, changeData);
+                    PropertyPanel.InvokeToMyTools(this, changeData);
                 }
             }
            
@@ -338,7 +355,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 AnnotEvent?.UpdateAnnot();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
+                PropertyPanel.InvokeToMyTools(this, changeData);
             }
 
         }
@@ -354,7 +371,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 AnnotEvent?.UpdateAnnot();
                 Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                 changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
+                PropertyPanel.InvokeToMyTools(this, changeData);
             }
 
         }
@@ -374,7 +391,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                     Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                     changeData[AnnotArgsType.AnnotFreehand] = obj;
-                    PropertyPanel.DataChangedInvoke(this, changeData);
+                    PropertyPanel.InvokeToMyTools(this, changeData);
                 }
 
             }

+ 57 - 192
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -64,175 +64,55 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
     }
     public class TextAnnotPropertyViewModel:BindableBase, INavigationAware
     {
-     
 
         #region 属性
-
-        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 double annotOpacity;
-        public double AnnotOpacity
-        {
-            get {return annotOpacity;}
-            set 
-            { 
-                SetProperty(ref annotOpacity, value);
-            }
-        }
-
-
-        /// <summary>
-        /// 示例背景
-        /// </summary>
-        private Brush sampleTextBg = new SolidColorBrush(Colors.Transparent);
-        public Brush SampleTextBg
-        {
-            get { return sampleTextBg; }
-            set { SetProperty(ref sampleTextBg, value); 
-                if(Annot.EventType == AnnotArgsType.AnnotHighlight)
-                {
-                    CurrentColor = sampleTextBg;
-                    AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (sampleTextBg as SolidColorBrush).Color);
-                    AnnotEvent?.UpdateAnnot();
-                }
-                
-            }
-        }
-
-
-        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
-        public Brush SelectColor
+        private AnnotBasePropertyVM _basicVm = new AnnotBasePropertyVM();
+        public AnnotBasePropertyVM BasicVm
         {
-            get { return selectColor; }
-            set { 
-                SetProperty(ref selectColor, value);
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
-                AnnotEvent?.UpdateAnnot();
-                CurrentColor = selectColor;
-            }
-        }
-
-        private Brush _currentColor = new SolidColorBrush(Colors.Transparent);
-        public Brush CurrentColor
-        {
-            get { return _currentColor; }
+            get { return _basicVm; }
             set
             {
-                SetProperty(ref _currentColor, value);
+                SetProperty(ref _basicVm, value); 
             }
         }
 
-        private bool _isMultiSelected = false;
-        public bool IsMultiSelected
-        {
-            get { return _isMultiSelected; }
-            set => SetProperty(ref _isMultiSelected, value);
-        }
-
-        #endregion
+        #endregion 属性
 
         public AnnotAttribEvent AnnotEvent { get; set; }
         private AnnotHandlerEventArgs Annot;
         private AnnotPropertyPanel PropertyPanel;
         public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
-        public DelegateCommand<object> OpacityItemCommand { get; set; }
-        public DelegateCommand<object> OpacityValueChangedCommand { get; set; }
-        public DelegateCommand<object> SelectedValueChangedCommand { get; set; }
-
-        public event EventHandler<object> LoadPropertyHandler;
+        public DelegateCommand<object> SelectedOpacityChangedCommand { get; set; }
 
         public TextAnnotPropertyViewModel()
         {
-            SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
-            OpacityItemCommand = new DelegateCommand<object>(OpacityItemCommand_Click);
-            OpacityValueChangedCommand = new DelegateCommand<object>(OpacityValueChanged_Command);
-            SelectedValueChangedCommand = new DelegateCommand<object>(SelectedValueChanged_Command);
+            SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged);
+            SelectedOpacityChangedCommand = new DelegateCommand<object>(SelectedOpacityChanged);
         }
 
-        private void SelectedValueChanged_Command(object obj)
+        //设置不透明度
+        private void SelectedOpacityChanged(object obj)
         {
             if (obj != null)
             {
-                annotOpacity = (double)obj;
-                if (AnnotType == AnnotArgsType.AnnotHighlight)
-                    SampleTextBg.Opacity = annotOpacity;
-                else
-                    SelectColor.Opacity = annotOpacity;
+                BasicVm.FillOpacity = (double)obj;
+                BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
 
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
                 AnnotEvent?.UpdateAnnot();
-           
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotType] = annotOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
+                PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
             }
         }
 
-        private void OpacityItemCommand_Click(object obj)
-        {
-            if (obj != null)
-            {
-                if (AnnotType == AnnotArgsType.AnnotHighlight)
-                    SampleTextBg.Opacity = annotOpacity;
-                else
-                    SelectColor.Opacity = annotOpacity;
-
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
-                AnnotEvent?.UpdateAnnot();
-      
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotType] = annotOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
-            }
-        }
-
-        private void OpacityValueChanged_Command(object obj)
-        {
-            if (obj != null)
-            {
-                if (AnnotType == AnnotArgsType.AnnotHighlight)
-                    SampleTextBg.Opacity = annotOpacity;
-                else
-                    SelectColor.Opacity = annotOpacity;
-
-                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
-                AnnotEvent?.UpdateAnnot();
-               
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotType] = annotOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
-            }
-        }
-
-        public void SelectedColorChanged_Click(object color)
+        //设置颜色
+        public void SelectedColorChanged(object color)
         {
             if (color != null && PropertyPanel != null)
             {
                 var colorValue = (Color)color;
                 if (colorValue != null)
                 {
-                    if(IsMultiSelected)
+                    if(BasicVm.IsMultiSelected)
                     {
                         foreach (var item in PropertyPanel.AnnotEvents)
                         {
@@ -242,24 +122,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     }
                     else
                     {
-                        switch (AnnotType)
-                        {
-                            case AnnotArgsType.AnnotHighlight:
-                                SampleTextBg = new SolidColorBrush(colorValue);
-                                SampleTextBg.Opacity = AnnotOpacity;
-                                break;
-                            case AnnotArgsType.AnnotUnderline:
-                            case AnnotArgsType.AnnotStrikeout:
-                            case AnnotArgsType.AnnotSquiggly:
-                            case AnnotArgsType.AnnotSticky:
-                                SelectColor = new SolidColorBrush(colorValue);
-                                SelectColor.Opacity = AnnotOpacity;
-                                break;
-                        }
-
-                        Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                        changeData[AnnotType] = color;
-                        PropertyPanel.DataChangedInvoke(this, changeData);
+                        BasicVm.FontColor = new SolidColorBrush(colorValue);
+                        BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, colorValue);
+                        AnnotEvent?.UpdateAnnot();
+                        PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, color);
                     }
                    
                    
@@ -269,22 +136,19 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         private void SetAnnotType()
         {
-            switch (AnnotType)
+            switch (BasicVm.AnnotType)
             {
                 case AnnotArgsType.AnnotHighlight:
-                    AnnotTypeTitle = "高亮";
+                    BasicVm.AnnotTypeTitle = "高亮";
                     break;
                 case AnnotArgsType.AnnotUnderline:
-                    AnnotTypeTitle = "下划线";
+                    BasicVm.AnnotTypeTitle = "下划线";
                     break;
                 case AnnotArgsType.AnnotStrikeout:
-                    AnnotTypeTitle = "删除线";
+                    BasicVm.AnnotTypeTitle = "删除线";
                     break;
                 case AnnotArgsType.AnnotSquiggly:
-                    AnnotTypeTitle = "波浪线";
-                    break;
-                case AnnotArgsType.AnnotSticky:
-                    AnnotTypeTitle = "??";
+                    BasicVm.AnnotTypeTitle = "波浪线";
                     break;
             }
         }
@@ -296,48 +160,52 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-            IsMultiSelected = false;
+            BasicVm.IsMultiSelected = false;
         }
 
-
-       
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
 
             navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
             if(PropertyPanel != null)
             {
-                AnnotEvent = PropertyPanel.AnnotEvent;
-                Annot = PropertyPanel.annot;
-                AnnotType = Annot.EventType;
 
-                if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
-                {
-                    IsMultiSelected = true;
-                }
-                else
-                {
-                    IsMultiSelected = false;
-                }
+                readyData();
+                SetAnnotType();
 
-                if(IsMultiSelected)
+                //多选注释,默认通用属性颜色为高亮注释的预设颜色
+                if(BasicVm.IsMultiSelected)
                 {
                     DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
                     if (annotProperty != null)
                     {
-                        SelectColor = new SolidColorBrush(annotProperty.ForgoundColor);
+                        BasicVm.FontColor = new SolidColorBrush(annotProperty.ForgoundColor);
                     }
                 }
                 else
                 {
                     GetAnnotProperty();
                 }
-                
-                LoadPropertyHandler?.Invoke(null, Annot);
             }
 
         }
 
+        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)
@@ -348,8 +216,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                       if (Annot is TextHighlightAnnotArgs)
                         {
                             var Hightlight = Annot as TextHighlightAnnotArgs;
-                            AnnotOpacity = Hightlight.Transparency;
-                            SampleTextBg = new SolidColorBrush(Hightlight.Color);
+                            BasicVm.FillOpacity = Hightlight.Transparency;
+                            BasicVm.FontColor = new SolidColorBrush(Hightlight.Color);
 
                         }
                         break;
@@ -357,27 +225,24 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     case AnnotArgsType.AnnotUnderline:
                         {
                             var Underline = Annot as TextUnderlineAnnotArgs;
-                            AnnotOpacity = Underline.Transparency;
-                             SampleTextBg = new SolidColorBrush(Colors.Transparent);
-                            SelectColor = new SolidColorBrush(Underline.Color);
+                            BasicVm.FillOpacity = Underline.Transparency;
+                            BasicVm.FontColor = new SolidColorBrush(Underline.Color);
                         }
                         break;
 
                     case AnnotArgsType.AnnotStrikeout:
                         {
                             var Strikeout = Annot as TextStrikeoutAnnotArgs;
-                            AnnotOpacity = Strikeout.Transparency;
-                            SampleTextBg = new SolidColorBrush(Colors.Transparent);
-                            SelectColor = new SolidColorBrush(Strikeout.Color);
+                            BasicVm.FillOpacity = Strikeout.Transparency;
+                            BasicVm.FontColor = new SolidColorBrush(Strikeout.Color);
                         }
                         break;
 
                     case AnnotArgsType.AnnotSquiggly:
                         {
                             var Squiggly = Annot as TextSquigglyAnnotArgs;
-                            AnnotOpacity = Squiggly.Transparency;
-                            SampleTextBg = new SolidColorBrush(Colors.Transparent);
-                            SelectColor = new SolidColorBrush(Squiggly.Color);
+                            BasicVm.FillOpacity = Squiggly.Transparency;
+                            BasicVm.FontColor = new SolidColorBrush(Squiggly.Color);
                         }
                         break;
 

+ 3 - 3
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -129,7 +129,7 @@ namespace PDF_Office.ViewModels.Tools
 
         #region PDFViewer事件
 
-        //选中和非选中注释,右键菜单
+        //选中和非选中注释
         private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
         {
             if (e != null)
@@ -143,8 +143,7 @@ namespace PDF_Office.ViewModels.Tools
                         if (e.IsAnnotCreateReset == false)
                         {
                             GetSelectedAnnots(e);
-                            //记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
-                            PDFViewer.SetToolParam(annot);
+                            //PDFViewer.SetToolParam(annot);
                         }
                         else
                         {
@@ -545,6 +544,7 @@ namespace PDF_Office.ViewModels.Tools
                     switch (editEvent.EditAction)
                     {
                         case ActionType.Add:
+                            
                             bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
 
                             if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)

+ 13 - 4
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -35,15 +35,24 @@ namespace PDF_Office.ViewModels.Tools
         { }
 
         /// <summary>
-        /// 触发到工具栏注释工具,改变工具图标下的颜色值
+        /// 更新多个属性,触发到工具栏注释工具,改变工具图标下的颜色值
         /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="keyValues"></param>
-        public void DataChangedInvoke(object sender, Dictionary<AnnotArgsType, object> keyValues)
+        public void InvokeToMyTools(object sender, Dictionary<AnnotArgsType, object> keyValues)
         {
             DataChanged?.Invoke(sender, keyValues);
         }
 
+        /// <summary>
+        /// 更新单个属性
+        /// </summary>
+        public void InvokeToMyTools(AnnotArgsType argsType, object obj)
+        {
+            Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+            changeData[argsType] = obj;
+            DataChanged?.Invoke(null, changeData);
+        }
+
+        //同一属性面板,切换注释工具
         public void AnnotTypeChangedInvoke(object sender, Dictionary<AnnotArgsType, object> keyValues)
         {
             AnnotTypeChanged?.Invoke(sender, keyValues);

+ 29 - 29
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml

@@ -12,7 +12,7 @@
              xmlns:AnnotPanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
              d:DataContext="{d:DesignInstance Type=AnnotPanel:TextAnnotPropertyViewModel}"
              xmlns:Convert="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
-             xmlns:convert="clr-namespace:PDF_Office.DataConvert"
+             xmlns:dataconvert="clr-namespace:PDF_Office.DataConvert"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
@@ -21,60 +21,60 @@
                 <ResourceDictionary Source="../../../Styles/SliderStyle.xaml"></ResourceDictionary>
             </ResourceDictionary.MergedDictionaries>
             <Convert:AnnotArgsTypeConverter x:Key="AnnotArgsTypeConverter"/>
-            <convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
+            <dataconvert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
         </ResourceDictionary>
       
     </UserControl.Resources>
     <Grid  VerticalAlignment="Stretch" Background="#F3F3F3">
         <StackPanel Margin="12 0 12 0">
             <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="0,16,0,8"
-                       Text="{Binding AnnotTypeTitle}"
+                       Text="{Binding BasicVm.AnnotTypeTitle,Mode=OneWay}"
                        ></TextBlock>
             
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0"
-                     Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                     Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
                     >
                 <Grid>
-                    <TextBlock Name="SampleText" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontFamily="Segoe UI" FontSize="18"
-                             Background="{Binding SampleTextBg}" 
-                               >
-                    </TextBlock>
-                    <Path Name="UnderlinePath" HorizontalAlignment="Center" StrokeThickness="2" Margin="0,60,0,0" Stroke="{Binding SelectColor}" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotUnderline}">
-                        <Path.Data>
-                            <LineGeometry StartPoint="0,0" EndPoint="62,0"></LineGeometry>
-                        </Path.Data>
-                    </Path>
-                    <Path Name="StrikeoutPath" HorizontalAlignment="Center" StrokeThickness="2" Margin="0,50,0,0" Stroke="{Binding SelectColor}" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotStrikeout}">
-                        <Path.Data>
-                            <LineGeometry StartPoint="0,0" EndPoint="62,0"></LineGeometry>
-                        </Path.Data>
-                    </Path>
-                    <Path Name="SquigglyPath"  HorizontalAlignment="Center" StrokeThickness="2" Margin="0,51,0,0" Stroke="{Binding SelectColor}" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotSquiggly}">
-
-                    </Path>
-
-                    <Path Name="StickyPath" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed" Fill="#FF8133"
-                      Data="M28.8,4.8 L28.8,24 L16,24 L8,28.8 L8,24 L3.2,24 L3.2,4.8 L28.8,4.8 Z M24,15.2 L8,15.2 L8,17.6 L24,17.6 L24,15.2 Z M17.6,9.6 L8,9.6 L8,12 L17.6,12 L17.6,9.6 Z">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="*"/>
+                        <ColumnDefinition Width="Auto"/>
+                        <ColumnDefinition Width="*"/>
+                    </Grid.ColumnDefinitions>
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="*"/>
+                        <RowDefinition Height="Auto"/>
+                        <RowDefinition Height="*"/>
+                    </Grid.RowDefinitions>
+                    <Rectangle Grid.Row="1" Grid.Column="1"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
+                               Fill="{Binding BasicVm.FontColor}" Visibility="{Binding BasicVm.AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotHighlight}" />
+                  
+                    <Rectangle Grid.Row="1" Grid.Column="1" Height="2" StrokeThickness="2" HorizontalAlignment="Stretch"
+                               Stroke="{Binding BasicVm.FontColor}" Visibility="{Binding BasicVm.AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotStrikeout}"/>
+                    
+                    <Rectangle Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom"  Height="2" StrokeThickness="2" HorizontalAlignment="Stretch" 
+                               Stroke="{Binding BasicVm.FontColor}" Visibility="{Binding BasicVm.AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotUnderline}" />
 
-                    </Path>
+                    <TextBlock Name="SampleText" Grid.Row="1" Grid.Column="1" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontFamily="Segoe UI" FontSize="18" >
+                    </TextBlock>
                 </Grid>
             </Border>
 
-
             <Grid Margin="0,18,0,0">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="auto"/>
                     <RowDefinition/>
                 </Grid.RowDefinitions>
                 <CompositeControl:SlidContent x:Name="SlidOpacity" HorizontalAlignment="Right" 
-                                              Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                                              InitValue="{Binding BasicVm.FillOpacity,Mode=OneWay}"
+                                              Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedValueChanged">
-                            <i:InvokeCommandAction Command="{Binding SelectedValueChangedCommand}" CommandParameter="{Binding ElementName=SlidOpacity,Path=Value}"/>
+                            <i:InvokeCommandAction Command="{Binding SelectedOpacityChangedCommand}" CommandParameter="{Binding ElementName=SlidOpacity,Path=Value}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:SlidContent>
-                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor" UIColor="{Binding CurrentColor,Mode=OneWay}" >
+                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor"
+                                               UIColor="{Binding BasicVm.CurrentFontColor,Mode=OneWay}" >
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedColorInvoke">
                             <i:InvokeCommandAction Command="{Binding SelectedColorChangedCommand}" CommandParameter="{Binding ElementName=cusColor,Path=SelectedColor}"/>

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

@@ -29,47 +29,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         public TextAnnotProperty()
         {
             InitializeComponent();
-            ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
         }
-
-        private void ViewModel_LoadPropertyHandler(object sender, object e)
-        {
-            var item = e as AnnotHandlerEventArgs;
-            switch (item.EventType)
-            {
-                case AnnotArgsType.AnnotHighlight:
-                    {
-                        var annot = item as TextHighlightAnnotArgs;
-                        if (annot != null)
-                        {
-                            SlidOpacity.SetSliOpacity(annot.Transparency);
-                        }
-                        break;
-                    }
-
-                case AnnotArgsType.AnnotUnderline:
-                    {
-                        var annot = item as TextUnderlineAnnotArgs;
-                        if (annot != null)
-                        {
-                            SlidOpacity.SetSliOpacity(annot.Transparency);
-                        }
-                        break;
-                    }
-
-                case AnnotArgsType.AnnotStrikeout:
-                    {
-                        var annot = item as TextStrikeoutAnnotArgs;
-                        if (annot != null)
-                        {
-                            SlidOpacity.SetSliOpacity(annot.Transparency);
-                        }
-                        break;
-                    }
-            }
-        }
-
-
     }
    
 }