OYXH\oyxh 1 rok temu
rodzic
commit
3794b635fd

+ 11 - 5
PDF Office/CustomControl/CompositeControl/CustomComboControl.xaml

@@ -2,6 +2,7 @@
     x:Class="PDF_Master.CustomControl.CompositeControl.CustomComboControl"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:convert="clr-namespace:PDF_Master.DataConvert"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:local="clr-namespace:PDF_Master.CustomControl.CompositeControl"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -16,14 +17,19 @@
                 <ResourceDictionary Source="../../Styles/SliderStyle.xaml" />
                 <ResourceDictionary Source="../../Styles/CustomBtnStyle.xaml" />
             </ResourceDictionary.MergedDictionaries>
-
+            <convert:BoolToVisible x:Key="BoolToVisible" />
             <DataTemplate x:Key="numberData">
-                <Grid>
+                <StackPanel Orientation="Horizontal">
+                    <!--<TextBlock
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Center"
+                    Text="*"
+                    Visibility="{Binding NeedFrontTag, Converter={StaticResource BoolToVisible}}" />-->
                     <TextBlock
                         HorizontalAlignment="Center"
                         VerticalAlignment="Center"
                         Text="{Binding Content}" />
-                </Grid>
+                </StackPanel>
             </DataTemplate>
         </ResourceDictionary>
     </UserControl.Resources>
@@ -47,6 +53,7 @@
                         BorderThickness="1"
                         ItemTemplate="{StaticResource numberData}"
                         MaxDropDownHeight="200" />
+
                     <TextBox
                         Name="title"
                         Height="20"
@@ -62,5 +69,4 @@
             </Border>
         </Grid>
     </Grid>
-
-</UserControl>
+</UserControl>

+ 72 - 31
PDF Office/CustomControl/CompositeControl/CustomComboControl.xaml.cs

@@ -21,67 +21,100 @@ namespace PDF_Master.CustomControl.CompositeControl
     //SetItemSource(List<ComboDataItem> items)更换集合List
     //默认:字体集合、IsValueContent为false、Value作为集合某项的值
 
-
     public class ComboDataItem : Prism.Mvvm.BindableBase
     {
+        //private bool needFrontTag = false;
+
+        //public bool NeedFrontTag
+        //{
+        //    get { return needFrontTag; }
+        //    set
+        //    {
+        //        SetProperty(ref needFrontTag, value);
+        //    }
+        //}
+
         //字符串类型的值
         public string ValueStr { get; private set; }
+
         //数字类型的值
         public double Value { get; private set; }
+
         //public string Content { get; private set; }
         //下拉框显示的内容
         private string _content = "";
+
         public string Content
         {
             get { return _content; }
             private set { SetProperty(ref _content, value); }
         }
+
         //下拉框显示的内容+单位:限数字值的单位
         public string Unit { get; private set; }
+
         //数字类型
         public ComboDataItem(double value, string unitStr = "")
         {
             Content = value + unitStr;
             Value = value;
         }
+
         //字符串类型
         public ComboDataItem(string valueStr, string contentStr = "")
         {
             Content = contentStr;
             ValueStr = valueStr;
+            //this.NeedFrontTag = needFrontTag;
         }
 
         public void SetContent(string content)
         {
             Content = content;
         }
-
     }
+
     /// <summary>
     /// CustomComboControl.xaml 的交互逻辑
     /// </summary>
     public partial class CustomComboControl : UserControl
     {
         public List<ComboDataItem> Items { get; private set; }
+
         public event RoutedEventHandler ValueChanged;
 
+        //private string titleStr;
+
+        //public string Title
+        //{
+        //    get
+        //    {
+        //        titleStr = title.Text;
+        //        return titleStr;
+        //    }
+        //    set
+        //    {
+        //        title.Text = titleStr;
+        //    }
+        //}
+
         public CustomComboControl()
         {
             InitializeComponent();
             Items = new List<ComboDataItem>();
             DefaultItems();
         }
+
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
             comBox.SelectionChanged -= comBox_SelectionChanged;
             comBox.SelectionChanged += comBox_SelectionChanged;
         }
 
-
         //更换集合
         public void SetItemSource(List<ComboDataItem> items)
         {
-            SelectedIndex = - 1;//为了触发SelectedIndex
+            SelectedIndex = -1;//为了触发SelectedIndex
             Items = items;
             ItemSource = Items;
         }
@@ -112,7 +145,7 @@ namespace PDF_Master.CustomControl.CompositeControl
             Items.Add(item);
             ItemSource = Items;
         }
- 
+
         //下拉框选中项
         private void comBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
@@ -127,16 +160,12 @@ namespace PDF_Master.CustomControl.CompositeControl
                     Value = item.Value;
                     ValueChanged?.Invoke(Value, null);
                 }
-                    
                 else
                 {
                     ValueStr = item.ValueStr;
                     ValueChanged?.Invoke(ValueStr, null);
                 }
-
             }
-
-
         }
 
         //在外部判断值是否存在于下拉框里
@@ -193,6 +222,26 @@ namespace PDF_Master.CustomControl.CompositeControl
             set { SetValue(SelectedItemsProperty, value); }
         }
 
+        //标题
+        public string Title
+        {
+            get { return (string)GetValue(TitleProperty); }
+            set { SetValue(TitleProperty, value); }
+        }
+
+        public static readonly DependencyProperty TitleProperty =
+        DependencyProperty.Register("Title", typeof(string), typeof(CustomComboControl), new PropertyMetadata("", TitlePropertyChanged));
+
+        private static void TitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            var control = d as CustomComboControl;
+            var title = (string)e.NewValue;
+            if (control != null)
+            {
+                control.title.Text = title;
+            }
+        }
+
         //外部需要下拉框都不选中时,true为不选中,false为正常选中
         public bool IsSelectedEmpty
         {
@@ -201,34 +250,32 @@ namespace PDF_Master.CustomControl.CompositeControl
         }
 
         public static readonly DependencyProperty IsSelectedEmptyProperty =
-    DependencyProperty.Register("IsSelectedEmpty", typeof(bool), typeof(CustomComboControl), new PropertyMetadata(false, IsSelectedEmptyPropertyChanged));
-
+        DependencyProperty.Register("IsSelectedEmpty", typeof(bool), typeof(CustomComboControl), new PropertyMetadata(false, IsSelectedEmptyPropertyChanged));
 
         public static readonly DependencyProperty SelectedItemsProperty =
-         DependencyProperty.Register("SelectedItems", typeof(ComboDataItem), typeof(CustomComboControl), new PropertyMetadata(null, SelectedItemsPropertyChanged));
-
+        DependencyProperty.Register("SelectedItems", typeof(ComboDataItem), typeof(CustomComboControl), new PropertyMetadata(null, SelectedItemsPropertyChanged));
 
         public static readonly DependencyProperty ValueProperty =
