Browse Source

综合-筛选UI、书签快捷键、手绘初始值、注释工具本地缓存

OYXH\oyxh 2 years ago
parent
commit
0fa7664693

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

@@ -282,6 +282,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = highlightArgs.EventType;
                     defaultAnnot.ForgoundColor = (highLightColor as SolidColorBrush).Color;
                     defaultAnnot.Opacity = 1;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -347,6 +348,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = underlineArgs.EventType;
                     defaultAnnot.ForgoundColor = (UnderLineColor as SolidColorBrush).Color;
                     defaultAnnot.Opacity = 1;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -386,6 +388,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = squigglyArgs.EventType;
                     defaultAnnot.ForgoundColor = (squigglyColor as SolidColorBrush).Color;
                     defaultAnnot.Opacity = 1;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -425,6 +428,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = strikeoutArgs.EventType;
                     defaultAnnot.ForgoundColor = (strikeoutColor as SolidColorBrush).Color;
                     defaultAnnot.Opacity = 1;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -471,6 +475,8 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = freehandArgs.EventType;
                     defaultAnnot.ForgoundColor = annotate.FreeHandColor;
                     defaultAnnot.Opacity = 1;
+                    defaultAnnot.Thickness = 2;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -545,7 +551,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.TextAlign = TextAlignment.Left;
                     defaultAnnot.Thickness = 0;
                     defaultAnnot.NoteText = string.Empty;
-
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -614,6 +620,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = stickyAnnotArgs.EventType;
                     defaultAnnot.NoteText = string.Empty;
                     defaultAnnot.Opacity = 1;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -669,6 +676,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.AnnotToolType = squareArgs.EventType;
                     defaultAnnot.Thickness = 1;
                     defaultAnnot.Opacity = 1;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -741,6 +749,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.Opacity = 1;
                     defaultAnnot.NoteText = string.Empty;
                     defaultAnnot.DashArray = null;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 
@@ -821,6 +830,7 @@ namespace PDF_Office.ViewModels.Tools
                     defaultAnnot.Opacity = 1;
                     defaultAnnot.NoteText = string.Empty;
                     defaultAnnot.DashArray = null;
+                    SettingHelper.SetAnnotDefaultProperty(defaultAnnot);
                     Settings.Default.Save();
                 }
 

+ 3 - 2
PDF Office/Views/BOTA/BookmarkContent.xaml

@@ -10,9 +10,9 @@
     xmlns:helper="clr-namespace:PDF_Office.Helper"
     xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
     xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
+    xmlns:mainPageLoader="clr-namespace:PDF_Office.Strings.MainPage"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:prism="http://prismlibrary.com/"
-    xmlns:mainPageLoader="clr-namespace:PDF_Office.Strings.MainPage"
     d:DataContext="{d:DesignInstance Type=bota:BookmarkContentViewModel}"
     d:DesignHeight="450"
     d:DesignWidth="300"
@@ -145,12 +145,13 @@
                 BorderThickness="0"
                 ItemTemplate="{StaticResource myDataTemplate}"
                 ItemsSource="{Binding Bookmarklist}"
+                PreviewMouseDown="BookMarkListView_PreviewMouseDown"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 SelectionChanged="BookMarkListView_SelectionChanged"
                 VirtualizingPanel.CacheLength="1"
                 VirtualizingPanel.CacheLengthUnit="Page"
                 VirtualizingPanel.IsVirtualizing="True"
-                VirtualizingPanel.ScrollUnit="Pixel" KeyDown="BookMarkListView_KeyDown" PreviewMouseDown="BookMarkListView_PreviewMouseDown">
+                VirtualizingPanel.ScrollUnit="Pixel">
                 <ListView.ItemsPanel>
                     <ItemsPanelTemplate>
                         <VirtualizingStackPanel Margin="-5,0,0,0" Background="Transparent" />

+ 335 - 320
PDF Office/Views/BOTA/BookmarkContent.xaml.cs

