Pārlūkot izejas kodu

注释 - 高亮注释数值

chenrongqian 2 gadi atpakaļ
vecāks
revīzija
dfe456c74e

+ 70 - 51
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -17,27 +17,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
     
     public class TextAnnotPropertyViewModel:BindableBase, INavigationAware
     {
-      //  private ComPDFKitViewer.PdfViewer.CPDFViewer PDFViewer;
-        private AnnotHandlerEventArgs Annot;
-        private AnnotPropertyPanel PropertyPanel;
+     
 
         #region 属性
 
-        private double annotOpacity;
-        public double AnnotOpacity
-        {
-            get {return annotOpacity;}
-            set 
-            { 
-                SetProperty(ref annotOpacity, value);
-                SampleTextBg.Opacity = annotOpacity;
-                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
-                changeData[AnnotType] = annotOpacity;
-                PropertyPanel.DataChangedInvoke(this, changeData);
-            }
-        }
-
-
         private AnnotArgsType annotType;
         public AnnotArgsType AnnotType
         {
@@ -49,15 +32,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        /// <summary>
-        /// 示例背景
-        /// </summary>
-        private Brush sampleTextBg = new SolidColorBrush(Colors.Transparent);
-        public Brush SampleTextBg
-        {
-            get { return sampleTextBg; }
-            set { SetProperty(ref sampleTextBg, value); SetAnnotProperty(); }
-        }
 
         private string annotTypeTitle;
         public string AnnotTypeTitle
@@ -69,8 +43,31 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private Color selectColor;
-        public Color SelectColor
+
+        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); SetAnnotProperty(); }
+        }
+
+
+        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
+        public Brush SelectColor
         {
             get { return selectColor; }
             set { SetProperty(ref selectColor, value); SetAnnotProperty(); }
@@ -78,14 +75,17 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
         #endregion
 
-
+        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 TextAnnotPropertyViewModel()
         {
             SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
             OpacityItemCommand = new DelegateCommand<object>(OpacityItemCommand_Click);
+            OpacityValueChangedCommand = new DelegateCommand<object>(OpacityValueChanged_Command);
         }
 
         private void OpacityItemCommand_Click(object obj)
@@ -103,6 +103,22 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private void OpacityValueChanged_Command(object obj)
+        {
+            if (obj != null)
+            {
+                if (AnnotType == AnnotArgsType.AnnotHighlight)
+                    SampleTextBg.Opacity = annotOpacity;
+                else
+                    SelectColor.Opacity = annotOpacity;
+
+                SetAnnotProperty();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotType] = annotOpacity;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+        }
+
         public void SelectedColorChanged_Click(object color)
         {
             if (color != null)
@@ -110,30 +126,25 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 var colorValue = (Color)color;
                 if (colorValue != null)
                 {
-                    SampleTextBg = new SolidColorBrush(colorValue);
-                    switch(AnnotType)
+                   
+                    switch (AnnotType)
                     {
                         case AnnotArgsType.AnnotHighlight:
+                            SampleTextBg = new SolidColorBrush(colorValue);
                             SampleTextBg.Opacity = AnnotOpacity;
                             break;
                         case AnnotArgsType.AnnotUnderline:
-                            SampleTextBg.Opacity = AnnotOpacity;
-                            break;
                         case AnnotArgsType.AnnotStrikeout:
-                            SampleTextBg.Opacity = AnnotOpacity;
-                            break;
                         case AnnotArgsType.AnnotSquiggly:
-                            SampleTextBg.Opacity = AnnotOpacity;
-                            break;
                         case AnnotArgsType.AnnotSticky:
-                            SampleTextBg.Opacity = AnnotOpacity;
+                            SelectColor = new SolidColorBrush(colorValue);
+                            SelectColor.Opacity = AnnotOpacity;
                             break;
                     }
-                   
+
                     Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
                     changeData[AnnotType] = color;
                     PropertyPanel.DataChangedInvoke(this, changeData);
-                   // PropertyPanel.DataChanged?.Invoke(this, changeData);
                 }
             }
         }
@@ -179,10 +190,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if(PropertyPanel != null)
             {
                 Annot = PropertyPanel.annot;
-
+                AnnotType = Annot.EventType;
                 GetAnnotProperty();
             }
-            
 
         }
 