-           DependencyProperty.Register("Value", typeof(double), typeof(CustomComboControl), new PropertyMetadata(1.0));
+        DependencyProperty.Register("Value", typeof(double), typeof(CustomComboControl), new PropertyMetadata(1.0));
 
         public static readonly DependencyProperty ValueStrProperty =
-         DependencyProperty.Register("ValueStr", typeof(string), typeof(CustomComboControl), new PropertyMetadata(""));
+        DependencyProperty.Register("ValueStr", typeof(string), typeof(CustomComboControl), new PropertyMetadata(""));
 
         public static readonly DependencyProperty ItemSourceProperty =
-          DependencyProperty.Register("ItemSource", typeof(List<ComboDataItem>), typeof(CustomComboControl), new PropertyMetadata(null, SelectedItemSourcePropertyChanged));
+        DependencyProperty.Register("ItemSource", typeof(List<ComboDataItem>), typeof(CustomComboControl), new PropertyMetadata(null, SelectedItemSourcePropertyChanged));
 
         public static readonly DependencyProperty SelectedIndexProperty =
         DependencyProperty.Register("SelectedIndex", typeof(int), typeof(CustomComboControl), new PropertyMetadata(-1, SelectedIndexPropertyChanged));
 
         public static readonly DependencyProperty IsValueContentProperty =
-          DependencyProperty.Register("IsValueContent", typeof(bool), typeof(CustomComboControl), new PropertyMetadata(false));
+        DependencyProperty.Register("IsValueContent", typeof(bool), typeof(CustomComboControl), new PropertyMetadata(false));
 
         //集合绑定下拉框 SelectedItems触发属性
         private static void IsSelectedEmptyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
             var control = d as CustomComboControl;
             var isSelectedEmpty = (bool)e.NewValue;
-            if(control != null)
+            if (control != null)
             {
                 //弃用:IsSelectedEmpty属性,可用SelectedItems == null来处理下拉框不选中的情况。
 
@@ -241,7 +288,6 @@ namespace PDF_Master.CustomControl.CompositeControl
                 //}
             }
         }
-        
 
         private static void SelectedItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
@@ -249,7 +295,7 @@ namespace PDF_Master.CustomControl.CompositeControl
             var selectedItems = (ComboDataItem)e.NewValue;
             if (control != null /* && control.IsSelectedEmpty == false*/)
             {
-                if(selectedItems != null)
+                if (selectedItems != null)
                 {
                     if (control.comBox.Items != null && control.comBox.Items.Count > 0)
                     {
@@ -280,10 +326,9 @@ namespace PDF_Master.CustomControl.CompositeControl
                         if (temp != null)
                             index = control.Items.IndexOf(temp);
 
-
                         if (index >= 0)
                         {
-                            if(control.SelectedIndex != index)
+                            if (control.SelectedIndex != index)
                             {
                                 control.SelectedIndex = index;
                             }
@@ -292,10 +337,8 @@ namespace PDF_Master.CustomControl.CompositeControl
                         }
                         else
                             control.title.Text = selectedItems.Content;
-
                     }
                 }
-
                 else
                 {
                     control.comBox.SelectedItem = null;
@@ -303,10 +346,7 @@ namespace PDF_Master.CustomControl.CompositeControl
                     control.SelectedItems = null;
                     control.title.Text = "";
                 }
-              
-
             }
-            
         }
 
         //集合绑定下拉框Itemsource触发属性
@@ -330,10 +370,10 @@ namespace PDF_Master.CustomControl.CompositeControl
             var selectedIndex = (int)e.NewValue;
             if (control != null /*&& control.IsSelectedEmpty == false*/)
             {
-                if(control.comBox.Items != null && control.comBox.Items.Count > 0 && selectedIndex != -1)
+                if (control.comBox.Items != null && control.comBox.Items.Count > 0 && selectedIndex != -1)
                 {
                     control.comBox.SelectedIndex = selectedIndex;
-                    if (control.comBox.SelectedItem != null )
+                    if (control.comBox.SelectedItem != null)
                         control.SelectedItems = (ComboDataItem)control.comBox.SelectedItem;
                     else
                         control.SelectedItems = null;
@@ -341,10 +381,11 @@ namespace PDF_Master.CustomControl.CompositeControl
                 control.UpdateSelectedIndex();
             }
         }
+
         //选中项后,更新控件选中的显示内容
         public void UpdateSelectedIndex()
         {
-            if(SelectedIndex < 0  || comBox.Items == null || comBox.Items.Count <= SelectedIndex)
+            if (SelectedIndex < 0 || comBox.Items == null || comBox.Items.Count <= SelectedIndex)
             {
                 title.Text = "";
             }
@@ -355,4 +396,4 @@ namespace PDF_Master.CustomControl.CompositeControl
             }
         }
     }
-}
+}

+ 5 - 2
PDF Office/Model/AnnotPanel/FontBoard.cs

@@ -547,8 +547,9 @@ namespace PDF_Master.Model.AnnotPanel
             CurrentPresetFont = new ComboDataItem(presetFont, uiStr);
         }
 
-        internal void GetCurrentPresetFont(FreeTextAnnotArgs annot)
+        internal bool GetCurrentPresetFont(FreeTextAnnotArgs annot)
         {
+            bool isExist = false;
             //List<PresetFontItem> presetFontItems = TextFont.GetCachePresetFontList();
             foreach (var item in PresetFontList)
             {
@@ -557,9 +558,11 @@ namespace PDF_Master.Model.AnnotPanel
                     )
                 {
                     CurrentPresetFont = new ComboDataItem(item.mTag, item.mTagContent);
+                    isExist = true;
+                    break;
                 }
             }
-           
+            return isExist;
         }
 
         #endregion 列表选中赋值

+ 6 - 0
PDF Office/PDF Master.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ProjectFiles</ProjectView>
+  </PropertyGroup>
+</Project>

BIN
PDF Office/Resources/BOTA/HideAnnot.png


+ 8 - 0
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -358,6 +358,8 @@ namespace PDF_Master.ViewModels.BOTA
         /// </summary>
         private void PageSortEvent()
         {
+            if (AnnotationListItems == null) return;
+            if (AnnotationListItems.Count < 0) return;
             ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
             v.GroupDescriptions.Clear();
             v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.PageIndex)));
@@ -597,6 +599,7 @@ namespace PDF_Master.ViewModels.BOTA
                 default:
                     break;
             }