@@ -21,357 +21,372 @@ using static Dropbox.Api.Sharing.ListFileMembersIndividualResult;
 
 namespace PDF_Office.Views.BOTA
 {
-    /// <summary>
+/// <summary>
     /// BookmarkContent.xaml 的交互逻辑
-    /// </summary>
-    public partial class BookmarkContent : UserControl
-    {
-        private BookmarkContentViewModel viewModel = null;
+/// </summary>
+public partial class BookmarkContent : UserControl
+{
+private BookmarkContentViewModel viewModel = null;
 
-        /// <summary>
-        /// 上一个ListBoxItem,为选中状态做准备
-        /// </summary>
-        private ListBoxItem histotyListBoxItem = null;
+/// <summary>
+    /// 上一个ListBoxItem,为选中状态做准备
+/// </summary>
+private ListBoxItem histotyListBoxItem = null;
 
-        private bool isAdd = false;
+private bool isAdd = false;
 
-        public BookmarkContent()
-        {
-            InitializeComponent();
-            viewModel = this.DataContext as BookmarkContentViewModel;
-        }
+public BookmarkContent()
+{
+InitializeComponent();
+viewModel = this.DataContext as BookmarkContentViewModel;
+KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
+KeyEventsHelper.KeyDown += ShortCut_KeyDown;
+}
 
-        /// <summary>
-        ///ListViewItem,鼠标左键点击
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ListViewItem_MouseButtonDown(object sender, MouseButtonEventArgs e)
-        {
-            object[] objects = new object[] { sender, e };
-            TextBlock textBlock = null;
-            ListViewItem listBoxItem = (sender as ListViewItem);
-            if (e.LeftButton == MouseButtonState.Pressed)
-            {
-                if (e.ClickCount >= 2)
-                {
-                    histotyListBoxItem = listBoxItem;
-                    if (e.OriginalSource is TextBlock)
-                    {
-                        textBlock = (TextBlock)e.OriginalSource;
+private void ShortCut_KeyDown(object sender, KeyEventArgs e)
+{
+if (KeyEventsHelper.IsSingleKey(Key.Escape))
+{
+if (BookMarkListView.SelectedItems == null)
+{
+return;
+}
 
-                        if (textBlock != null)
-                        {
-                            TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listBoxItem);
+BookMarkListView.SelectedItems.Clear();
+}
+}
 
-                            SetSelectedStatus(listBoxItem, textBox, textBlock);
-                        }
-                    }
-                }
-                else if (e.ClickCount == 1)
-                {
-                    if (histotyListBoxItem != listBoxItem)
-                    {
-                        if (histotyListBoxItem != null)
-                        {
-                            histotyListBoxItem.IsSelected = false;
-                            textBlock = CommonHelper.FindVisualChild<TextBlock>(histotyListBoxItem);
-                            textBlock.Visibility = Visibility.Visible;
-                            textBlock.Focusable = true;
-                        }
-                    }
+/// <summary>
+    ///ListViewItem,鼠标左键点击
+/// </summary>
+/// <param name="sender"></param>
+/// <param name="e"></param>
+private void ListViewItem_MouseButtonDown(object sender, MouseButtonEventArgs e)
+{
+object[] objects = new object[] { sender, e };
+TextBlock textBlock = null;
+ListViewItem listBoxItem = (sender as ListViewItem);
+if (e.LeftButton == MouseButtonState.Pressed)
+{
+if (e.ClickCount >= 2)
+    {
+    histotyListBoxItem = listBoxItem;
+    if (e.OriginalSource is TextBlock)
+    {
+    textBlock = (TextBlock)e.OriginalSource;
 
-                    viewModel.ListViewItemMouseDownCommand.Execute(sender);
-                }
+    if (textBlock != null)
+    {
+    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listBoxItem);
+
+        SetSelectedStatus(listBoxItem, textBox, textBlock);
+        }
+        }
+        }
+        else if (e.ClickCount == 1)
+        {
+        if (histotyListBoxItem != listBoxItem)
+        {
+        if (histotyListBoxItem != null)
+        {
+        histotyListBoxItem.IsSelected = false;
+        textBlock = CommonHelper.FindVisualChild<TextBlock>(histotyListBoxItem);
+            textBlock.Visibility = Visibility.Visible;
+            textBlock.Focusable = true;
+            }
+            }
+
+            viewModel.ListViewItemMouseDownCommand.Execute(sender);
+            }
             }
             else if (e.RightButton == MouseButtonState.Pressed)
             {
-                ContextMenu contextMenu = listBoxItem.ContextMenu;
-                if (contextMenu.Items.Count == 3)
-                {
-                    MenuItem rename = contextMenu.Items[0] as MenuItem;
-                    MenuItem editPageIndex = contextMenu.Items[1] as MenuItem;
-                    MenuItem del = contextMenu.Items[2] as MenuItem;
-                    if (isSelects)
-                    {
-                        rename.IsEnabled = false;
-                        editPageIndex.IsEnabled = false;
-                        isSelects = false;
-                    }
-                    else
-                    {
-                        CPDFBookmark bookmark = (CPDFBookmark)listBoxItem.DataContext;
-                        if (viewModel.PDFViewer.CurrentIndex == bookmark.PageIndex)
-                        {
-                            editPageIndex.IsEnabled = false;
-                            return;
-                        }
-                        rename.IsEnabled = true;
-                        editPageIndex.IsEnabled = true;
-                        editPageIndex.CommandParameter = listBoxItem.DataContext;
-                        editPageIndex.Command = viewModel.EditPageIndexCommand;
-                    }
-                }
+            ContextMenu contextMenu = listBoxItem.ContextMenu;
+            if (contextMenu.Items.Count == 3)
+            {
+            MenuItem rename = contextMenu.Items[0] as MenuItem;
+            MenuItem editPageIndex = contextMenu.Items[1] as MenuItem;
+            MenuItem del = contextMenu.Items[2] as MenuItem;
+            if (isSelects)
+            {
+            rename.IsEnabled = false;
+            editPageIndex.IsEnabled = false;
+            isSelects = false;
             }
-        }
-
-        private bool isSelects = false;
-
-        private void BookMarkListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            var a1 = (sender as ListView).SelectedItems.Count;
-            if (a1 > 1)
+            else
             {
-                isSelects = true;
+            CPDFBookmark bookmark = (CPDFBookmark)listBoxItem.DataContext;
+            if (viewModel.PDFViewer.CurrentIndex == bookmark.PageIndex)
+            {
+            editPageIndex.IsEnabled = false;
+            return;
+            }
+            rename.IsEnabled = true;
+            editPageIndex.IsEnabled = true;
+            editPageIndex.CommandParameter = listBoxItem.DataContext;
+            editPageIndex.Command = viewModel.EditPageIndexCommand;
+            }
+            }
+            }
             }
-        }
-
-        /// <summary>
-        /// ListViewItem双击时选中状态
-        /// </summary>
-        /// <param name="listBoxItem"></param>
-        /// <param name="textBox"></param>
-        /// <param name="textBlock"></param>
-        private void SetSelectedStatus(ListBoxItem listBoxItem, TextBox textBox, TextBlock textBlock)
-        {
-            listBoxItem.IsSelected = true;
-            listBoxItem.Focus();
-            textBlock.Visibility = Visibility.Collapsed;
 
-            textBox.Dispatcher.BeginInvoke(new Action(() =>
-            {
-                textBox.Focus();
-                textBox.SelectAll();
-                //listBoxItem.IsSelected = true;
-            }));
-        }
+            private bool isSelects = false;
 
-        /// <summary>
-        /// ListViewItem失去焦点
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ListViewItem_LostFocus(object sender, RoutedEventArgs e)
-        {
-            ListViewItem listItem = sender as ListViewItem;
-            if (listItem != null)
+            private void BookMarkListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
             {
-                BookMarkListView.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
-                viewModel.LostFocusCommand.Execute(listItem);
-
-                TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listItem);
-                TextBox text = CommonHelper.FindVisualChild<TextBox>(listItem);
+            var a1 = (sender as ListView).SelectedItems.Count;
+if (a1 > 1)
+                {
+                isSelects = true;
+                }
+                }
 
-                if (textBlock.Visibility != Visibility.Visible)
+                /// <summary>
+                    /// ListViewItem双击时选中状态
+                /// </summary>
+                /// <param name="listBoxItem"></param>
+                /// <param name="textBox"></param>
+                /// <param name="textBlock"></param>
+                private void SetSelectedStatus(ListBoxItem listBoxItem, TextBox textBox, TextBlock textBlock)
                 {
-                    if (isAdd == false && isRename == false)
+                listBoxItem.IsSelected = true;
+                listBoxItem.Focus();
+                textBlock.Visibility = Visibility.Collapsed;
+
+textBox.Dispatcher.BeginInvoke(new Action(() =>
                     {
-                        listItem.IsSelected = false;
+                    textBox.Focus();
+                    textBox.SelectAll();
+                    //listBoxItem.IsSelected = true;
+                    }));
                     }
-                    else
+
+                    /// <summary>
+                        /// ListViewItem失去焦点
+                    /// </summary>
+                    /// <param name="sender"></param>
+                    /// <param name="e"></param>
+                    private void ListViewItem_LostFocus(object sender, RoutedEventArgs e)
                     {
-                        listItem.IsSelected = true;
-                        isAdd = false;
-                    }
-                    if (text.IsSelectionActive == true)
+                    ListViewItem listItem = sender as ListViewItem;
+                    if (listItem != null)
                     {
-                        textBlock.Visibility = Visibility.Visible;
-                    }
-                }
-                else
-                {
-                    listItem.IsSelected = true;
-                }
+                    BookMarkListView.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
+                    viewModel.LostFocusCommand.Execute(listItem);
 