@@ -191,16 +201,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         {
             if (Annot != null)
             {
-                SampleTextBg = new SolidColorBrush(Colors.Transparent);
-
                 switch (Annot.EventType)
                 {
                     case AnnotArgsType.AnnotHighlight:
-                        if (Annot is TextHighlightAnnotArgs)
+                      if (Annot is TextHighlightAnnotArgs)
                         {
                             var Hightlight = Annot as TextHighlightAnnotArgs;
                             AnnotOpacity = Hightlight.Transparency;
-                            AnnotType = Hightlight.EventType;
                             SampleTextBg = new SolidColorBrush(Hightlight.Color);
 
                         }
@@ -210,8 +217,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         {
                             var Underline = Annot as TextUnderlineAnnotArgs;
                             AnnotOpacity = Underline.Transparency;
-                            AnnotType = Underline.EventType;
-                            SampleTextBg = new SolidColorBrush(Underline.Color);
+                             SampleTextBg = new SolidColorBrush(Colors.Transparent);
+                            SelectColor = new SolidColorBrush(Underline.Color);
                         }
                         break;
 
@@ -219,8 +226,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         {
                             var Squiggly = Annot as TextSquigglyAnnotArgs;
                             AnnotOpacity = Squiggly.Transparency;
-                            AnnotType = Squiggly.EventType;
-                            SampleTextBg = new SolidColorBrush(Squiggly.Color);
+                            SampleTextBg = new SolidColorBrush(Colors.Transparent);
+                            SelectColor = new SolidColorBrush(Squiggly.Color);
                         }
                         break;
 
@@ -256,6 +263,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                             if (Underline.Transparency != AnnotOpacity)
                                 Underline.Transparency = AnnotOpacity;
+
+                            var c = (SelectColor as SolidColorBrush).Color;
+                            if (Underline.Color.A != c.A || Underline.Color.B != c.B || Underline.Color.G != c.G || Underline.Color.R != c.R)
+                                Underline.Color = (SelectColor as SolidColorBrush).Color;
                         }
                         break;
 
@@ -264,6 +275,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             var Squiggly = Annot as TextSquigglyAnnotArgs;
                             if (Squiggly.Transparency != AnnotOpacity)
                                 AnnotOpacity = Squiggly.Transparency;
+
+                            var c = (SelectColor as SolidColorBrush).Color;
+                            if (Squiggly.Color.A != c.A || Squiggly.Color.B != c.B || Squiggly.Color.G != c.G || Squiggly.Color.R != c.R)
+                                Squiggly.Color = (SelectColor as SolidColorBrush).Color;
                         }
                         break;
 
@@ -272,6 +287,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             var Strikeout = Annot as TextStrikeoutAnnotArgs;
                             if (Strikeout.Transparency != AnnotOpacity)
                                 Strikeout.Transparency = AnnotOpacity;
+
+                            var c = (SelectColor as SolidColorBrush).Color;
+                            if (Strikeout.Color.A != c.A || Strikeout.Color.B != c.B || Strikeout.Color.G != c.G || Strikeout.Color.R != c.R)
+                                Strikeout.Color = (SelectColor as SolidColorBrush).Color;
                         }
                         break;
 

+ 69 - 2
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -28,6 +28,15 @@ namespace PDF_Office.ViewModels.Tools
         }
 
         private void InitDefaultValue()
+        {
+
+            InitAnnotHighlight();
+            InitAnnotUnderline();
+            InitAnnotSquiggly();
+            InitAnnotStrikeout();
+        }
+
+        private void InitAnnotHighlight()
         {
             DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
             if (annotProperty == null)
@@ -44,8 +53,66 @@ namespace PDF_Office.ViewModels.Tools
                 HighLightColor = new SolidColorBrush(annotProperty.BackgroundColor);
                 HighLightOpacity = annotProperty.Opacity;
             }
+        }
+
+
+        private void InitAnnotUnderline()
+        {
+            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
+            if (annotProperty == null)
+            {
+                annotProperty = new DefaultAnnotProperty();
+                annotProperty.AnnotToolType = AnnotArgsType.AnnotUnderline;
+                annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
+                annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
+                annotProperty.Opacity = 0.5;
+                SettingHelper.SetAnnotDefaultProperty(annotProperty);
+            }
+            else
+            {
+                UnderLineColor = new SolidColorBrush(annotProperty.BackgroundColor);
+                UnderLineOpacity = annotProperty.Opacity;
+            }
+        }
+
+        private void InitAnnotSquiggly()
+        {
+            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquiggly);
+            if (annotProperty == null)
+            {
+                annotProperty = new DefaultAnnotProperty();
+                annotProperty.AnnotToolType = AnnotArgsType.AnnotSquiggly;
+                annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
+                annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
+                annotProperty.Opacity = 0.5;
+                SettingHelper.SetAnnotDefaultProperty(annotProperty);
+            }
+            else
+            {
+                SquigglyColor = new SolidColorBrush(annotProperty.BackgroundColor);
+                SquigglyOpacity = annotProperty.Opacity;
+            }
+        }
 