+            if (AnnotationListItems == null) return;
             if (AnnotationListItems.Count > 0)
             {
                 IsEmptyPanelVisibility = Visibility.Collapsed;
@@ -1143,6 +1146,8 @@ namespace PDF_Master.ViewModels.BOTA
                 if (composite.Parameter is ListBox listBox)
                 {
                     this.listBox = listBox;
+                    //RefreshAnnotationListItems();
+                    SetGroupHeader(listBox);
                 }
             }
         }
@@ -1167,6 +1172,7 @@ namespace PDF_Master.ViewModels.BOTA
                 PdfViewer = pdfview;
             }
             SetGroupHeader(listBox);
+            //RefreshAnnotationListItems();
             KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
             KeyEventsHelper.KeyDown += ShortCut_KeyDown;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
@@ -1229,6 +1235,8 @@ namespace PDF_Master.ViewModels.BOTA
         /// <param name="listBox"></param>
         private async void SetGroupHeader(ListBox listBox)
         {
+            if (listBox == null) { return; }
+
             #region BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
 
             //AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>(AnnotationListItems.OrderBy(item => item.ClientRect.Y).ThenBy(item => item.ClientRect.X));

+ 41 - 4
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -4,6 +4,7 @@ using PDF_Master.CustomControl.CompositeControl;
 using PDF_Master.Model;
 using PDF_Master.Model.AnnotPanel;
 using PDF_Master.Model.PropertyPanel.AnnotPanel;
+using PDF_Master.Properties;
 using PDF_Master.ViewModels.Tools;
 using PDF_Master.ViewModels.Tools.AnnotManager;
 using PDFSettings;
@@ -69,6 +70,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
         #endregion 文案
 
+        private string title;
+
+        public string Title
+        {
+            get { return title; }
+            set
+            {
+                SetProperty(ref title, value);
+            }
+        }
+
         private FontBoardVm _fontVm = new FontBoardVm(true);
 
         public FontBoardVm FontVm
@@ -326,6 +338,26 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         //设置字体大小
         private void FontSizeChanged()
         {
+            var currentItem = FontVm.PresetFontList.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
+            //var comboDataItem = FontVm.PresetFontItems.FirstOrDefault(temp => temp.ValueStr == FontVm.CurrentPresetFont.ValueStr);
+            if (currentItem.mTag != "Custom")
+            {
+                foreach (var item in Settings.Default.PresetFontList)
+                {
+                    if (item.mTag == currentItem.mTag)
+                    {
+                        if (FontVm.CurrentFontSize.Value != item.mFontSize)
+                        {
+                            Title = string.Format($"*{currentItem.mTagContent}");
+                        }
+                        else
+                        {
+                            Title = currentItem.mTagContent;
+                        }
+                    }
+                }
+            }
+
             if (FontVm.CurrentFontSize != null)
             {
                 PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontSize, FontVm.CurrentFontSize.Value);
@@ -661,10 +693,15 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             BasicVm.FillOpacity = Annot.Transparency;
 
             FontVm.FontColor = new SolidColorBrush(Annot.FontColor);
-            FontVm.GetCurrentFontSize((int)Annot.FontSize);
-            FontVm.GetCurrentPresetFont(Annot);
-            FontVm.GetCurrentFontFamily(Annot.FontFamily.ToString(), Annot.FontFamily.ToString());
-            FontVm.GetFontWeights_Style(Annot.FontStyle, Annot.FontWeight);
+
+            bool isExist = FontVm.GetCurrentPresetFont(Annot);
+            if (isExist == false)
+            {
+                FontVm.GetCurrentFontSize((int)Annot.FontSize);
+
+                FontVm.GetCurrentFontFamily(Annot.FontFamily.ToString(), Annot.FontFamily.ToString());
+                FontVm.GetFontWeights_Style(Annot.FontStyle, Annot.FontWeight);
+            }
 
             GetTimeFormat();
             GetAnnotAlign(Annot.Align);

+ 48 - 34
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -24,7 +24,6 @@ using System.Windows.Media;
 
 namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 {
-
     public class DashStyleConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -52,10 +51,13 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             throw new NotImplementedException();
         }
     }
+
     public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         #region 属性
+
         private bool isRect = false;
+
         public bool IsRect
         {
             get { return isRect; }
@@ -63,6 +65,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private bool isCircle = false;
+
         public bool IsCircle
         {
             get { return isCircle; }
@@ -70,6 +73,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private bool isArrow = false;
+
         public bool IsArrow
         {
             get { return isArrow; }
@@ -77,6 +81,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private bool isLine = false;
+
         public bool IsLine
         {
             get { return isLine; }
@@ -93,9 +98,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 SetProperty(ref _strShapeChecked, value);
             }
         }
+
         public List<ComboDataItem> ThicknessItems { get; protected set; }
 
         private AnnotCommon _basicVm = new AnnotCommon();
+
         public AnnotCommon BasicVm
         {
             get { return _basicVm; }
@@ -103,6 +110,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private Geometry dataPath = null;
+
         public Geometry DataPath
         {
             get { return dataPath; }
@@ -113,6 +121,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private DashStyle dash = new DashStyle();
+
         public DashStyle Dash
         {
             get { return dash; }
@@ -123,6 +132,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private bool _isLineAnnot = false;
+
         public bool IsLineAnnot
         {
             get { return _isLineAnnot; }
@@ -132,7 +142,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        #endregion
+        #endregion 属性
 
         public DelegateCommand<object> SelectedThickCommand { get; set; }
         public DelegateCommand<object> SelectedBorderColorCommand { get; set; }
@@ -146,8 +156,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand<object> ThicknessChangedCommand { get; set; }
         public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
 
-
         public event EventHandler<object> LoadPropertyHandler;
+
         public SharpsAnnotPropertyViewModel()
         {
             InitColorItems();
@@ -225,6 +235,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     DataPath = rectPath;
                     changeData[AnnotArgsType.AnnotSquare] = tag;
                     IsLineAnnot = false;
+                    if (IsRect == false)
+                        IsRect = true;
                     break;
 
                 case "Circle":
@@ -235,11 +247,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     DataPath = circlePath;
                     changeData[AnnotArgsType.AnnotCircle] = tag;
                     IsLineAnnot = false;
+                    if (IsCircle == false)
+                        IsCircle = true;
                     break;
 
                 case "Arrow":
                     {
-
                         ArrowHelper arrowLine = new ArrowHelper();
                         arrowLine.ArrowLength = 8;
                         arrowLine.LineStart = new Point(8, 24);
@@ -248,7 +261,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                         arrowLine.EndSharp = C_LINE_TYPE.LINETYPE_ARROW;
                         DataPath = arrowLine.BuildArrowBody();
                         changeData[AnnotArgsType.AnnotLine] = tag;
-                        IsLineAnnot = true;
+                        if (IsLineAnnot == false)
+                            IsLineAnnot = true;
+                        if (isArrow == false)
+                            isArrow = true;
                         //  changeData[AnnotArgsType.AnnotLine] = tag;
                     }
 
@@ -261,7 +277,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                         arrowLine.LineEnd = new Point(32, 0);
                         DataPath = arrowLine.BuildArrowBody();
                         changeData[AnnotArgsType.AnnotLine] = tag;
-                        IsLineAnnot = true;
+                        if (IsLineAnnot == false)
+                            IsLineAnnot = true;
+                        if (IsLine == false)
+                            IsLine = true;
                     }
 
                     break;
@@ -271,6 +290,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
 
             StrShapeChecked = tag;
+            PropertyPanel.SharpsAnnot = tag;
             BasicVm.SetOtherTag(tag);
         }
 
@@ -301,8 +321,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-
-
         private void SelectedFillColor_Command(object obj)
         {
             if (obj != null && PropertyPanel != null)
@@ -318,8 +336,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                         PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
                 }
             }
-
-
         }
 
         private void SelectedFillOpacity_Command(object obj)
@@ -331,9 +347,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
                 PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
                 PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
-
             }
-
         }
 
         private void SelectedOpacityValue(object obj)
@@ -346,14 +360,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
                 PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
             }
-
         }
 