-                //if (histotyListBoxItem != null)
-                //{
-                //    histotyListBoxItem.IsSelected = false;
-                //    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(histotyListBoxItem);
-                //    textBlock.Visibility = Visibility.Visible;
-                //    textBlock.Focusable = true;
-                //}
-                //if (textBlock.Visibility == Visibility.Collapsed)
-                //{
-                //    listItem.IsSelected = false;
-                //    //textBlock.Visibility = Visibility.Visible;
-                //}
-                //else
-                //{
-                //    listItem.IsSelected = true;
-                //    //textBlock.Visibility = Visibility.Collapsed;
-                //}
-            }
-        }
+                    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listItem);
+                        TextBox text = CommonHelper.FindVisualChild<TextBox>(listItem);
 
-        private bool isRename = false;
+                            if (textBlock.Visibility != Visibility.Visible)
+                            {
+                            if (isAdd == false && isRename == false)
+                            {
+                            listItem.IsSelected = false;
+                            }
+                            else
+                            {
+                            listItem.IsSelected = true;
+                            isAdd = false;
+                            }
+                            if (text.IsSelectionActive == true)
+                            {
+                            textBlock.Visibility = Visibility.Visible;
+                            }
+                            }
+                            else
+                            {
+                            listItem.IsSelected = true;
+                            }
 