+        private void InitAnnotStrikeout()
+        {
+            DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStrikeout);
+            if (annotProperty == null)
+            {
+                annotProperty = new DefaultAnnotProperty();
+                annotProperty.AnnotToolType = AnnotArgsType.AnnotStrikeout;
+                annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
+                annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
+                annotProperty.Opacity = 0.5;
+                SettingHelper.SetAnnotDefaultProperty(annotProperty);
+            }
+            else
+            {
+                StrikeoutColor = new SolidColorBrush(annotProperty.BackgroundColor);
+                StrikeoutOpacity = annotProperty.Opacity;
+            }
         }
+
         #endregion
 
 
@@ -427,9 +494,9 @@ namespace PDF_Office.ViewModels.Tools
         {
             if (string.IsNullOrEmpty(toolTag) == false)
             {
-                if (!ToolExpandDict.ContainsKey("HighLight"))
+                if (!ToolExpandDict.ContainsKey(toolTag))
                 {
-                    ToolExpandDict["HighLight"] = true;
+                    ToolExpandDict[toolTag] = true;
                 }
             }
 

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

@@ -152,6 +152,39 @@ namespace PDF_Office.ViewModels.Tools
                                 HighLightOpacity = (double)e[argsType];
                             }
                             break;
+
+                        case AnnotArgsType.AnnotUnderline:
+                            if (e[argsType] is Color)
+                            {
+                                UnderLineColor = new SolidColorBrush((Color)e[argsType]);
+                            }
+                            if (e[argsType] is double)
+                            {
+                                underLineOpacity = (double)e[argsType];
+                            }
+                            break;
+
+                        case AnnotArgsType.AnnotSquiggly:
+                            if (e[argsType] is Color)
+                            {
+                                SquigglyColor = new SolidColorBrush((Color)e[argsType]);
+                            }
+                            if (e[argsType] is double)
+                            {
+                                SquigglyOpacity = (double)e[argsType];
+                            }
+                            break;
+
+                        case AnnotArgsType.AnnotStrikeout:
+                            if (e[argsType] is Color)
+                            {
+                                StrikeoutColor = new SolidColorBrush((Color)e[argsType]);
+                            }
+                            if (e[argsType] is double)
+                            {
+                                StrikeoutOpacity = (double)e[argsType];
+                            }
+                            break;
                     }
                 }
             }

+ 10 - 4
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml

@@ -32,17 +32,17 @@
                              Background="{Binding SampleTextBg}" 
                                >
                     </TextBlock>
-                    <Path Name="UnderlinePath" HorizontalAlignment="Center" StrokeThickness="2" Margin="0,51,0,0" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotUnderline}">
+                    <Path Name="UnderlinePath" HorizontalAlignment="Center" StrokeThickness="2" Margin="0,51,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,40,0,0" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotStrikeout}">
+                    <Path Name="StrikeoutPath" HorizontalAlignment="Center" StrokeThickness="2" Margin="0,40,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" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotSquiggly}">
+                    <Path Name="SquigglyPath"  HorizontalAlignment="Center" StrokeThickness="2" Margin="0,51,0,0" Stroke="{Binding SelectColor}" Visibility="{Binding AnnotType,Converter={StaticResource AnnotArgsTypeConverter},ConverterParameter=AnnotSquiggly}">
 
                     </Path>
 
@@ -73,12 +73,18 @@
                 </Grid.ColumnDefinitions>
                 <Slider Name="OpacitySlider" HorizontalAlignment="Left" VerticalAlignment="Center" Minimum="0" Maximum="1" IsSelectionRangeEnabled="True" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True"
                      Value="{Binding AnnotOpacity}"
-                    Style="{StaticResource RoundThumbSlider}" Width="148" TickFrequency="0.01" ValueChanged="OpacitySlider_ValueChanged" Thumb.DragStarted="OpacitySlider_DragStarted" 
+                    Style="{StaticResource RoundThumbSlider}" Width="148" TickFrequency="0.01" Thumb.DragStarted="OpacitySlider_DragStarted" 
                     Thumb.DragCompleted="OpacitySlider_DragCompleted">
                     <Slider.Resources>
                         <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
                         <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
                     </Slider.Resources>
+
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="ValueChanged">
+                            <i:InvokeCommandAction Command="{Binding OpacityValueChangedCommand}" CommandParameter="75"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
                 </Slider>
 
                 <Border Grid.Column="1" HorizontalAlignment="Right" Background="Transparent" BorderBrush="#E2E3E6"  Width="80" Height="32"  BorderThickness="0">