-
-
         private void SelectedBorderColor(object obj)
         {
-
             if (obj != null && PropertyPanel != null)
             {
                 var colorValue = (Color)obj;
@@ -367,7 +377,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                         PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
                 }
             }
-
         }
 
         private void SelectedThick_Command(object obj)
@@ -400,9 +409,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 case AnnotArgsType.AnnotCircle:
                     BasicVm.AnnotTypeTitle = "圆";
                     break;
+
                 case AnnotArgsType.AnnotSquare:
                     BasicVm.AnnotTypeTitle = "矩形";
                     break;
+
                 case AnnotArgsType.AnnotLine:
 
                     var annotLine = Annot as LineAnnotArgs;
@@ -415,12 +426,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     }
                     break;
             }
-
         }
 
         public AnnotAttribEvent AnnotEvent { get; set; }
         private AnnotHandlerEventArgs Annot;
         private AnnotTransfer PropertyPanel;
+
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<AnnotTransfer>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
@@ -441,7 +452,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
                 LoadPropertyHandler?.Invoke(null, Annot);
             }
-
         }
 
         private List<SquareAnnotArgs> ConvertLists()
@@ -461,6 +471,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
             else
                 return FreeTextLists;
         }
+
         private void IsAttributeEquals()
         {
             var list = ConvertLists();
@@ -491,12 +502,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     {
                         if (temp.LineColor.A != item.LineColor.A || temp.LineColor.R != item.LineColor.R || temp.LineColor.G != item.LineColor.G || temp.LineColor.B != item.LineColor.B)
                         {
-                            BasicVm.BorderColor = new SolidColorBrush(Color.FromArgb(0x01,0xff,0xff,0xff));
+                            BasicVm.BorderColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
                             isNoEqualsDir["LineColor"] = true;
                         }
                     }
 
-
                     if (isNoEqualsDir["Thickness"] == false)
                     {
                         isNoEqualsDir["Thickness"] = true;
@@ -523,13 +533,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 if (isNoEqualsDir["FillColor"] == false)
                 {
                     BasicVm.FillColor = new SolidColorBrush(temp.BgColor);
-
                 }
 
                 if (isNoEqualsDir["LineColor"] == false)
                 {
                     BasicVm.BorderColor = new SolidColorBrush(temp.LineColor);
-
                 }
 
                 if (isNoEqualsDir["Thickness"] == false)
@@ -547,11 +555,9 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     BasicVm.IsSolidLine = isSolid;
                     BasicVm.IsDashLine = !isSolid;
                 }
-
             }
         }
 
-
         private bool IsSolidStyle(AnnotHandlerEventArgs annot)
         {
             bool isSolid = true;
@@ -594,7 +600,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                             SharpsType("Rect", true);
                             BasicVm.AnnotTypeTitle = "矩形";
                             IsLineAnnot = false;
-                            IsRect = true;
+                            //IsRect = true;
+                            //IsCircle = false;
+                            //IsArrow=false;
+                            //IsLine= false;
                         }
                         break;
 
@@ -611,7 +620,10 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                             SharpsType("Circle", true);
                             BasicVm.AnnotTypeTitle = "圆";
                             IsLineAnnot = false;
-                            IsCircle = true;
+                            //IsCircle = true;
+                            //IsRect = false;
+                            //IsArrow = false;
+                            //IsLine = false;
                         }
                         break;
 
@@ -630,17 +642,22 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                             {
                                 SharpsType("Arrow", true);
                                 BasicVm.AnnotTypeTitle = "箭头";
-                                IsArrow = true;
+                                //IsArrow = true;
+                                //IsCircle = false;
+                                //IsRect = false;
+                                //IsLine = false;
                             }
                             else
                             {
                                 SharpsType("Line", true);
                                 BasicVm.AnnotTypeTitle = "线条";
-                                IsLine = true;
+                                //IsLine = true;
+                                //IsCircle = false;
+                                //IsRect = false;
+                                //IsArrow = false;
                             }
 
                             IsLineAnnot = true;
-
                         }
 
                         break;
@@ -650,9 +667,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 BasicVm.IsSolidLine = isSolid;
                 BasicVm.IsDashLine = !isSolid;
             }
-
         }
-
-
     }
-}
+}

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

@@ -30,6 +30,7 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
         public Dictionary<AnnotArgsType, AnnotHandlerEventArgs> LastAnnotDict = new Dictionary<AnnotArgsType, AnnotHandlerEventArgs>();
         public AnnotHandlerEventArgs LastArrowAnnot = null;
 
+        public string SharpsAnnot = "Rect";
         //是否为填写与签名的日期文本
         public bool IsTextFill { get; private set; }
 
@@ -183,7 +184,7 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
                     itemevent?.UpdateAnnot();
                 }
             }
-            else
+            else if (annotlists.Count == 1)
             {
                 AnnotEvent?.UpdateAttrib(annotAttrib, obj);
                 AnnotEvent?.UpdateAnnot();
@@ -206,7 +207,7 @@ namespace PDF_Master.ViewModels.Tools.AnnotManager
                     itemevent?.UpdateAnnot();
                 }
             }