-        /// <summary>
-        /// 右键菜单-重命名
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void MenuItemRename_Click(object sender, RoutedEventArgs e)
-        {
-            if (sender is MenuItem)
-            {
-                MenuItem menuItem = (MenuItem)sender;
-                CPDFBookmark bookmark = menuItem.CommandParameter as CPDFBookmark;
-                if (bookmark != null)
-                {
-                    BookMarkListView.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
-                    isRename = true;
-                    ListViewItem listBoxItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(bookmark));
-                    histotyListBoxItem = listBoxItem;
+                            //if (histotyListBoxItem != null)
+                            //{
+                            //    histotyListBoxItem.IsSelected = false;
+                            //    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(histotyListBoxItem);
+                                //    textBlock.Visibility = Visibility.Visible;
+                                //    textBlock.Focusable = true;
+                                //}
+                                //if (textBlock.Visibility == Visibility.Collapsed)
+                                //{
+                                //    listItem.IsSelected = false;
+                                //    //textBlock.Visibility = Visibility.Visible;
+                                //}
+                                //else
+                                //{
+                                //    listItem.IsSelected = true;
+                                //    //textBlock.Visibility = Visibility.Collapsed;
+                                //}
+                                }
+                                }
 
-                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listBoxItem);
-                    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listBoxItem);
-                    SetSelectedStatus(listBoxItem, textBox, textBlock);
-                }
-            }
-        }
+                                private bool isRename = false;
 
