Forráskód Böngészése

注释 - 保留上次注释属性值

chenrongqian@kdanmobile.com 1 éve
szülő
commit
1c616b6636

+ 12 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -24,6 +24,7 @@ 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)
@@ -54,6 +55,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
     public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         #region 属性
+        private string _strShapeChecked = "";
+
+        public string StrShapeChecked
+        {
+            get { return _strShapeChecked; }
+            set
+            {
+                SetProperty(ref _strShapeChecked, value);
+            }
+        }
         public List<ComboDataItem> ThicknessItems { get; protected set; }
 
         private AnnotCommon _basicVm = new AnnotCommon();
@@ -231,6 +242,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if (isFromToolsBtn == false)
                 PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
 
+            StrShapeChecked = tag;
             BasicVm.SetOtherTag(tag);
         }
 

+ 29 - 3
PDF Office/ViewModels/Tools/AnnotManager/AnnotTransfer.cs

@@ -1,4 +1,5 @@
-using ComPDFKitViewer;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using System;
 using System.Collections.Generic;
@@ -25,6 +26,8 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
         public AnnotHandlerEventArgs annot;
         public List<AnnotHandlerEventArgs> annotlists;
 
+        public Dictionary<AnnotArgsType, AnnotHandlerEventArgs> LastAnnotDict = new Dictionary<AnnotArgsType, AnnotHandlerEventArgs>();
+        public AnnotHandlerEventArgs LastArrowAnnot = null;
         //是否为填写与签名的日期文本
         public bool IsTextFill { get; private set; }
 
@@ -37,8 +40,31 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
         { get { return (annotlists != null && annotlists.Count > 1); } }
 
         public AnnotTransfer()
-        { 
-        
+        {
+            LastAnnotDict.Add(AnnotArgsType.AnnotHighlight, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotUnderline, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotStrikeout, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotFreehand, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotFreeText, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotSticky, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotSquare, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotCircle, null);
+            LastAnnotDict.Add(AnnotArgsType.AnnotLine, null);
+        }
+
+        public void SaveLastAnnot()
+        {
+            if(annot.EventType == AnnotArgsType.AnnotLine)
+            {
+                var lineAnnotArgs = annot as LineAnnotArgs;
+                if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
+                {
+                    LastArrowAnnot = annot;
+                    return;
+                }
+            }
+
+            LastAnnotDict[annot.EventType] = annot;
         }
 
         #region 静态

+ 2 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -1011,6 +1011,8 @@ namespace PDF_Office.ViewModels.Tools
                         PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
                         PDFViewer.SetToolParam(annotArgs);
                     }
+
+                    propertyPanel.SaveLastAnnot();
                     ShowPropertyPanel();
                 }
             }

+ 237 - 159
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -281,32 +281,39 @@ namespace PDF_Office.ViewModels.Tools
             if (annotArgs != null)
                 annotArgs.Author = Settings.Default.AppProperties.Description.Author;
         }
