Browse Source

注释 - 多选高亮、下划线、删除线注释同一更改属性

chenrongqian@kdanmobile.com 2 years ago
parent
commit
d9fcc02f2a

+ 11 - 8
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -364,18 +364,21 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 LoadPropertyHandler?.Invoke(this, Annot);
                 ChangedValue -= FontMode_ChangedValue;
                 ChangedValue += FontMode_ChangedValue;
-
-                SelectColor = new SolidColorBrush(Annot.FontColor);
-                FillColor = new SolidColorBrush(Annot.BgColor);
-
-                GetCurrentFontSize((int)Annot.FontSize);
-                GetCurrentFontFamily(Annot.FontFamily.ToString(), Annot.FontFamily.ToString());
-                GetFontWeights_Style( Annot.FontStyle, Annot.FontWeight);
-
+                GetAnnotProperty();
                 IsCanSave = true;
             }
         }
 
+        private void GetAnnotProperty()
+        {
+            SelectColor = new SolidColorBrush(Annot.FontColor);
+            FillColor = new SolidColorBrush(Annot.BgColor);
+
+            GetCurrentFontSize((int)Annot.FontSize);
+            GetCurrentFontFamily(Annot.FontFamily.ToString(), Annot.FontFamily.ToString());
+            GetFontWeights_Style(Annot.FontStyle, Annot.FontWeight);
+        }
+
         private void FontMode_ChangedValue(object sender, FontSetModeType e)
         {
             if (sender != null)

+ 49 - 20
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -1,5 +1,6 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.ViewModels.Tools;
 using PDFSettings;
@@ -231,25 +232,37 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 var colorValue = (Color)color;
                 if (colorValue != null)
                 {
-                   
-                    switch (AnnotType)
+                    if(IsMultiSelected)
                     {
-                        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;
+                        foreach (var item in PropertyPanel.AnnotEvents)
+                        {
+                            item?.UpdateAttrib(AnnotAttrib.Color, colorValue);
+                            item?.UpdateAnnot();
+                        }
                     }
+                    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);
+                        Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                        changeData[AnnotType] = color;
+                        PropertyPanel.DataChangedInvoke(this, changeData);
+                    }
+                   
+                   
                 }
             }
         }
@@ -296,14 +309,30 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 AnnotEvent = PropertyPanel.AnnotEvent;
                 Annot = PropertyPanel.annot;
-                AnnotType = Annot.EventType; 
-                 if(PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
+                AnnotType = Annot.EventType;
+
+                if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
                 {
                     IsMultiSelected = true;
                 }
+                else
+                {
+                    IsMultiSelected = false;
+                }
 
-
-                GetAnnotProperty();
+                if(IsMultiSelected)
+                {
+                    DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
+                    if (annotProperty != null)
+                    {
+                        SelectColor = new SolidColorBrush(annotProperty.ForgoundColor);
+                    }
+                }
+                else
+                {
+                    GetAnnotProperty();
+                }
+                
                 LoadPropertyHandler?.Invoke(null, Annot);
             }
 

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

@@ -907,22 +907,33 @@ namespace PDF_Office.ViewModels.Tools
 
             if (annots != null)
             {
-                if (annots.Count > 1)
-                {
-                    propertyPanel.annotlists = annots;
-                    propertyPanel.annot = annots[0];
-                }
-                else
-                {
-                    propertyPanel.annot = annots[0];
-                }
+                propertyPanel.annotlists = annots;
+                propertyPanel.annot = annots[0];
+            }
+            else
+            {
+                propertyPanel.annotlists = null;
+                propertyPanel.annot = null;
             }
 
             if (annotAttribsList != null)
             {
-                AnnotHandlerEventArgs annot = annots[0];
-                propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
-                if (annot is LinkAnnotArgs && annotAttribEvent != null)
+                if(annots.Count > 1)
+                {
+                    if (propertyPanel.AnnotEvents == null)
+                        propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
+
+                    propertyPanel.AnnotEvents.Clear();
+
+                    foreach (var itemAnnot in annots)
+                    {
+                        var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
+                        propertyPanel.AnnotEvents.Add(eventitem);
+                    }
+                }
+
+                propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
+                if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
                 {
                     propertyPanel.AnnotEvent = annotAttribEvent;
                 }

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

@@ -21,6 +21,7 @@ namespace PDF_Office.ViewModels.Tools
     public class AnnotPropertyPanel
     {
         public AnnotAttribEvent AnnotEvent { get; set; }
+        public List<AnnotAttribEvent> AnnotEvents = new List<AnnotAttribEvent>();
         public AnnotHandlerEventArgs annot;
         public List<AnnotHandlerEventArgs> annotlists;
 

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

@@ -64,7 +64,8 @@
                     <RowDefinition Height="auto"/>
                     <RowDefinition/>
                 </Grid.RowDefinitions>
-                <CompositeControl:SlidContent x:Name="SlidOpacity" HorizontalAlignment="Right">
+                <CompositeControl:SlidContent x:Name="SlidOpacity" HorizontalAlignment="Right" 
+                                              Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedValueChanged">
                             <i:InvokeCommandAction Command="{Binding SelectedValueChangedCommand}" CommandParameter="{Binding ElementName=SlidOpacity,Path=Value}"/>