-        /// <summary>
-        /// BookMarkListView,鼠标点击
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void BookMarkListView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
-        {
-            if (e.LeftButton == MouseButtonState.Pressed)
-            {
-                var pos = e.GetPosition(BookMarkListView);
+                                /// <summary>
+                                    /// 右键菜单-重命名
+                                /// </summary>
+                                /// <param name="sender"></param>
+                                /// <param name="e"></param>
+                                private void MenuItemRename_Click(object sender, RoutedEventArgs e)
+                                {
+                                if (sender is MenuItem)
+                                {
+                                MenuItem menuItem = (MenuItem)sender;
+                                CPDFBookmark bookmark = menuItem.CommandParameter as CPDFBookmark;
+                                if (bookmark != null)
+                                {
+                                BookMarkListView.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
+                                isRename = true;
+                                ListViewItem listBoxItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(bookmark));
+                                histotyListBoxItem = listBoxItem;
 
-                var result = VisualTreeHelper.HitTest(BookMarkListView, pos);
-                if (result != null)
-                {
-                    //获取当前鼠标指针下的容器
-                    var listBoxItem = CommonHelper.FindVisualParent<ListViewItem>(result.VisualHit);
-                    if (listBoxItem == null)
-                    {
-                        if (BookMarkListView.SelectedItem != null)
-                        {
-                            ListViewItem item = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(BookMarkListView.SelectedItem));
-                            item.IsSelected = false;
-                            TextBlock box = CommonHelper.FindVisualChild<TextBlock>(item);
-                            box.Visibility = Visibility.Visible;
-                            BookMarkListView.SelectedItems.Clear();
-                        }
-                        if (histotyListBoxItem != null)
-                        {
-                            var pos1 = e.GetPosition(histotyListBoxItem);
-                            var result1 = VisualTreeHelper.HitTest(BookMarkListView, pos1);
-                            if (result1 == null)
-                            {
-                                histotyListBoxItem.IsSelected = false;
-                                TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(histotyListBoxItem);
-                                textBlock.Visibility = Visibility.Visible;
-                                textBlock.Focusable = true;
-                            }
-                        }
-                    }
-                    else
-                    {
-                        TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listBoxItem);
-                        TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listBoxItem);
-                        if (textBox.IsFocused == false)
-                        {
-                            listBoxItem.Focus();
-                        }
-                    }
-                }
-                //BookMarkListView.Focus();
-            }
-        }
+                                TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listBoxItem);
+                                    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listBoxItem);
+                                        SetSelectedStatus(listBoxItem, textBox, textBlock);
+                                        }
+                                        }
+                                        }
 