-            else
+            else if (annotlists.Count == 1)
             {
                 foreach (var item in AnnotAttribDir)
                 {

+ 68 - 44
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -37,10 +37,10 @@ namespace PDF_Master.ViewModels.Tools
         {
             //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
             //比如在属性面板里更改注释颜色,会同时更新工具栏对应的工具颜色
-            propertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
-            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
-            propertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
-            propertyPanel.AnnotTypeChanged += AnnotPropertyPanel_AnnotTypeChanged;
+            PropertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
+            PropertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+            PropertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
+            PropertyPanel.AnnotTypeChanged += AnnotPropertyPanel_AnnotTypeChanged;
             //快捷键
             KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
             KeyEventsHelper.KeyDown += ShortCut_KeyDown;
@@ -48,8 +48,8 @@ namespace PDF_Master.ViewModels.Tools
 
         private void UnBindingEvent()
         {
-            propertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
-            propertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
+            PropertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
+            PropertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
             //快捷盘解绑
             KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
         }
@@ -266,7 +266,7 @@ namespace PDF_Master.ViewModels.Tools
 
                     if (StrAnnotToolChecked == "Link")
                     {
-                        propertyPanel.IsAddLink = false;
+                        PropertyPanel.IsAddLink = false;
                     }
 
                     GetLink(e.AnnotItemsList, e);
@@ -278,11 +278,11 @@ namespace PDF_Master.ViewModels.Tools
                     customStickyPopup.GetPDFViewer = PDFViewer;
                     if (e.IsAnnotCreateReset)
                     {
-                        propertyPanel.annot = e.AnnotItemsList[0];
+                        PropertyPanel.annot = e.AnnotItemsList[0];
                         var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                        propertyPanel.AnnotEvents = null;
-                        propertyPanel.AnnotEvent = AnnotEvent;
-                        propertyPanel.annotlists = e.AnnotItemsList;
+                        PropertyPanel.AnnotEvents = null;
+                        PropertyPanel.AnnotEvent = AnnotEvent;
+                        PropertyPanel.annotlists = e.AnnotItemsList;
                     }
                     break;
 
@@ -401,6 +401,7 @@ namespace PDF_Master.ViewModels.Tools
                         {
                             GetSelectedAnnots(e);
                             PDFViewer.SetToolParam(annot);
+
                             //switch (annot.EventType)
                             //{
                             //    case AnnotArgsType.AnnotFreeText:
@@ -528,23 +529,45 @@ namespace PDF_Master.ViewModels.Tools
             {
                 if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
                 {
+                    viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
                     return;
-                }
-
-                if (StrAnnotToolChecked == "Link")
-                {
-                    if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
-                    {
-                        if (PDFViewer.MouseMode == MouseModes.PanTool && propertyPanel.IsAddLink == false && propertyPanel.IsLocationLink == false)
-                        {
-                            viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
-                        }
-                    }
-                }
-                if (string.IsNullOrWhiteSpace(StrAnnotToolChecked))
+                }
+
+                if (!string.IsNullOrWhiteSpace(StrAnnotToolChecked))
+                {
+                    if (StrAnnotToolChecked != "Stamp" && StrAnnotToolChecked != "Freetext")
+                    {
+                        AnnotHandlerEventArgs annotArgs = null;
+                        //propertyPanel.SaveLastAnnot();
+                        FindAnnotTypeKey(StrAnnotToolChecked, ref annotArgs);
+                        //if (annotArgs != null)
+                        //{
+                        //    //设置点击页面会创建对应选中注释工具的注释
+                        //    annotArgs.Author = Settings.Default.AppProperties.Description.Author;
+                        //    PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+                        //    PDFViewer.SetToolParam(annotArgs);
+                        //}
+                    }
+                }
+                else
                 {
                     viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
-                }
+                }
+
+                //if (StrAnnotToolChecked == "Link")
+                //{
+                //    if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
+                //    {
+                //        if (PDFViewer.MouseMode == MouseModes.PanTool && propertyPanel.IsAddLink == false && propertyPanel.IsLocationLink == false)
+                //        {
+                //            viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                //        }
+                //    }
+                //}
+                //if (string.IsNullOrWhiteSpace(StrAnnotToolChecked))
+                //{
+                //    viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                //}
             }
         }
 
@@ -1123,11 +1146,11 @@ namespace PDF_Master.ViewModels.Tools
             if (e != null)
             {
                 AnnotHandlerEventArgs annotArgs = null;
-                propertyPanel.SaveLastAnnot();
+                //PropertyPanel.SaveLastAnnot();
 
                 foreach (AnnotArgsType argsType in e.Keys)
                 {
-                    if (propertyPanel.annot.EventType != argsType)
+                    if (PropertyPanel.annot.EventType != argsType)
                     {
                         PDFViewer.SetMouseMode(MouseModes.PanTool);
                     }
@@ -1183,11 +1206,11 @@ namespace PDF_Master.ViewModels.Tools
                                 HighLightOpacity = (double)e[argsType];
                             }
                             //创建注释后,修改注释属性,可用于下次创建的注释
-                            if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
+                            if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                             {
                                 if (StrAnnotToolChecked == key.Key)
                                 {
-                                    PDFViewer.SetToolParam(propertyPanel.annot);
+                                    PDFViewer.SetToolParam(PropertyPanel.annot);
                                 }
                             }
                             break;
@@ -1202,11 +1225,11 @@ namespace PDF_Master.ViewModels.Tools
                                 underLineOpacity = (double)e[argsType];
                             }
                             //创建注释后,修改注释属性,可用于下次创建的注释
-                            if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
+                            if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                             {
                                 if (StrAnnotToolChecked == key.Key)
                                 {
-                                    PDFViewer.SetToolParam(propertyPanel.annot);
+                                    PDFViewer.SetToolParam(PropertyPanel.annot);
                                 }
                             }
                             break;
@@ -1221,11 +1244,11 @@ namespace PDF_Master.ViewModels.Tools
                                 SquigglyOpacity = (double)e[argsType];
                             }
                             //创建注释后,修改注释属性,可用于下次创建的注释
-                            if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
+                            if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                             {
                                 if (StrAnnotToolChecked == key.Key)
                                 {
-                                    PDFViewer.SetToolParam(propertyPanel.annot);
+                                    PDFViewer.SetToolParam(PropertyPanel.annot);
                                 }
                             }
                             break;
@@ -1240,11 +1263,11 @@ namespace PDF_Master.ViewModels.Tools
                                 StrikeoutOpacity = (double)e[argsType];
                             }
                             //创建注释后,修改注释属性,可用于下次创建的注释
-                            if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
+                            if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                             {
                                 if (StrAnnotToolChecked == key.Key)
                                 {
-                                    PDFViewer.SetToolParam(propertyPanel.annot);
+                                    PDFViewer.SetToolParam(PropertyPanel.annot);
                                 }
                             }
                             break;
