Browse Source

综合-注释bug

OYXH\oyxh 2 years ago
parent
commit
021f2e73b9

+ 19 - 0
PDF Office/EventAggregators/CleanSelectAllEvent.cs

@@ -0,0 +1,19 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.EventAggregators
+{
+    public class CleanSelectAllArgs
+    {
+        public string Unicode { get; set; }
+        public bool IsCleanSelectAll { get; set; }
+    }
+
+    internal class CleanSelectAllEvent : PubSubEvent<CleanSelectAllArgs>
+    {
+    }
+}

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -359,6 +359,7 @@
     <Compile Include="DataConvert\TextAlignToCheckedConverter.cs" />
     <Compile Include="DataConvert\UnVisivleConvert.cs" />
     <Compile Include="DataConvert\WidthConvert.cs" />
+    <Compile Include="EventAggregators\CleanSelectAllEvent.cs" />
     <Compile Include="EventAggregators\EditToolsEvent.cs" />
     <Compile Include="EventAggregators\FillAndSignEvent.cs" />
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />

+ 19 - 3
PDF Office/ViewModels/BOTA/BookmarkContentViewModel.cs

@@ -37,6 +37,8 @@ using static Dropbox.Api.Files.SaveUrlError;
 using System.Windows.Documents;
 using System.Runtime.Remoting.Messaging;
 using ListView = System.Windows.Controls.ListView;
+using PDF_Office.EventAggregators;
+using Prism.Events;
 
 namespace PDF_Office.ViewModels.BOTA
 {
@@ -72,13 +74,15 @@ namespace PDF_Office.ViewModels.BOTA
             T_EmptyContext = App.MainPageLoader.GetString("Bookmark_EmptyContext");
         }
 
-        #endregion
+        #endregion 文案
+
         #region 属性
 
         public bool isAddBookMark = false;
         private IRegionManager region;
         private IDialogService dialogs;
         public CPDFViewer PDFViewer;
+        public IEventAggregator events;
 
         /// <summary>
         /// 书签ItemSouce
@@ -136,11 +140,11 @@ namespace PDF_Office.ViewModels.BOTA
 
         #endregion 命令
 
-        public BookmarkContentViewModel(IRegionManager regionManager, IDialogService dialogService)
+        public BookmarkContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
         {
             region = regionManager;
             dialogs = dialogService;
-
+            events = eventAggregator;
             Bookmarklist = new ObservableCollection<CPDFBookmark>();
 
             LostFocusCommand = new DelegateCommand<object>(LostFocusEvent);
@@ -454,6 +458,9 @@ namespace PDF_Office.ViewModels.BOTA
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
+            KeyEventsHelper.KeyDown += ShortCut_KeyDown;
+
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             if (PDFViewer == null)
             {
@@ -482,6 +489,15 @@ namespace PDF_Office.ViewModels.BOTA
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
+            KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
+        }
+
+        private void ShortCut_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (KeyEventsHelper.IsSingleKey(System.Windows.Input.Key.Escape))
+            {
+                this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
+            }
         }
     }
 }

+ 15 - 29
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SharpsAnnotPropertyViewModel.cs

@@ -24,7 +24,6 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-
     public class DashStyleConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -52,9 +51,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             throw new NotImplementedException();
         }
     }