-        /// <summary>
-        /// 右键菜单-删除
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void MenuItemDeleteCommand_Click(object sender, RoutedEventArgs e)
-        {
-            List<int> pagelist = new List<int>();
-            for (int i = 0; i < BookMarkListView.SelectedItems.Count; i++)
-            {
-                CPDFBookmark item = BookMarkListView.SelectedItems[i] as CPDFBookmark;
-                pagelist.Add(BookMarkListView.Items.IndexOf(item));
-            }
-            pagelist.Sort();
-            for (int i = 0; i < pagelist.Count; i++)
-            {
-                CPDFBookmark data = BookMarkListView.Items[pagelist[pagelist.Count - i - 1]] as CPDFBookmark;
-                if (data != null)
-                {
-                    viewModel.DeleteCommand.Execute(data);
-                }
-            }
-        }
+                                        /// <summary>
+                                            /// BookMarkListView,鼠标点击
+                                        /// </summary>
+                                        /// <param name="sender"></param>
+                                        /// <param name="e"></param>
+                                        private void BookMarkListView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+                                        {
+                                        if (e.LeftButton == MouseButtonState.Pressed)
+                                        {
+                                        var pos = e.GetPosition(BookMarkListView);
 
-        public void BtnAddBookmark_Click(object sender, RoutedEventArgs e)
-        {
-            isAdd = true;
-            viewModel.AddBookmarkCommand.Execute(BookMarkListView);
-            if (viewModel.IsHasBookmark == false)
-            {
-                BookMarkListView.ScrollIntoView(viewModel.AddCPDFBookmark);
-                ListViewItem myListBoxItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(viewModel.AddCPDFBookmark));
-                if (myListBoxItem == null)
-                {
-                    BookMarkListView.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
-                    BookMarkListView.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
-                }
-                else
-                {
-                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
-                    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
+                                        var result = VisualTreeHelper.HitTest(BookMarkListView, pos);
+                                        if (result != null)
+                                        {
+                                        //获取当前鼠标指针下的容器
+                                        var listBoxItem = CommonHelper.FindVisualParent<ListViewItem>(result.VisualHit);
+                                            if (listBoxItem == null)
+                                            {
+                                            if (BookMarkListView.SelectedItem != null)
+                                            {
+                                            ListViewItem item = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(BookMarkListView.SelectedItem));
+                                            item.IsSelected = false;
+                                            TextBlock box = CommonHelper.FindVisualChild<TextBlock>(item);
+                                                box.Visibility = Visibility.Visible;
+                                                BookMarkListView.SelectedItems.Clear();
+                                                }
+                                                if (histotyListBoxItem != null)
+                                                {
+                                                var pos1 = e.GetPosition(histotyListBoxItem);
+                                                var result1 = VisualTreeHelper.HitTest(BookMarkListView, pos1);
+                                                if (result1 == null)
+                                                {
+                                                histotyListBoxItem.IsSelected = false;
+                                                TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(histotyListBoxItem);
+                                                    textBlock.Visibility = Visibility.Visible;
+                                                    textBlock.Focusable = true;
+                                                    }
+                                                    }
+                                                    }
+                                                    else
+                                                    {
+                                                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listBoxItem);
+                                                        TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(listBoxItem);
+                                                            if (textBox.IsFocused == false)
+                                                            {
+                                                            listBoxItem.Focus();
+                                                            }
+                                                            }
+                                                            }
+                                                            //BookMarkListView.Focus();
+                                                            }
+                                                            }
 
-                    SetSelectedStatus(myListBoxItem, textBox, textBlock);
-                }
-            }
-        }
+                                                            /// <summary>
+                                                                /// 右键菜单-删除
+                                                            /// </summary>
+                                                            /// <param name="sender"></param>
+                                                            /// <param name="e"></param>
+                                                            private void MenuItemDeleteCommand_Click(object sender, RoutedEventArgs e)
+                                                            {
+                                                            List<int> pagelist = new List<int>();
+                                                                    for (int i = 0; i < BookMarkListView.SelectedItems.Count; i++)
+                                                                      {
+                                                                      CPDFBookmark item = BookMarkListView.SelectedItems[i] as CPDFBookmark;
+                                                                      pagelist.Add(BookMarkListView.Items.IndexOf(item));
+                                                                      }
+                                                                      pagelist.Sort();
+                                                                    for (int i = 0; i < pagelist.Count; i++)
+                                                                      {
+                                                                      CPDFBookmark data = BookMarkListView.Items[pagelist[pagelist.Count - i - 1]] as CPDFBookmark;
+                                                                      if (data != null)
+                                                                      {
+                                                                      viewModel.DeleteCommand.Execute(data);
+                                                                      }
+                                                                      }
+                                                                      }
 