-
+       
+        //创建,选中,保留上次属性值的注释
         /// <summary>
         /// 高亮注释
         /// </summary>
         private AnnotHandlerEventArgs GetHighLight(List<AnnotHandlerEventArgs> selectedArgs = null)
         {
             TextHighlightAnnotArgs highlightArgs = null;
-
             if (selectedArgs == null || selectedArgs.Count == 0)
             {
                 highlightArgs = new TextHighlightAnnotArgs();
                 highlightArgs.Transparency = highLightOpacity;
                 highlightArgs.Color = (highLightColor as SolidColorBrush).Color;
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(highlightArgs.EventType);
-                if (defaultAnnot == null)
+                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotHighlight] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = highlightArgs.EventType;
-                    defaultAnnot.ForgoundColor = (highLightColor as SolidColorBrush).Color;
-                    defaultAnnot.Opacity = 1;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(highlightArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = highlightArgs.EventType;
+                        defaultAnnot.ForgoundColor = (highLightColor as SolidColorBrush).Color;
+                        defaultAnnot.Opacity = 1;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
+
+                    highLightOpacity = highlightArgs.Transparency = defaultAnnot.Opacity;
                 }
+                else
+                {
 
-                highLightOpacity = highlightArgs.Transparency = defaultAnnot.Opacity;
+                }
 
                 selectedArgs = new List<AnnotHandlerEventArgs>();
                 selectedArgs.Add(highlightArgs);
@@ -360,19 +367,21 @@ namespace PDF_Office.ViewModels.Tools
                 underlineArgs = new TextUnderlineAnnotArgs();
                 underlineArgs.Transparency = UnderLineOpacity;
                 underlineArgs.Color = (UnderLineColor as SolidColorBrush).Color;
-
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(underlineArgs.EventType);
-                if (defaultAnnot == null)
+                if(propertyPanel.LastAnnotDict[AnnotArgsType.AnnotUnderline] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = underlineArgs.EventType;
-                    defaultAnnot.ForgoundColor = (UnderLineColor as SolidColorBrush).Color;
-                    defaultAnnot.Opacity = 1;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(underlineArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = underlineArgs.EventType;
+                        defaultAnnot.ForgoundColor = (UnderLineColor as SolidColorBrush).Color;
+                        defaultAnnot.Opacity = 1;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                UnderLineOpacity = underlineArgs.Transparency = defaultAnnot.Opacity;
+                    UnderLineOpacity = underlineArgs.Transparency = defaultAnnot.Opacity;
+                }
 
                 selectedArgs = new List<AnnotHandlerEventArgs>();
                 selectedArgs.Add(underlineArgs);
@@ -401,18 +410,21 @@ namespace PDF_Office.ViewModels.Tools
                 squigglyArgs.Transparency = SquigglyOpacity;
                 squigglyArgs.Color = (squigglyColor as SolidColorBrush).Color;
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squigglyArgs.EventType);
-                if (defaultAnnot == null)
+                if(propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquiggly] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = squigglyArgs.EventType;
-                    defaultAnnot.ForgoundColor = (squigglyColor as SolidColorBrush).Color;
-                    defaultAnnot.Opacity = 1;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squigglyArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = squigglyArgs.EventType;
+                        defaultAnnot.ForgoundColor = (squigglyColor as SolidColorBrush).Color;
+                        defaultAnnot.Opacity = 1;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                SquigglyOpacity = squigglyArgs.Transparency = defaultAnnot.Opacity;
+                    SquigglyOpacity = squigglyArgs.Transparency = defaultAnnot.Opacity;
+                }
 
                 selectedArgs = new List<AnnotHandlerEventArgs>();
                 selectedArgs.Add(squigglyArgs);
@@ -441,18 +453,22 @@ namespace PDF_Office.ViewModels.Tools
                 strikeoutArgs.Transparency = strikeoutOpacity;
                 strikeoutArgs.Color = (strikeoutColor as SolidColorBrush).Color;
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(strikeoutArgs.EventType);
-                if (defaultAnnot == null)
+                if(propertyPanel.LastAnnotDict[AnnotArgsType.AnnotStrikeout] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = strikeoutArgs.EventType;
-                    defaultAnnot.ForgoundColor = (strikeoutColor as SolidColorBrush).Color;
-                    defaultAnnot.Opacity = 1;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(strikeoutArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = strikeoutArgs.EventType;
+                        defaultAnnot.ForgoundColor = (strikeoutColor as SolidColorBrush).Color;
+                        defaultAnnot.Opacity = 1;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                strikeoutArgs.Transparency = defaultAnnot.Opacity;
+                    strikeoutArgs.Transparency = defaultAnnot.Opacity;
+                }
+       
 
                 selectedArgs = new List<AnnotHandlerEventArgs>();
                 selectedArgs.Add(strikeoutArgs);
@@ -488,37 +504,45 @@ namespace PDF_Office.ViewModels.Tools
                     freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
                 }
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freehandArgs.EventType);
-                if (defaultAnnot == null)
+                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = freehandArgs.EventType;
-                    defaultAnnot.ForgoundColor = annotate.FreeHandColor;
-                    defaultAnnot.Opacity = 1;
-                    defaultAnnot.Thickness = 2;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
 