+
     public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
     {
         #region 属性
+
         private string _strShapeChecked = "";
 
         public string StrShapeChecked
@@ -65,9 +66,11 @@ namespace PDF_Office.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; }
@@ -75,6 +78,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private Geometry dataPath = null;
+
         public Geometry DataPath
         {
             get { return dataPath; }
@@ -85,6 +89,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private DashStyle dash = new DashStyle();
+
         public DashStyle Dash
         {
             get { return dash; }
@@ -95,6 +100,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         }
 
         private bool _isLineAnnot = false;
+
         public bool IsLineAnnot
         {
             get { return _isLineAnnot; }
@@ -104,7 +110,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        #endregion
+        #endregion 属性
 
         public DelegateCommand<object> SelectedThickCommand { get; set; }
         public DelegateCommand<object> SelectedBorderColorCommand { get; set; }
@@ -118,8 +124,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public DelegateCommand<object> ThicknessChangedCommand { get; set; }
         public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
 
-
         public event EventHandler<object> LoadPropertyHandler;
+
         public SharpsAnnotPropertyViewModel()
         {
             InitColorItems();
@@ -211,7 +217,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 case "Arrow":
                     {
-
                         ArrowHelper arrowLine = new ArrowHelper();
                         arrowLine.ArrowLength = 8;
                         arrowLine.LineStart = new Point(8, 24);
@@ -242,7 +247,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if (isFromToolsBtn == false)
                 PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
 
-            StrShapeChecked = tag;
             BasicVm.SetOtherTag(tag);
         }
 
@@ -273,8 +277,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-
-
         private void SelectedFillColor_Command(object obj)
         {
             if (obj != null && PropertyPanel != null)
@@ -290,8 +292,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
                 }
             }
-
-
         }
 
         private void SelectedFillOpacity_Command(object obj)
@@ -303,9 +303,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
                 PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
-
             }
-
         }
 
         private void SelectedOpacityValue(object obj)
@@ -318,14 +316,10 @@ namespace PDF_Office.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;
@@ -339,7 +333,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
                 }
             }
-
         }
 
         private void SelectedThick_Command(object obj)
@@ -372,9 +365,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 case AnnotArgsType.AnnotCircle:
                     BasicVm.AnnotTypeTitle = "圆";
                     break;
+
                 case AnnotArgsType.AnnotSquare:
                     BasicVm.AnnotTypeTitle = "矩形";
                     break;
+
                 case AnnotArgsType.AnnotLine:
 
                     var annotLine = Annot as LineAnnotArgs;
@@ -387,12 +382,12 @@ namespace PDF_Office.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);
@@ -413,7 +408,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
                 LoadPropertyHandler?.Invoke(null, Annot);
             }
-
         }
 
         private List<SquareAnnotArgs> ConvertLists()
@@ -433,6 +427,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             else
                 return FreeTextLists;
         }
+
         private void IsAttributeEquals()
         {
             var list = ConvertLists();
@@ -463,12 +458,11 @@ namespace PDF_Office.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;
@@ -495,13 +489,11 @@ namespace PDF_Office.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)
@@ -519,11 +511,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     BasicVm.IsSolidLine = isSolid;
                     BasicVm.IsDashLine = !isSolid;
                 }
-
             }
         }
 
-
         private bool IsSolidStyle(AnnotHandlerEventArgs annot)
         {
             bool isSolid = true;
@@ -608,7 +598,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                             }
 
                             IsLineAnnot = true;
-
                         }
 
                         break;
@@ -618,9 +607,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 BasicVm.IsSolidLine = isSolid;
                 BasicVm.IsDashLine = !isSolid;
             }
-
         }
-
-
     }
-}
+}

+ 11 - 4
PDF Office/ViewModels/Tools/AnnotManager/AnnotTransfer.cs

@@ -16,6 +16,7 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
     public class AnnotTransfer
     {
         public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
+
         public event EventHandler<Dictionary<AnnotArgsType, object>> AnnotTypeChanged;
 
         public bool IsAddLink = false;
@@ -28,6 +29,7 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
 
         public Dictionary<AnnotArgsType, AnnotHandlerEventArgs> LastAnnotDict = new Dictionary<AnnotArgsType, AnnotHandlerEventArgs>();
         public AnnotHandlerEventArgs LastArrowAnnot = null;
+
         //是否为填写与签名的日期文本
         public bool IsTextFill { get; private set; }
 
@@ -54,7 +56,11 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
 
         public void SaveLastAnnot()
         {
-            if(annot.EventType == AnnotArgsType.AnnotLine)
+            if (annot == null)
+            {
+                return;
+            }
+            if (annot.EventType == AnnotArgsType.AnnotLine)
             {
                 var lineAnnotArgs = annot as LineAnnotArgs;
                 if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
@@ -163,8 +169,8 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
 
             return newDash;
         }
-        #endregion 静态
 
+        #endregion 静态
 
         //单个属性更改
         public void UpdateAnnotAAttrib(AnnotAttrib annotAttrib, object obj)
@@ -181,6 +187,7 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
             {
                 AnnotEvent?.UpdateAttrib(annotAttrib, obj);
                 AnnotEvent?.UpdateAnnot();
+                this.annot = AnnotEvent.AnnotItemsList[0];
             }
         }
 
@@ -207,6 +214,7 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
                 }
 
                 AnnotEvent?.UpdateAnnot();