@@ -1256,24 +1279,24 @@ namespace PDF_Master.ViewModels.Tools
                                 var annot = e[argsType] as FreehandAnnotArgs;
                                 if (annot != null)
                                 {
-                                    if (propertyPanel != null)
+                                    if (PropertyPanel != null)
                                     {
                                         //属性面板,切换橡皮擦后,再回到画笔时,需要恢复最近画笔的属性值
                                         var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                                        propertyPanel.AnnotEvent = AnnotEvent;
+                                        PropertyPanel.AnnotEvent = AnnotEvent;
                                         var AnnotEvents = new List<AnnotAttribEvent>();
                                         AnnotEvents.Add(AnnotEvent);
-                                        propertyPanel.AnnotEvents = AnnotEvents;
-                                        propertyPanel.annot = annot;
+                                        PropertyPanel.AnnotEvents = AnnotEvents;
+                                        PropertyPanel.annot = annot;
                                         //手绘注释工具按钮的属性
                                         // FreehandPath.Opacity = annot.Transparency;
                                         // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
                                     }
-                                    if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
+                                    if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                                     {
                                         if (StrAnnotToolChecked == key.Key)
                                         {
-                                            PDFViewer.SetToolParam(propertyPanel.annot);
+                                            PDFViewer.SetToolParam(PropertyPanel.annot);
                                         }
                                     }
                                 }
@@ -1305,11 +1328,12 @@ namespace PDF_Master.ViewModels.Tools
                         case AnnotArgsType.AnnotLine:
                         case AnnotArgsType.AnnotFreeText:
                             //创建注释后,修改注释属性,可用于下次创建的注释
-                            if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
+                            if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                             {
-                                if (StrAnnotToolChecked == key.Key)
+                                if (StrAnnotToolChecked == key.Key || PropertyPanel.SharpsAnnot==key.Key)
                                 {
-                                    PDFViewer.SetToolParam(propertyPanel.annot);
+                                    PDFViewer.SetToolParam(PropertyPanel.annot);
+                                    PropertyPanel.SaveLastAnnot();
                                 }
                             }
 

+ 55 - 20
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -229,7 +229,25 @@ namespace PDF_Master.ViewModels.Tools
                     break;
 
                 case "Rect"://矩形
-                    annotArgs = GetRect();
+
+                    switch (PropertyPanel.SharpsAnnot)
+                    {
+                        case "Rect":
+                            annotArgs = GetRect();
+                            break;
+
+                        case "Circle":
+                            annotArgs = GetCircle();
+                            break;
+
+                        case "Arrow":
+                            annotArgs = GetArrowLine("Arrow");
+                            break;
+
+                        case "Line":
+                            annotArgs = GetArrowLine("Line");
+                            break;
+                    }
                     break;
 
                 case "Circle"://圆
@@ -274,7 +292,7 @@ namespace PDF_Master.ViewModels.Tools
                         dialogs.ShowDialog(DialogNames.IAPCompareDialog);
                         return;
                     }
-                    propertyPanel.IsAddLink = true;
+                    PropertyPanel.IsAddLink = true;
                     viewContentViewModel.IsRightMenuCreateLink = isRightMenuAdd;
                     annotArgs = GetLink();
                     break;
@@ -297,7 +315,7 @@ namespace PDF_Master.ViewModels.Tools
                 highlightArgs.Transparency = highLightOpacity;
                 highlightArgs.Color = (highLightColor as SolidColorBrush).Color;
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotHighlight] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotHighlight] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(highlightArgs.EventType);
                     if (defaultAnnot == null)
@@ -369,7 +387,7 @@ namespace PDF_Master.ViewModels.Tools
                 underlineArgs = new TextUnderlineAnnotArgs();
                 underlineArgs.Transparency = UnderLineOpacity;
                 underlineArgs.Color = (UnderLineColor as SolidColorBrush).Color;
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotUnderline] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotUnderline] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(underlineArgs.EventType);
                     if (defaultAnnot == null)
@@ -412,7 +430,7 @@ namespace PDF_Master.ViewModels.Tools
                 squigglyArgs.Transparency = SquigglyOpacity;
                 squigglyArgs.Color = (squigglyColor as SolidColorBrush).Color;
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquiggly] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquiggly] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squigglyArgs.EventType);
                     if (defaultAnnot == null)
@@ -455,7 +473,7 @@ namespace PDF_Master.ViewModels.Tools
                 strikeoutArgs.Transparency = strikeoutOpacity;
                 strikeoutArgs.Color = (strikeoutColor as SolidColorBrush).Color;
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotStrikeout] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotStrikeout] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(strikeoutArgs.EventType);
                     if (defaultAnnot == null)
@@ -505,7 +523,7 @@ namespace PDF_Master.ViewModels.Tools
                     freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
                 }
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freehandArgs.EventType);
                     if (defaultAnnot == null)
@@ -542,7 +560,10 @@ namespace PDF_Master.ViewModels.Tools
                 }
                 else
                 {
-                    freehandArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] as FreehandAnnotArgs;
+                    freehandArgs = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] as FreehandAnnotArgs;
+                    freehandArgs.AnnotIndex = -1;
+                    freehandArgs.PageIndex = -1;
+                    freehandArgs.ClientRect = Rect.Empty;
                 }
 
                 selectedArgs = new List<AnnotHandlerEventArgs>();
@@ -585,7 +606,7 @@ namespace PDF_Master.ViewModels.Tools
                     freetextArgs.FontColor = Colors.Black;
                 }
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreeText] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreeText] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freetextArgs.EventType);
                     if (defaultAnnot == null)
@@ -627,7 +648,7 @@ namespace PDF_Master.ViewModels.Tools
                 }
                 else
                 {
-                    FreeTextAnnotArgs freeText = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreeText] as FreeTextAnnotArgs;
+                    FreeTextAnnotArgs freeText = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreeText] as FreeTextAnnotArgs;
                     freetextArgs = SetFreetextArgs(freeText);
                     //freetextArgs = SetFreetextArgs(freeText);
                     //freetextArgs.Content = string.Empty;
@@ -846,7 +867,7 @@ namespace PDF_Master.ViewModels.Tools
                     stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
                 }
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSticky] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotSticky] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(stickyAnnotArgs.EventType);
                     if (defaultAnnot == null)
@@ -863,7 +884,7 @@ namespace PDF_Master.ViewModels.Tools
                 }
                 else
                 {
-                    stickyAnnotArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSticky] as StickyAnnotArgs;
+                    stickyAnnotArgs = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotSticky] as StickyAnnotArgs;
                     stickyAnnotArgs.Content = string.Empty;
                     stickyAnnotArgs.StickyNote = string.Empty;
                 }
@@ -911,7 +932,7 @@ namespace PDF_Master.ViewModels.Tools
                     squareArgs.BgColor = Colors.Red;
                 }
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squareArgs.EventType);
                     if (defaultAnnot == null)