-                freehandArgs.Transparency = defaultAnnot.Opacity;
-                freehandArgs.LineWidth = defaultAnnot.Thickness;
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freehandArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = freehandArgs.EventType;
+                        defaultAnnot.ForgoundColor = annotate.FreeHandColor;
+                        defaultAnnot.Opacity = 1;
+                        defaultAnnot.Thickness = 2;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
-                {
-                    freehandArgs.LineDash = DashStyles.Solid;
-                }
-                else
-                {
-                    var collect = new DoubleCollection();
-                    foreach (var item in defaultAnnot.DashArray)
+                    freehandArgs.Transparency = defaultAnnot.Opacity;
+                    freehandArgs.LineWidth = defaultAnnot.Thickness;
+
+                    if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
                     {
-                        collect.Add(item);
+                        freehandArgs.LineDash = DashStyles.Solid;
                     }
+                    else
+                    {
+                        var collect = new DoubleCollection();
+                        foreach (var item in defaultAnnot.DashArray)
+                        {
+                            collect.Add(item);
+                        }
 
-                    if (freehandArgs.LineDash == null)
-                        freehandArgs.LineDash = new DashStyle();
+                        if (freehandArgs.LineDash == null)
+                            freehandArgs.LineDash = new DashStyle();
 
-                    freehandArgs.LineDash.Dashes = collect;
+                        freehandArgs.LineDash.Dashes = collect;
+                    }
+                }
+                else
+                {
+                    freehandArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] as FreehandAnnotArgs;
                 }
 
                 selectedArgs = new List<AnnotHandlerEventArgs>();
@@ -561,45 +585,55 @@ namespace PDF_Office.ViewModels.Tools
                     freetextArgs.FontColor = Colors.Black;
                 }
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freetextArgs.EventType);
-                if (defaultAnnot == null)
+                if(propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreeText] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = freetextArgs.EventType;
-                    defaultAnnot.ForgoundColor = freetextArgs.FontColor;
-                    defaultAnnot.BorderColor = Colors.Transparent;
-                    defaultAnnot.BackgroundColor = Colors.Transparent;
-                    defaultAnnot.Opacity = 1;
-                    defaultAnnot.FontFamily = Settings.Default.AppProperties.Annotate.TextFontFamaily;
-                    defaultAnnot.FontSize = 14;
-                    defaultAnnot.TextAlign = TextAlignment.Left;
-                    defaultAnnot.Thickness = 0;
-                    defaultAnnot.NoteText = string.Empty;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freetextArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = freetextArgs.EventType;
+                        defaultAnnot.ForgoundColor = freetextArgs.FontColor;
+                        defaultAnnot.BorderColor = Colors.Transparent;
+                        defaultAnnot.BackgroundColor = Colors.Transparent;
+                        defaultAnnot.Opacity = 1;
+                        defaultAnnot.FontFamily = Settings.Default.AppProperties.Annotate.TextFontFamaily;
+                        defaultAnnot.FontSize = 14;
+                        defaultAnnot.TextAlign = TextAlignment.Left;
+                        defaultAnnot.Thickness = 0;
+                        defaultAnnot.NoteText = string.Empty;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                freetextArgs.FontColor = defaultAnnot.ForgoundColor;
-                freetextArgs.LineColor = defaultAnnot.BorderColor;
-                freetextArgs.BgColor = defaultAnnot.BackgroundColor;
-                freetextArgs.Transparency = defaultAnnot.Opacity;
-                freetextArgs.FontFamily = new FontFamily(defaultAnnot.FontFamily);
-                freetextArgs.FontSize = defaultAnnot.FontSize;
-                freetextArgs.FontWeight = defaultAnnot.FontWeight;
-                freetextArgs.FontStyle = defaultAnnot.FontStyle;
-                freetextArgs.LineWidth = defaultAnnot.Thickness;
+                    freetextArgs.FontColor = defaultAnnot.ForgoundColor;
+                    freetextArgs.LineColor = defaultAnnot.BorderColor;
+                    freetextArgs.BgColor = defaultAnnot.BackgroundColor;
+                    freetextArgs.Transparency = defaultAnnot.Opacity;
+                    freetextArgs.FontFamily = new FontFamily(defaultAnnot.FontFamily);
+                    freetextArgs.FontSize = defaultAnnot.FontSize;
+                    freetextArgs.FontWeight = defaultAnnot.FontWeight;
+                    freetextArgs.FontStyle = defaultAnnot.FontStyle;
+                    freetextArgs.LineWidth = defaultAnnot.Thickness;
+
+                    int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
+
+                    if (align == 0)
+                        textAlignment = TextAlignment.Left;
+                    else if (align == 1)
+                        textAlignment = TextAlignment.Center;
+                    else
+                        textAlignment = TextAlignment.Right;
 