+                this.annot = AnnotEvent.AnnotItemsList[0];
             }
         }
 
@@ -239,6 +247,5 @@ namespace PDF_Office.ViewModels.Tools.AnnotManager
         }
 
         #endregion Invoke
-
     }
-}
+}

+ 19 - 15
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -27,13 +27,14 @@ using PDF_Office.Model.AnnotPanel;
 using System.Windows.Input;
 using PDF_Office.ViewModels.Tools.AnnotManager;
 using ComPDFKit.Import;
+using static Dropbox.Api.Files.SearchMatchType;
 
 namespace PDF_Office.ViewModels.Tools
 {
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
-
         #region 事件绑定和解绑
+
         private void BindingEvent()
         {
             //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
@@ -104,6 +105,15 @@ namespace PDF_Office.ViewModels.Tools
         //鼠标左键双击注释
         private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
+            if (e.ClickCount == 1)
+            {
+                bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemBookMark");
+
+                if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true && bOTAContent.TabItemBookMark.IsSelected == true)
+                {
+                    this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
+                }
+            }
             if (e.ClickCount == 2)
             {
                 if (CurrentSelectedAnnot != null)
@@ -121,13 +131,9 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 PopAnnotNoteText(CurrentSelectedAnnot);
                             }
-
                         }
-
                     }
-                       
                 }
-                   
             }
         }
 
@@ -170,6 +176,7 @@ namespace PDF_Office.ViewModels.Tools
                     break;
             }
         }
+
         private void GetSelectedAnnots(AnnotAttribEvent e)
         {
             var annot = e.AnnotItemsList[0];
@@ -266,7 +273,6 @@ namespace PDF_Office.ViewModels.Tools
             if (annot.PageIndex < 0 || annot.AnnotIndex < 0)
                 return;
 
-
             var signAnnot = viewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
             if (signAnnot == null)
             {
@@ -284,7 +290,6 @@ namespace PDF_Office.ViewModels.Tools
                 GetSignature();
                 StrAnnotToolChecked = "Signature";
             }
-
         }
 
         private void AddAnnotSignature(AnnotHandlerEventArgs annot)
@@ -308,7 +313,9 @@ namespace PDF_Office.ViewModels.Tools
         #endregion 与触发事件调用相关的函数
 
         #region PDFViewer事件
+
         private AnnotHandlerEventArgs CurrentSelectedAnnot = null;
+
         //选中和非选中注释
         private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
         {
@@ -720,7 +727,6 @@ namespace PDF_Office.ViewModels.Tools
                     menuItem = popMenu.Items[4] as MenuItem;
                     menuItem.CommandTarget = PDFViewer;
                     menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
-
                 }
             }
         }
@@ -808,7 +814,6 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 AddAnnotSignature(editEvent.EditAnnotArgs);
                             }
-                            
 
                             break;
 
@@ -863,7 +868,7 @@ namespace PDF_Office.ViewModels.Tools
         {
             bool isAdd = false;
             Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
-           
+
             foreach (var item in e)
             {
                 if (item.EditAction == ActionType.Add)
@@ -883,11 +888,8 @@ namespace PDF_Office.ViewModels.Tools
                         }
 
                         isAdd = true;
-
                     }
-
                 }
-
             }
 
             if (isAdd)
@@ -895,7 +897,6 @@ namespace PDF_Office.ViewModels.Tools
                 PDFViewer.ClearSelectAnnots();
                 PDFViewer.SelectAnnotation(selectAnnotDicts);
             }
-
         }
 
         //阅读页悬浮相应
@@ -939,6 +940,7 @@ namespace PDF_Office.ViewModels.Tools
         }
 
         private Rect oldRect = new Rect(0, 0, 0, 0);