@@ -947,7 +968,12 @@ namespace PDF_Master.ViewModels.Tools
                 }
                 else
                 {
-                    squareArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare] as SquareAnnotArgs;
+                    SquareAnnotArgs squareAnnot = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare] as SquareAnnotArgs;
+                    squareArgs.BgColor = squareAnnot.BgColor;
+                    squareArgs.LineColor = squareAnnot.LineColor;
+                    squareArgs.LineWidth = squareAnnot.LineWidth;
+                    squareArgs.Transparency = squareAnnot.Transparency;
+                    squareArgs.LineDash = squareAnnot.LineDash;
                 }
 
                 if (squareArgs != null)
@@ -990,7 +1016,7 @@ namespace PDF_Master.ViewModels.Tools
                     circleAnnotArgs.BgColor = Colors.Red;
                 }
 
-                if (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle] == null)
+                if (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle] == null)
                 {
                     var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(circleAnnotArgs.EventType);
                     if (defaultAnnot == null)
@@ -1028,7 +1054,12 @@ namespace PDF_Master.ViewModels.Tools
                 }
                 else
                 {
-                    circleAnnotArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle] as CircleAnnotArgs;
+                    CircleAnnotArgs circleAnnot = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle] as CircleAnnotArgs;
+                    circleAnnotArgs.LineColor = circleAnnot.LineColor;
+                    circleAnnotArgs.BgColor = circleAnnot.BgColor;
+                    circleAnnotArgs.LineWidth = circleAnnot.LineWidth;
+                    circleAnnotArgs.Transparency = circleAnnot.Transparency;
+                    circleAnnotArgs.LineDash = circleAnnot.LineDash;
                 }
 
                 if (circleAnnotArgs != null)
@@ -1073,12 +1104,12 @@ namespace PDF_Master.ViewModels.Tools
                 if (TagStr == "Line")
                 {
                     lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
-                    isLastAnnot = (propertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine] != null ? true : false);
+                    isLastAnnot = (PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine] != null ? true : false);
                 }
                 else
                 {
                     lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
-                    isLastAnnot = (propertyPanel.LastArrowAnnot != null ? true : false);
+                    isLastAnnot = (PropertyPanel.LastArrowAnnot != null ? true : false);
                 }
 
                 if (isLastAnnot == false)
@@ -1122,12 +1153,15 @@ namespace PDF_Master.ViewModels.Tools
                 {
                     if (lineArgs.TailLineType == C_LINE_TYPE.LINETYPE_ARROW)
                     {
-                        lineArgs = propertyPanel.LastArrowAnnot as LineAnnotArgs;
+                        lineArgs = PropertyPanel.LastArrowAnnot as LineAnnotArgs;
                     }
                     else
                     {
-                        lineArgs = propertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine] as LineAnnotArgs;
+                        lineArgs = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine] as LineAnnotArgs;
                     }
+                    lineArgs.AnnotIndex = -1;
+                    lineArgs.PageIndex = -1;
+                    lineArgs.ClientRect = Rect.Empty;
                 }
 
                 if (lineArgs != null)
@@ -1229,6 +1263,7 @@ namespace PDF_Master.ViewModels.Tools
             //SnapshotEditMenuViewModel = snapshotEditMenuViewModel;
 
             #endregion to do
+
             StrAnnotToolChecked = "";
             return snapshotArgs;
         }

+ 28 - 24
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -40,43 +40,48 @@ namespace PDF_Master.ViewModels.Tools
         {
             if (annots != null)
             {
-                propertyPanel.annotlists = annots;
-                propertyPanel.annot = annots[0];
+                PropertyPanel.annotlists = annots;
+                PropertyPanel.annot = annots[0];
             }
             else
             {
-                propertyPanel.annotlists = null;
-                propertyPanel.annot = null;
+                PropertyPanel.annotlists = null;
+                PropertyPanel.annot = null;
             }
-
+            PropertyPanel.AnnotEvents = null;
+            PropertyPanel.AnnotEvent = null;
             if (annots != null)
             {
                 if (annots.Count > 1)
                 {
-                    if (propertyPanel.AnnotEvents == null)
-                        propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
-
-                    propertyPanel.AnnotEvents.Clear();
-
+                    if (PropertyPanel.AnnotEvents == null)
+                    {
+                        PropertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
+                    }
+
+                    PropertyPanel.AnnotEvents.Clear();
+
                     foreach (var itemAnnot in annots)
                     {
-                        var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, itemAnnot.GetAnnotAttrib());
-                        propertyPanel.AnnotEvents.Add(eventitem);
+                        var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, itemAnnot.GetAnnotAttrib());
+                        //eventitem.ClearChangeAttribute();
+                        PropertyPanel.AnnotEvents.Add(eventitem);
                     }
                 }
 
-                propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annots[0].GetAnnotAttrib());
+                PropertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annots[0].GetAnnotAttrib());
+                //propertyPanel.AnnotEvent.ClearChangeAttribute();
                 if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
                 {
-                    propertyPanel.AnnotEvent = annotAttribEvent;
+                    PropertyPanel.AnnotEvent = annotAttribEvent;
                 }
             }
 
-            propertyPanel.SetIsTextFill(false);
+            PropertyPanel.SetIsTextFill(false);
 
             if (string.IsNullOrEmpty(viewContent) == false)
             {
-                viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
+                viewContentViewModel.SelectedPrpoertyPanel(viewContent, PropertyPanel);
             }
         }
 
@@ -292,18 +297,17 @@ namespace PDF_Master.ViewModels.Tools
         private ContextMenu SelectedTextOrImageContextMenu(object sender, AnnotCommandArgs annotCommand)
         {
             ContextMenu popMenu = new ContextMenu();
-            popMenu.FontSize = 14;
-
-            
+            popMenu.FontSize = 14;
+
             MenuItem menuItem = new MenuItem();
             menuItem = new MenuItem();
             menuItem.CommandTarget = (UIElement)sender;
             menuItem.Command = ApplicationCommands.Copy;
             if (annotCommand.CommandTarget == TargetType.ImageSelection && PDFViewer.GetSelectImageCount() > 0)
             {
-                menuItem.IsEnabled= true;
+                menuItem.IsEnabled = true;
             }
-           
+
             popMenu.Items.Add(menuItem);
 
             menuItem = new MenuItem();
@@ -318,11 +322,11 @@ namespace PDF_Master.ViewModels.Tools
                 popMenu.Items.Add(separator);
 
                 SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_ExtractImage"), "ExportPicture", annotCommand, out menuItem);
-                if(PDFViewer.GetSelectImageCount() > 0)
+                if (PDFViewer.GetSelectImageCount() > 0)
                 {
-                    menuItem.IsEnabled= true;
+                    menuItem.IsEnabled = true;
                 }
-                
+
                 popMenu.Items.Add(menuItem);
             }
             else if (annotCommand.CommandTarget == TargetType.Annot)

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