-                int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
+                    freetextArgs.Align = textAlignment;
 
-                if (align == 0)
-                    textAlignment = TextAlignment.Left;
-                else if (align == 1)
-                    textAlignment = TextAlignment.Center;
-                else
-                    textAlignment = TextAlignment.Right;
 
-                freetextArgs.Align = textAlignment;
+                }
+                else
+                {
+                    freetextArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreeText] as FreeTextAnnotArgs;
+                }
 
+                
                 if (freetextArgs != null)
                 {
                     selectedArgs = new List<AnnotHandlerEventArgs>();
@@ -671,18 +705,25 @@ namespace PDF_Office.ViewModels.Tools
                     stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
                 }
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(stickyAnnotArgs.EventType);
-                if (defaultAnnot == null)
+                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSticky] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = stickyAnnotArgs.EventType;
-                    defaultAnnot.NoteText = string.Empty;
-                    defaultAnnot.Opacity = 1;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(stickyAnnotArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = stickyAnnotArgs.EventType;
+                        defaultAnnot.NoteText = string.Empty;
+                        defaultAnnot.Opacity = 1;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                stickyAnnotArgs.Transparency = defaultAnnot.Opacity;
+                    stickyAnnotArgs.Transparency = defaultAnnot.Opacity;
+                }
+                else
+                {
+                    stickyAnnotArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSticky] as StickyAnnotArgs;
+                }
 
                 if (stickyAnnotArgs != null)
                 {
@@ -727,6 +768,9 @@ namespace PDF_Office.ViewModels.Tools
                     squareArgs.BgColor = Colors.Red;
                 }
 
+                if(propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare] == null)
+                { 
+
                 var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squareArgs.EventType);
                 if (defaultAnnot == null)
                 {
@@ -759,6 +803,13 @@ namespace PDF_Office.ViewModels.Tools
                     squareArgs.LineDash.Dashes = collect;
                 }
 