+
         private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
         {
             //便签,显示ToolTip内容
@@ -988,8 +990,10 @@ namespace PDF_Office.ViewModels.Tools
             if (e != null)
             {
                 AnnotHandlerEventArgs annotArgs = null;
+                PDFViewer.SetMouseMode(MouseModes.PanTool);
                 foreach (AnnotArgsType argsType in e.Keys)
                 {
+                    propertyPanel.SaveLastAnnot();
                     switch (argsType)
                     {
                         case AnnotArgsType.AnnotSquare:
@@ -1012,7 +1016,7 @@ namespace PDF_Office.ViewModels.Tools
                         PDFViewer.SetToolParam(annotArgs);
                     }
 
-                    propertyPanel.SaveLastAnnot();
+
                     ShowPropertyPanel();
                 }
             }

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

@@ -158,15 +158,15 @@ namespace PDF_Office.ViewModels.Tools
             if (annotBtn == null || annotBtn.Tag == null) return;
 
             //不创建注释,属于注释模板
-            Dictionary<string,bool> dictVar = new Dictionary<string,bool>();
+            Dictionary<string, bool> dictVar = new Dictionary<string, bool>();
             dictVar.Add("isTemplateAnnot", false);
             dictVar.Add("isSnapshotEdit", false);
             AnnotHandlerEventArgs annotArgs = null;
             var tag = annotBtn.Tag.ToString();
 
-           
+
             if (annotBtn.Name == "BtnShowAnnot")
-            { 
+            {
                 //显示/隐藏注释
                 PDFViewer.SetDrawAnnot((bool)annotBtn.IsChecked);
                 return;
@@ -174,9 +174,10 @@ namespace PDF_Office.ViewModels.Tools
 
             if (annotBtn.IsChecked == true)
             {
+                propertyPanel.SaveLastAnnot();
                 MyToolCheckedDoing(dictVar, tag);
                 FindAnnotTypeKey(tag, ref annotArgs);
-                propertyPanel.SaveLastAnnot();
+
                 if (annotArgs != null)
                 {
                     //设置点击页面会创建对应选中注释工具的注释
@@ -199,7 +200,7 @@ namespace PDF_Office.ViewModels.Tools
                 PDFViewer.ToolManager.EnableClickCreate = false;
             }
 
-            
+
             if (dictVar["isTemplateAnnot"] == false && annotArgs == null)
             {
                 //当不是注释模板,且无创建注释时,属性面板显示为空内容
@@ -220,7 +221,7 @@ namespace PDF_Office.ViewModels.Tools
         }
 
         //选中注释工具按钮时,处理的一些系列事情
-        private void MyToolCheckedDoing(Dictionary<string, bool> dict,string tag)
+        private void MyToolCheckedDoing(Dictionary<string, bool> dict, string tag)
         {
             if (BtnHandIsChecked)
                 BtnHandIsChecked = false;
@@ -244,7 +245,7 @@ namespace PDF_Office.ViewModels.Tools
             else
                 StrAnnotToolChecked = "Link";
 
-            
+
             if (tag == "Rect" || tag == "Circle" || tag == "Arrow" || tag == "Line")
             {
                 //新建形状注释,设置默认大小

+ 22 - 15
PDF Office/Views/BOTA/BookmarkContent.xaml.cs

@@ -1,6 +1,8 @@
 using ComPDFKit.PDFDocument;
+using PDF_Office.EventAggregators;
 using PDF_Office.Helper;
 using PDF_Office.ViewModels.BOTA;
+using Prism.Events;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -35,25 +37,30 @@ namespace PDF_Office.Views.BOTA
 
         private bool isAdd = false;
 
+        private string unicode = "";
+
         public BookmarkContent()
         {
             InitializeComponent();
             viewModel = this.DataContext as BookmarkContentViewModel;
-            KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
-            KeyEventsHelper.KeyDown += ShortCut_KeyDown;
+            unicode = App.mainWindowViewModel.SelectedItem.Unicode;
         }
 
-        private void ShortCut_KeyDown(object sender, KeyEventArgs e)
+        public BookmarkContent(IEventAggregator eventAggregator) : this()
         {
-            if (KeyEventsHelper.IsSingleKey(Key.Escape))
-            {
-                if (BookMarkListView.SelectedItems == null)
-                {
-                    return;
-                }
+            eventAggregator.GetEvent<CleanSelectAllEvent>().Subscribe(CleanSelectAll, e => e.Unicode == unicode);
+        }
 
-                BookMarkListView.SelectedItems.Clear();
+        private void CleanSelectAll(CleanSelectAllArgs obj)
+        {
+            ListViewItem listItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(BookMarkListView.SelectedItem));
+            TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listItem);
+            TextBox text = CommonHelper.FindVisualChild<TextBox>(listItem);
+            if (textBlock.Visibility == Visibility.Collapsed)
+            {
+                textBlock.Visibility = Visibility.Visible;
             }
+            BookMarkListView.SelectedItems.Clear();
         }
 
         /// <summary>
@@ -152,7 +159,7 @@ namespace PDF_Office.Views.BOTA
             listBoxItem.IsSelected = true;
             listBoxItem.Focus();
             textBlock.Visibility = Visibility.Collapsed;
-
+            isRename = true;
             textBox.Dispatcher.BeginInvoke(new Action(() =>
                                 {
                                     textBox.Focus();
@@ -188,10 +195,10 @@ namespace PDF_Office.Views.BOTA
                         listItem.IsSelected = true;
                         isAdd = false;
                     }
-                    if (text.IsSelectionActive == true)
-                    {
-                        textBlock.Visibility = Visibility.Visible;
-                    }
+                    //if (text.IsSelectionActive == true)
+                    //{
+                    //    textBlock.Visibility = Visibility.Visible;
+                    //}
                 }
                 else
                 {

+ 165 - 78
PDF Office/Views/PropertyPanel/AnnotPanel/SharpsAnnotProperty.xaml

@@ -2,20 +2,22 @@
     x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.SharpsAnnotProperty"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:AnnotPanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
     xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
     xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
     xmlns:DashConvert="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
+    xmlns:convert="clr-namespace:PDF_Office.Views.Tools"
     xmlns:cus="clr-namespace:PDF_Office.CustomControl"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
     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:DataContext="{d:DesignInstance Type=AnnotPanel:SharpsAnnotPropertyViewModel}"
     d:DesignHeight="450"
     d:DesignWidth="260"
-    Background="{StaticResource color.sys.layout.mg}"
     prism:ViewModelLocator.AutoWireViewModel="True"
+    Background="{StaticResource color.sys.layout.mg}"
     mc:Ignorable="d">
     <UserControl.Resources>
         <ResourceDictionary>
@@ -25,7 +27,7 @@
             </ResourceDictionary.MergedDictionaries>
             <Convert:ColorToBrushConverter x:Key="ColorToBrushConvert" />
             <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert" />
-            <convert:AnnotToolIsCheckedConvert x:Key="AnnotToolIsCheckedConvert"/>
+            <convert:AnnotToolIsCheckedConvert x:Key="AnnotToolIsCheckedConvert" />
             <DashConvert:DashStyleConverter x:Key="DashStyleConverter" />
             <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
             <Style x:Key="line1Style" TargetType="{x:Type Line}">
@@ -79,7 +81,7 @@
                 BorderBrush="#DDDDDD"
                 BorderThickness="1"
                 CornerRadius="2"
-                Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                 <Grid>
                     <Path
                         Name="SharpPath"
@@ -103,9 +105,10 @@
                 Width="162"
                 Height="32"
                 Margin="0,12,0,0"
+                HorizontalAlignment="Left"
                 BorderBrush="#FFE2E3E6"
-                BorderThickness="0"  HorizontalAlignment="Left"
-                Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                BorderThickness="0"
+                Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                 <Grid Name="ToolGrid">
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="40.5" />
@@ -114,13 +117,21 @@
                         <ColumnDefinition Width="40.5" />
                     </Grid.ColumnDefinitions>
 
-                    <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
+                        x:Name="SharpRectBtn"
+                        Width="32"
+                        Height="32"
+                        Margin="0,0"
+                        Padding="7,0,0,0"
+                        VerticalContentAlignment="Center"
+                        Background="Transparent"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}"
+                        GroupName="Shape"
+                        IsChecked="{Binding StrShapeChecked, Converter={StaticResource AnnotToolIsCheckedConvert}, ConverterParameter=Rect}"
+                        Style="{DynamicResource GreyBgRadioBtnStyle}"
+                        Tag="Rect"
+                        ToolTip="矩形">
                         <RadioButton.Content>
                             <Rectangle
                                 Width="16"
@@ -129,16 +140,24 @@
                                 VerticalAlignment="Center"
                                 Stroke="#273C62" />
                         </RadioButton.Content>
-                       
                     </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
+                        x:Name="SharpCircleBtn"
+                        Grid.Column="1"
+                        Width="32"
+                        Height="32"
+                        Margin="0,0"
+                        Padding="7,0,0,0"
+                        VerticalContentAlignment="Center"
+                        Background="Transparent"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}"
+                        GroupName="Shape"
+                        IsChecked="{Binding StrShapeChecked, Converter={StaticResource AnnotToolIsCheckedConvert}, ConverterParameter=Circle}"
+                        Style="{DynamicResource GreyBgRadioBtnStyle}"
+                        Tag="Circle"
+                        ToolTip="圆">
                         <RadioButton.Content>
                             <Ellipse
                                 Width="16"
@@ -147,16 +166,24 @@
                                 VerticalAlignment="Center"
                                 Stroke="#273C62" />
                         </RadioButton.Content>
-                       
                     </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
+                        x:Name="SharpArrowBtn"
+                        Grid.Column="2"
+                        Width="32"
+                        Height="32"
+                        Margin="0,0"
+                        Padding="7,0,0,0"
+                        VerticalContentAlignment="Center"
+                        Background="Transparent"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}"
+                        GroupName="Shape"
+                        IsChecked="{Binding StrShapeChecked, Converter={StaticResource AnnotToolIsCheckedConvert}, ConverterParameter=Arrow}"
+                        Style="{DynamicResource GreyBgRadioBtnStyle}"
+                        Tag="Arrow"
+                        ToolTip="箭头">
                         <RadioButton.Content>
                             <Path
                                 Width="16"
@@ -169,16 +196,24 @@
                                 </Path.Data>
                             </Path>
                         </RadioButton.Content>
-                        
                     </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
+                        x:Name="SharpLineBtn"
+                        Grid.Column="3"
+                        Width="32"
+                        Height="32"
+                        Margin="0,0"
+                        Padding="7,0,0,0"
+                        VerticalContentAlignment="Center"
+                        Background="Transparent"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}"
+                        GroupName="Shape"
+                        IsChecked="{Binding StrShapeChecked, Converter={StaticResource AnnotToolIsCheckedConvert}, ConverterParameter=Line}"
+                        Style="{DynamicResource GreyBgRadioBtnStyle}"
+                        Tag="Line"
+                        ToolTip="线条">
                         <RadioButton.Content>
                             <Polygon
                                 Width="16"
@@ -191,33 +226,43 @@
                                 </Polygon.Points>
                             </Polygon>
                         </RadioButton.Content>
-                       
                     </RadioButton>
                 </Grid>
             </Border>
 
-            <Grid x:Name="GridFill" Margin="0,18,0,0" Visibility="{Binding IsLineAnnot,Converter={StaticResource InvertBoolToVisibleConvert}}">
+            <Grid
+                x:Name="GridFill"
+                Margin="0,18,0,0"
+                Visibility="{Binding IsLineAnnot, Converter={StaticResource InvertBoolToVisibleConvert}}">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="auto" />
                     <RowDefinition />
                 </Grid.RowDefinitions>
-                <TextBlock Text="Fill" Foreground="{StaticResource color.sys.text.neutral.lv2}" VerticalAlignment="Center" />
-                <CompositeControl:SlidContent x:Name="layerFill" HorizontalAlignment="Right"
-                                              InitValue="{Binding BasicVm.FillOpacity,Mode=OneWay}"
-                                              Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                <TextBlock
+                    VerticalAlignment="Center"
+                    Foreground="{StaticResource color.sys.text.neutral.lv2}"
+                    Text="Fill" />
+                <CompositeControl:SlidContent
+                    x:Name="layerFill"
+                    HorizontalAlignment="Right"
+                    InitValue="{Binding BasicVm.FillOpacity, Mode=OneWay}"
+                    Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedValueChanged">
-                            <i:InvokeCommandAction Command="{Binding SelectedOpacityValueCommand}" CommandParameter="{Binding ElementName=layerFill,Path=Value}" />
+                            <i:InvokeCommandAction Command="{Binding SelectedOpacityValueCommand}" CommandParameter="{Binding ElementName=layerFill, Path=Value}" />
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:SlidContent>
-                <CompositeControl:ColorContent x:Name="cusFillColor" Grid.Row="1" Margin="0,8,0,0"
-                                               ItemSource="{Binding BasicVm.FillColorItems}"
-                                               ColorType="Fill"
-                                               UIColor="{Binding BasicVm.CurrentFillColor,Mode=OneWay}">
+                <CompositeControl:ColorContent
+                    x:Name="cusFillColor"
+                    Grid.Row="1"
+                    Margin="0,8,0,0"
+                    ColorType="Fill"
+                    ItemSource="{Binding BasicVm.FillColorItems}"
+                    UIColor="{Binding BasicVm.CurrentFillColor, Mode=OneWay}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedColorInvoke">
-                            <i:InvokeCommandAction Command="{Binding SelectedFillColorCommand}" CommandParameter="{Binding ElementName=cusFillColor,Path=SelectedColor}" />
+                            <i:InvokeCommandAction Command="{Binding SelectedFillColorCommand}" CommandParameter="{Binding ElementName=cusFillColor, Path=SelectedColor}" />
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:ColorContent>
@@ -228,60 +273,102 @@
                     <RowDefinition Height="auto" />
                     <RowDefinition />
                 </Grid.RowDefinitions>
-                <TextBlock Text="Border" Foreground="{StaticResource color.sys.text.neutral.lv2}" VerticalAlignment="Center" />
-                <CompositeControl:SlidContent x:Name="layerThick" HorizontalAlignment="Right"
-                                              InitValue="{Binding BasicVm.FillOpacity,Mode=OneWay}"
-                                              Visibility="{Binding BasicVm.IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                <TextBlock
+                    VerticalAlignment="Center"
+                    Foreground="{StaticResource color.sys.text.neutral.lv2}"
+                    Text="Border" />
+                <CompositeControl:SlidContent
+                    x:Name="layerThick"
+                    HorizontalAlignment="Right"
+                    InitValue="{Binding BasicVm.FillOpacity, Mode=OneWay}"
+                    Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedValueChanged">
-                            <i:InvokeCommandAction Command="{Binding SelectedOpacityValueCommand}" CommandParameter="{Binding ElementName=layerThick,Path=Value}" />
+                            <i:InvokeCommandAction Command="{Binding SelectedOpacityValueCommand}" CommandParameter="{Binding ElementName=layerThick, Path=Value}" />
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:SlidContent>
 
-                <CompositeControl:ColorContent x:Name="cusColor" Grid.Row="1" Margin="0,8,0,0"
-                                               ItemSource="{Binding BasicVm.ColorItems}"
-                                               ColorType="Border"
-                                               UIColor="{Binding BasicVm.CurrentBorderColor,Mode=OneWay}">
+                <CompositeControl:ColorContent
+                    x:Name="cusColor"
+                    Grid.Row="1"
+                    Margin="0,8,0,0"
+                    ColorType="Border"
+                    ItemSource="{Binding BasicVm.ColorItems}"
+                    UIColor="{Binding BasicVm.CurrentBorderColor, Mode=OneWay}">
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="SelectedColorInvoke">
-                            <i:InvokeCommandAction Command="{Binding SelectedBorderColorCommand}" CommandParameter="{Binding ElementName=cusColor,Path=SelectedColor}" />
+                            <i:InvokeCommandAction Command="{Binding SelectedBorderColorCommand}" CommandParameter="{Binding ElementName=cusColor, Path=SelectedColor}" />
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </CompositeControl:ColorContent>
             </Grid>
 
-            <CompositeControl:SlidComboControl x:Name="thickness" Margin="0,0,0,0"  ItemsSource="{Binding ThicknessItems}" Value="{Binding  BasicVm.AnnotThickness,Mode=TwoWay}">
+            <CompositeControl:SlidComboControl
+                x:Name="thickness"
+                Margin="0,0,0,0"
+                ItemsSource="{Binding ThicknessItems}"
+                Value="{Binding BasicVm.AnnotThickness, Mode=TwoWay}">
                 <i:Interaction.Triggers>
                     <i:EventTrigger EventName="ValueChanged">
-                        <i:InvokeCommandAction Command="{Binding SelectedThickCommand}" CommandParameter="{Binding ElementName=thickness,Path=Value}" />
+                        <i:InvokeCommandAction Command="{Binding SelectedThickCommand}" CommandParameter="{Binding ElementName=thickness, Path=Value}" />
                     </i:EventTrigger>
                 </i:Interaction.Triggers>
             </CompositeControl:SlidComboControl>
 
-            <StackPanel  x:Name="PnlLineStyle" Orientation="Horizontal" Margin="0,20,0,0">
+            <StackPanel
+                x:Name="PnlLineStyle"
+                Margin="0,20,0,0"
+                Orientation="Horizontal">
 
-                <RadioButton x:Name="BtnSolid" Tag="Solid" GroupName="LineMode"
-                             Width="105" Height="32" Margin="0,0,10,0" Foreground="#616469"
-                             VerticalContentAlignment="Center" Background="Transparent"
-                             Command="{Binding LineStyleCommand}"
-                             CommandParameter="{Binding ElementName=BtnSolid, Path=Tag}"
-                             IsChecked="{Binding BasicVm.IsSolidLine}"
-                             Style="{DynamicResource GreyBgRadioBtnStyle}">
+                <RadioButton
+                    x:Name="BtnSolid"
+                    Width="105"
+                    Height="32"
+                    Margin="0,0,10,0"
+                    VerticalContentAlignment="Center"
+                    Background="Transparent"
+                    Command="{Binding LineStyleCommand}"
+                    CommandParameter="{Binding ElementName=BtnSolid, Path=Tag}"
+                    Foreground="#616469"
+                    GroupName="LineMode"
+                    IsChecked="{Binding BasicVm.IsSolidLine}"
+                    Style="{DynamicResource GreyBgRadioBtnStyle}"
+                    Tag="Solid">
                     <RadioButton.Content>
-                        <Line X1="10" Y1="5" X2="90" Y2="5" Stroke="Black" StrokeThickness="2" />
+                        <Line
+                            Stroke="Black"
+                            StrokeThickness="2"
+                            X1="10"
+                            X2="90"
+                            Y1="5"
+                            Y2="5" />
                     </RadioButton.Content>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnDashed" Tag="Dashed" GroupName="LineMode"
-                             Width="105" Height="32" Margin="0,0" Foreground="#616469"
-                             VerticalContentAlignment="Center" Background="Transparent"
-                             Command="{Binding LineStyleCommand}"
-                             CommandParameter="{Binding ElementName=BtnDashed, Path=Tag}"
-                             IsChecked="{Binding BasicVm.IsDashLine}"
-                             Style="{DynamicResource GreyBgRadioBtnStyle}">
+                <RadioButton
+                    x:Name="BtnDashed"
+                    Width="105"
+                    Height="32"
+                    Margin="0,0"
+                    VerticalContentAlignment="Center"
+                    Background="Transparent"
+                    Command="{Binding LineStyleCommand}"
+                    CommandParameter="{Binding ElementName=BtnDashed, Path=Tag}"
+                    Foreground="#616469"
+                    GroupName="LineMode"
+                    IsChecked="{Binding BasicVm.IsDashLine}"
+                    Style="{DynamicResource GreyBgRadioBtnStyle}"
+                    Tag="Dashed">
                     <RadioButton.Content>
-                        <Line X1="10" Y1="5" X2="90" Y2="5" Stroke="Black" StrokeThickness="2" StrokeDashArray="2" />
+                        <Line
+                            Stroke="Black"
+                            StrokeDashArray="2"
+                            StrokeThickness="2"
+                            X1="10"
+                            X2="90"
+                            Y1="5"
+                            Y2="5" />
                     </RadioButton.Content>
                 </RadioButton>
             </StackPanel>