Browse Source

内容选择 快捷键补充、文案修正

OYXH\oyxh 2 years ago
parent
commit
5f970ab0ac

+ 3 - 3
PDF Office/Styles/ContextMenuStyle.xaml

@@ -81,7 +81,7 @@
         <MenuItem
             Name="BtnSnapCopy"
             Header="{x:Static mainpage:MainPage.ContentSelection_Copy}"
-            IsEnabled="True">
+            IsEnabled="True" InputGestureText="Ctrl+C">
             <!--<MenuItem.Icon>
             <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
             <Path.RenderTransform>
@@ -136,7 +136,7 @@
         <MenuItem
             Name="BtnSnapPrint"
             Header="{x:Static mainpage:MainPage.ContentSelection_Print}"
-            IsEnabled="True">
+            IsEnabled="True" InputGestureText="Ctrl+P">
             <!--<MenuItem.Icon>
             <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
             <Path.RenderTransform>
@@ -167,7 +167,7 @@
     <!--  阅读页点击空白处菜单  -->
     <ContextMenu x:Key="ViewerContextMenu" FontSize="14">
         <MenuItem
-            Header="{x:Static mainpage:MainPage.ViewRightMenu_Copy}"
+            Header="{x:Static mainpage:MainPage.ViewRightMenu_Paste}"
             InputGestureText="Ctrl+V"
             Tag="Paste" />
         <Separator

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

@@ -683,6 +683,7 @@ namespace PDF_Office.ViewModels.Tools
                     menuItem = popMenu.Items[4] as MenuItem;
                     menuItem.CommandTarget = PDFViewer;
                     menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
+
                 }
             }
         }
@@ -839,7 +840,7 @@ namespace PDF_Office.ViewModels.Tools
                 hoverPen.DashStyle = DashStyles.Dash;
                 e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
 
-                
+
                 //便签,显示ToolTip内容
                 if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
                 {

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

@@ -1085,14 +1085,19 @@ namespace PDF_Office.ViewModels.Tools
                         //stickyAnnotArgs.ClientRect = new Rect(textSelectNodes[0].StartPoint.X, annotCommand.TextRect.Y - annotCommand.TextRect.Height, annotCommand.TextRect.Width, annotCommand.TextRect.Height);
                         Rect rect = annotCommand.TextRectList[0];
 
-                        int dpi = DpiHelpers.Dpi;
-                        double x = rect.X / 72D * dpi;
-                        double y = (rect.Y - rect.Height) / 72D * dpi;
-                        double width = rect.Width / 72D * dpi;
-                        double height = rect.Height / 72D * dpi;
+                        #region to do 转dpi
 
-                        stickyAnnotArgs.ClientRect = new Rect(x, y, width, height);
+                        //int dpi = DpiHelpers.Dpi;
+                        //double x = rect.X / 72D * dpi;
+                        //double y = (rect.Y - rect.Height) / 72D * dpi;
+                        //double width = rect.Width / 72D * dpi;
+                        //double height = rect.Height / 72D * dpi;
+
+                        #endregion to do 转dpi
+
+                        //stickyAnnotArgs.ClientRect = new Rect(x, y, width, height);
                         //stickyAnnotArgs.ClientRect = new Rect(rect.X, rect.Y - rect.Height, rect.Width, rect.Height);
+                        stickyAnnotArgs.ClientRect = rect;
                         //PDFViewer.CreatePageAnnot(annotCommand.PageIndex, stickyAnnotArgs);
                         NavigationParameters param = new NavigationParameters();
                         param.Add(ParameterNames.PDFViewer, PDFViewer);

+ 39 - 20
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -1595,20 +1595,15 @@ namespace PDF_Office.ViewModels
                 //内容选择 退出
                 if (PDFViewer.MouseMode != MouseModes.PanTool)
                 {
-                    if (region.Regions.ContainsRegionWithName(ToolsBarContentRegionName))
+                    AnnotToolContent annotToolContent = GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel);
+                    if (annotToolContent != null && toolContentViewModel != null)
                     {
-                        var views = region.Regions[ToolsBarContentRegionName].Views;
-                        var model = views.FirstOrDefault(q => q is AnnotToolContent);
-                        if (model is AnnotToolContent annotToolContent)
+                        if (annotToolContent.BtnSelecttool.IsChecked == true)
                         {
-                            AnnotToolContentViewModel toolContentViewModel = annotToolContent.DataContext as AnnotToolContentViewModel;
-                            if (annotToolContent.BtnSelecttool.IsChecked == true)
+                            if (toolContentViewModel.SnapshotEditMenuViewModel.SnapToolArgs != null)
                             {
-                                if (toolContentViewModel.SnapshotEditMenuViewModel.SnapToolArgs != null)
-                                {
-                                    toolContentViewModel.SnapshotEditMenuViewModel.SnapToolArgs.ReSnapshot();
-                                    annotToolContent.BtnSelecttool.IsChecked = false;
-                                }
+                                toolContentViewModel.SnapshotEditMenuViewModel.SnapToolArgs.ReSnapshot();
+                                annotToolContent.BtnSelecttool.IsChecked = false;
                             }
                         }
                     }
@@ -1616,20 +1611,44 @@ namespace PDF_Office.ViewModels
             }
             if (KeyEventsHelper.IsModifierKey(ModifierKeys.Control, Key.C))
             {
-                if (region.Regions.ContainsRegionWithName(ToolsBarContentRegionName))
+                //内容选择 复制 快捷键
+                AnnotToolContent annotToolContent = GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel);
+                if (annotToolContent != null && toolContentViewModel != null)
                 {
-                    var views = region.Regions[ToolsBarContentRegionName].Views;
-                    var model = views.FirstOrDefault(q => q is AnnotToolContent);
-                    if (model is AnnotToolContent annotToolContent)
+                    if (annotToolContent.BtnSelecttool.IsChecked == true)
                     {
-                        AnnotToolContentViewModel toolContentViewModel = annotToolContent.DataContext as AnnotToolContentViewModel;
-                        if (annotToolContent.BtnSelecttool.IsChecked == true)
-                        {
-                            toolContentViewModel.SnapshotEditMenuViewModel.SnapCopyCommand.Execute();
-                        }
+                        toolContentViewModel.SnapshotEditMenuViewModel.SnapCopyCommand.Execute();
                     }
                 }
             }
+            if (KeyEventsHelper.IsModifierKey(ModifierKeys.Control, Key.P))
+            {
+                AnnotToolContent annotToolContent = GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel);
+                if (annotToolContent != null && toolContentViewModel != null)
+                {
+                    if (annotToolContent.BtnSelecttool.IsChecked == true)
+                    {
+                        toolContentViewModel.SnapshotEditMenuViewModel.PrintCommand.Execute();
+                    }
+                }
+            }
+        }
+
+        private AnnotToolContent GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel)
+        {
+            AnnotToolContent toolContent = null;
+            toolContentViewModel = null;
+            if (region.Regions.ContainsRegionWithName(ToolsBarContentRegionName))
+            {
+                var views = region.Regions[ToolsBarContentRegionName].Views;
+                var model = views.FirstOrDefault(q => q is AnnotToolContent);
+                if (model is AnnotToolContent annotToolContent)
+                {
+                    toolContent = annotToolContent;
+                    toolContentViewModel = annotToolContent.DataContext as AnnotToolContentViewModel;
+                }
+            }
+            return toolContent;
         }
 
         /// <summary>