+                }
+                else
+                {
+                    squareArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare] as SquareAnnotArgs;
+                }
+
+
                 if (squareArgs != null)
                 {
                     selectedArgs = new List<AnnotHandlerEventArgs>();
@@ -798,40 +849,49 @@ namespace PDF_Office.ViewModels.Tools
                     circleAnnotArgs.BgColor = Colors.Red;
                 }
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(circleAnnotArgs.EventType);
-                if (defaultAnnot == null)
+                if(propertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle] == null)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = circleAnnotArgs.EventType;
-                    defaultAnnot.Thickness = 1;
-                    defaultAnnot.Opacity = 1;
-                    defaultAnnot.NoteText = string.Empty;
-                    defaultAnnot.DashArray = null;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(circleAnnotArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = circleAnnotArgs.EventType;
+                        defaultAnnot.Thickness = 1;
+                        defaultAnnot.Opacity = 1;
+                        defaultAnnot.NoteText = string.Empty;
+                        defaultAnnot.DashArray = null;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                circleAnnotArgs.LineWidth = defaultAnnot.Thickness;
-                circleAnnotArgs.Transparency = defaultAnnot.Opacity;
+                    circleAnnotArgs.LineWidth = defaultAnnot.Thickness;
+                    circleAnnotArgs.Transparency = defaultAnnot.Opacity;
 
-                if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
-                {
-                    circleAnnotArgs.LineDash = DashStyles.Solid;
-                }
-                else
-                {
-                    var collect = new DoubleCollection();
-                    foreach (var item in defaultAnnot.DashArray)
+                    if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
                     {
-                        collect.Add(item);
+                        circleAnnotArgs.LineDash = DashStyles.Solid;
                     }
+                    else
+                    {
+                        var collect = new DoubleCollection();
+                        foreach (var item in defaultAnnot.DashArray)
+                        {
+                            collect.Add(item);
+                        }
 
-                    if (circleAnnotArgs.LineDash == null)
-                        circleAnnotArgs.LineDash = new DashStyle();
+                        if (circleAnnotArgs.LineDash == null)
+                            circleAnnotArgs.LineDash = new DashStyle();
 
-                    circleAnnotArgs.LineDash.Dashes = collect;
+                        circleAnnotArgs.LineDash.Dashes = collect;
+                    }
+
+                }
+                else
+                {
+                    circleAnnotArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle] as CircleAnnotArgs;
                 }
 
+
                 if (circleAnnotArgs != null)
                 {
                     selectedArgs = new List<AnnotHandlerEventArgs>();
@@ -870,48 +930,66 @@ namespace PDF_Office.ViewModels.Tools
                 }
                 lineArgs.LineColor = Colors.Red;
                 lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
+                bool isLastAnnot = false;
                 if (TagStr == "Line")
                 {
                     lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
+                    isLastAnnot = (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine] != null ? true : false);
                 }
                 else
                 {
                     lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
+                    isLastAnnot = (propertyPanel.LastArrowAnnot != null ? true : false);
                 }
 
-                var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(lineArgs.EventType);
-                if (defaultAnnot == null)
+                if(isLastAnnot == false)
                 {
-                    defaultAnnot = new DefaultAnnotProperty();
-                    defaultAnnot.AnnotToolType = lineArgs.EventType;
-                    defaultAnnot.Thickness = 1;
-                    defaultAnnot.Opacity = 1;
-                    defaultAnnot.NoteText = string.Empty;
-                    defaultAnnot.DashArray = null;
-                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
-                    Settings.Default.Save();
-                }
-
-                lineArgs.LineDash = DashStyles.Solid;
-                lineArgs.LineWidth = defaultAnnot.Thickness;
-                lineArgs.Transparency = defaultAnnot.Opacity;
+                    var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(lineArgs.EventType);
+                    if (defaultAnnot == null)
+                    {
+                        defaultAnnot = new DefaultAnnotProperty();
+                        defaultAnnot.AnnotToolType = lineArgs.EventType;
+                        defaultAnnot.Thickness = 1;
+                        defaultAnnot.Opacity = 1;
+                        defaultAnnot.NoteText = string.Empty;
+                        defaultAnnot.DashArray = null;
+                        SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
+                        Settings.Default.Save();
+                    }
 
-                if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
-                {
                     lineArgs.LineDash = DashStyles.Solid;
+                    lineArgs.LineWidth = defaultAnnot.Thickness;
+                    lineArgs.Transparency = defaultAnnot.Opacity;
+
+                    if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
+                    {
+                        lineArgs.LineDash = DashStyles.Solid;
+                    }
+                    else
+                    {
+                        var collect = new DoubleCollection();
+                        foreach (var item in defaultAnnot.DashArray)
+                        {
+                            collect.Add(item);
+                        }
+
+                        if (lineArgs.LineDash == null)
+                            lineArgs.LineDash = new DashStyle();
+
+                        lineArgs.LineDash.Dashes = collect;
+                    }
+
                 }
                 else
                 {
-                    var collect = new DoubleCollection();
-                    foreach (var item in defaultAnnot.DashArray)
+                    if (lineArgs.TailLineType == C_LINE_TYPE.LINETYPE_ARROW)
                     {
-                        collect.Add(item);
+                        lineArgs = propertyPanel.LastArrowAnnot as LineAnnotArgs;
+                    }
+                    else
+                    {
+                        lineArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine] as LineAnnotArgs;
                     }