@@ -140,7 +140,7 @@ namespace PDF_Master.ViewModels.Tools
         public OpenFileInfo OpenFileInfo = null;
         public CPDFViewer PDFViewer;
         private ViewContentViewModel viewContentViewModel;
-        private AnnotTransfer propertyPanel = new AnnotTransfer();
+        private AnnotTransfer PropertyPanel = new AnnotTransfer();
         private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
         private Dictionary<string, string> ToolTipDict = new Dictionary<string, string>();
         private StickyNotePopup customStickyPopup;

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

@@ -188,7 +188,7 @@ namespace PDF_Master.ViewModels.Tools
 
             if (annotBtn.IsChecked == true)
             {
-                propertyPanel.SaveLastAnnot();
+                PropertyPanel.SaveLastAnnot();
                 MyToolCheckedDoing(dictVar, tag);
                 FindAnnotTypeKey(tag, ref annotArgs);
 
@@ -203,8 +203,8 @@ namespace PDF_Master.ViewModels.Tools
             else
             {
                 //取消选中注释工具按钮后,恢复到未编辑注释的状态
-                propertyPanel.IsAddLink = false;
-                propertyPanel.IsLocationLink = false;
+                PropertyPanel.IsAddLink = false;
+                PropertyPanel.IsLocationLink = false;
                 PDFViewer.ToolManager.EnableClickCreate = false;
                 PDFViewer.SetMouseMode(MouseModes.PanTool);
                 ShowPropertyPanel(false);
@@ -370,8 +370,8 @@ namespace PDF_Master.ViewModels.Tools
                 AnnotHandlerEventArgs annotHandler = null;
                 string str = menuItem.Tag.ToString();
                 viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
-                propertyPanel.IsAddLink = false;
-                propertyPanel.IsLocationLink = false;
+                PropertyPanel.IsAddLink = false;
+                PropertyPanel.IsLocationLink = false;
                 if (str == AddAnnotType.AnnotFreehand.ToString())
                 {
                     annotHandler = GetFreehand();
@@ -402,7 +402,7 @@ namespace PDF_Master.ViewModels.Tools
                 }
                 if (str == AddAnnotType.AnnotLink.ToString())
                 {
-                    propertyPanel.IsAddLink = true;
+                    PropertyPanel.IsAddLink = true;
 
                     annotHandler = GetLink();
                 }
@@ -577,7 +577,7 @@ namespace PDF_Master.ViewModels.Tools
                         StrAnnotToolChecked = "Link";
                         List<AnnotHandlerEventArgs> lists = new List<AnnotHandlerEventArgs>();
                         lists.Add(linkArgs);
-                        propertyPanel.IsAddLink = true;
+                        PropertyPanel.IsAddLink = true;
 
                         AnnotHandlerEventArgs annotArgs = GetLink(lists);
                         PDFViewer.SetMouseMode(MouseModes.AnnotCreate);

+ 1 - 0
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -823,6 +823,7 @@ namespace PDF_Master.ViewModels
             eventAggregator.GetEvent<ShowTipEvent>().Subscribe(ShowSelectedTipAsync, e => e.Unicode == unicode);
 
             //TODO:根据缓存 选择用户上次选择的菜单
+            CurrentBar = "TabItemAnnotation";
             EnterSelectedBar("TabItemAnnotation");
         }
 

+ 2 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -140,6 +140,7 @@
                         x:Name="ComBoxPresetFont"
                         Width="188"
                         Height="32"
+                        Title="{Binding Title}"
                         HorizontalAlignment="Left"
                         IsValueContent="True"
                         ItemSource="{Binding FontVm.PresetFontItems, Mode=OneWay}"
@@ -180,6 +181,7 @@
                         x:Name="FontFamilyBox"
                         Height="32"
                         IsValueContent="True"
+
                         ItemSource="{Binding FontVm.FontFamilyItems, Mode=OneWay}"
                         SelectedItems="{Binding FontVm.CurrentFontFamily, Mode=TwoWay}">
                         <i:Interaction.Triggers>

+ 16 - 5
PDF Office/Views/PropertyPanel/AnnotPanel/StickyNotePopup.xaml.cs

@@ -2,6 +2,7 @@
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Master.CustomControl.CompositeControl;
+using PDF_Master.Helper;
 using PDF_Master.Properties;
 using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
 using System;
@@ -116,19 +117,30 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
             ContentText.Focus();
             ContentText.CaretIndex = ContentText.Text.Length;
             LoadedColor();
-            if(GetPDFViewer != null)
+            if (GetPDFViewer != null)
             {
                 GetPDFViewer.PreviewMouseLeftButtonDown -= GetPDFViewer_LeftButtonDown;
                 GetPDFViewer.PreviewMouseLeftButtonDown += GetPDFViewer_LeftButtonDown;
+
+                KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
+                KeyEventsHelper.KeyDown += ShortCut_KeyDown;
+            }
+        }
+
+        private void ShortCut_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (KeyEventsHelper.IsSingleKey(Key.Delete))
+            {
+                BtnDelete_Click(null, null);
             }
         }
 
         private void GetPDFViewer_LeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             var ui = e.OriginalSource as FrameworkElement;
-            if(ui != null)
+            if (ui != null)
             {
-                if(ui.DataContext != null && ui.DataContext is ColorItem == false)
+                if (ui.DataContext != null && ui.DataContext is ColorItem == false)
                 {
                     CloseText_MouseUp(this, null);
                     GetPDFViewer.PreviewMouseLeftButtonDown -= GetPDFViewer_LeftButtonDown;
@@ -342,7 +354,7 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
             if (Regex.IsMatch(dateText, "(?<=D\\:)[0-9]+(?=[\\+\\-])"))
             {
                 string dateStr = Regex.Match(dateText, "(?<=D\\:)[0-9]+(?=[\\+\\-])").Value;
-                dateText = dateStr.Substring(4, 2)+ "/" + dateStr.Substring(6, 2) +"/" + dateStr.Substring(0, 4)  + " " + dateStr.Substring(8, 2) + ":" +
+                dateText = dateStr.Substring(4, 2) + "/" + dateStr.Substring(6, 2) + "/" + dateStr.Substring(0, 4) + " " + dateStr.Substring(8, 2) + ":" +
                     dateStr.Substring(10, 2) + ":" + dateStr.Substring(12, 2);
             }
             StickyDate = dateText;
@@ -366,7 +378,6 @@ namespace PDF_Master.Views.PropertyPanel.AnnotPanel
             }
             catch (Exception ex)
             {
-
             }
         }