-        private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
-        {
-            ItemContainerGenerator itemContainer = sender as ItemContainerGenerator;
-            if (itemContainer.Status == GeneratorStatus.ContainersGenerated)
-            {
-                BookMarkListView.ScrollIntoView(viewModel.AddCPDFBookmark);
-                ListViewItem myListBoxItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(viewModel.AddCPDFBookmark));
-                if (myListBoxItem != null)
-                {
-                    if (myListBoxItem.RenderSize.Width < 0 && myListBoxItem.RenderSize.Height < 0)
-                    {
-                        BookMarkListView.UpdateLayout();
-                        myListBoxItem.UpdateLayout();
-                        BookMarkListView.ScrollIntoView(viewModel.AddCPDFBookmark);
-                    }
-                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
-                    TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
-                    SetSelectedStatus(myListBoxItem, textBox, textBlock);
-                }
-            }
-        }
+                                                                      public void BtnAddBookmark_Click(object sender, RoutedEventArgs e)
+                                                                      {
+                                                                      isAdd = true;
+                                                                      viewModel.AddBookmarkCommand.Execute(BookMarkListView);
+                                                                      if (viewModel.IsHasBookmark == false)
+                                                                      {
+                                                                      BookMarkListView.ScrollIntoView(viewModel.AddCPDFBookmark);
+                                                                      ListViewItem myListBoxItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(viewModel.AddCPDFBookmark));
+                                                                      if (myListBoxItem == null)
+                                                                      {
+                                                                      BookMarkListView.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
+                                                                      BookMarkListView.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
+                                                                      }
+                                                                      else
+                                                                      {
+                                                                    TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
+                                                                        TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
 
-        private void BookMarkListView_KeyDown(object sender, KeyEventArgs e)
-        {
-            if (BookMarkListView.SelectedItems == null)
-            {
-                return;
-            }
-            if (e.Key == Key.Escape)
-            {
-                BookMarkListView.SelectedItems.Clear();
-            }
-            if (e.Key == Key.Delete)
-            {
-                if (BookMarkListView.SelectedItems.Count > 0)
-                {
-                    //全选删除
-                    if (BookMarkListView.SelectedItems.Count == BookMarkListView.Items.Count)
-                    {
-                    }
-                }
-            }
-        }
-    }
-}
+                                                                            SetSelectedStatus(myListBoxItem, textBox, textBlock);
+                                                                            }
+                                                                            }
+                                                                            }
+
+                                                                            private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
+                                                                            {
+                                                                            ItemContainerGenerator itemContainer = sender as ItemContainerGenerator;
+                                                                            if (itemContainer.Status == GeneratorStatus.ContainersGenerated)
+                                                                            {
+                                                                            BookMarkListView.ScrollIntoView(viewModel.AddCPDFBookmark);
+                                                                            ListViewItem myListBoxItem = (ListViewItem)(BookMarkListView.ItemContainerGenerator.ContainerFromItem(viewModel.AddCPDFBookmark));
+                                                                            if (myListBoxItem != null)
+                                                                            {
+                                                                            if (myListBoxItem.RenderSize.Width < 0 && myListBoxItem.RenderSize.Height < 0)
+                                                                              {
+                                                                              BookMarkListView.UpdateLayout();
+                                                                              myListBoxItem.UpdateLayout();
+                                                                              BookMarkListView.ScrollIntoView(viewModel.AddCPDFBookmark);
+                                                                              }
+                                                                            TextBox textBox = CommonHelper.FindVisualChild<TextBox>(myListBoxItem);
+                                                                                TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(myListBoxItem);
+                                                                                    SetSelectedStatus(myListBoxItem, textBox, textBlock);
+                                                                                    }
+                                                                                    }
+                                                                                    }
+
+                                                                                    private void BookMarkListView_KeyDown(object sender, KeyEventArgs e)
+                                                                                    {
+                                                                                    if (BookMarkListView.SelectedItems == null)
+                                                                                    {
+                                                                                    return;
+                                                                                    }
+                                                                                    if (e.Key == Key.Escape)
+                                                                                    {
+                                                                                    BookMarkListView.SelectedItems.Clear();
+                                                                                    }
+                                                                                    //if (e.Key == Key.Delete)
+                                                                                    //{
+                                                                              //    if (BookMarkListView.SelectedItems.Count > 0)
+                                                                                        //    {
+                                                                                        //        //全选删除
+                                                                                        //        if (BookMarkListView.SelectedItems.Count == BookMarkListView.Items.Count)
+                                                                                        //        {
+                                                                                        //        }
+                                                                                        //    }
+                                                                                        //}
+                                                                                        }
+                                                                                        }
+                                                                                        }

+ 1 - 1
PDF Office/Views/Dialog/BOTA/ScreenAnnotationDialog.xaml

@@ -552,7 +552,7 @@
                         Content="{Binding T_Cancel}"
                         FontFamily="Segoe UI"
                         FontSize="14"
-                        Style="{StaticResource Btn.cta}" />
+                        Style="{StaticResource btn.sec}" />
                 </StackPanel>
             </Grid>
         </customControl:DialogContent.BottmBar>