-
-                    if (lineArgs.LineDash == null)
-                        lineArgs.LineDash = new DashStyle();
-
-                    lineArgs.LineDash.Dashes = collect;
                 }
 
                 if (lineArgs != null)

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

@@ -176,7 +176,7 @@ namespace PDF_Office.ViewModels.Tools
             {
                 MyToolCheckedDoing(dictVar, tag);
                 FindAnnotTypeKey(tag, ref annotArgs);
-
+                propertyPanel.SaveLastAnnot();
                 if (annotArgs != null)
                 {
                     //设置点击页面会创建对应选中注释工具的注释

+ 18 - 20
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -11,6 +11,7 @@
     xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:prism="http://prismlibrary.com/"
+    xmlns:convert="clr-namespace:PDF_Office.Views.Tools"
     d:DesignHeight="450"
     d:DesignWidth="260"
     Background="{StaticResource color.sys.layout.mg}"
@@ -24,6 +25,7 @@
             </ResourceDictionary.MergedDictionaries>
             <Convert:ColorToBrushConverter x:Key="ColorToBrushConvert" />
             <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert" />
+            <convert:AnnotToolIsCheckedConvert x:Key="AnnotToolIsCheckedConvert"/>
             <DashConvert:DashStyleConverter x:Key="DashStyleConverter" />
             <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
             <Style x:Key="line1Style" TargetType="{x:Type Line}">
@@ -115,6 +117,9 @@
                     <RadioButton x:Name="SharpRectBtn" Tag="Rect" GroupName="Shape"
                                  Width="32" Height="32" Margin="0,0" ToolTip="矩形" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
+                                 Command="{Binding SharpsTypeCommand}"
+                                 CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}"
+                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Rect}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Rectangle
@@ -124,16 +129,15 @@
                                 VerticalAlignment="Center"
                                 Stroke="#273C62" />
                         </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>
 
                     <RadioButton x:Name="SharpCircleBtn" Tag="Circle" GroupName="Shape"  Grid.Column="1"
                                  Width="32" Height="32" Margin="0,0" ToolTip="圆" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
+                                 Command="{Binding SharpsTypeCommand}"
+                                 CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}"
+                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Circle}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Ellipse
@@ -143,16 +147,15 @@
                                 VerticalAlignment="Center"
                                 Stroke="#273C62" />
                         </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>
 
                     <RadioButton x:Name="SharpArrowBtn" Tag="Arrow" GroupName="Shape"  Grid.Column="2"
                                  Width="32" Height="32" Margin="0,0" ToolTip="箭头" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
+                                 Command="{Binding SharpsTypeCommand}" 
+                                 CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}"
+                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Arrow}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Path
@@ -166,16 +169,15 @@
                                 </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>
 
                     <RadioButton x:Name="SharpLineBtn" Tag="Line" GroupName="Shape"  Grid.Column="3"
                                  Width="32" Height="32" Margin="0,0" ToolTip="线条" Padding="7,0,0,0"
                                  VerticalContentAlignment="Center" Background="Transparent"
+                                 Command="{Binding SharpsTypeCommand}" 
+                                 CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}"
+                                 IsChecked="{Binding StrShapeChecked,Converter={StaticResource AnnotToolIsCheckedConvert},ConverterParameter=Line}"
                                  Style="{DynamicResource GreyBgRadioBtnStyle}">
                         <RadioButton.Content>
                             <Polygon
@@ -189,11 +191,7 @@
                                 </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>