Parcourir la source

其他-补充页面滚动快捷键

ZhouJieSheng il y a 1 an
Parent
commit
23d38a9c0e

+ 4 - 0
PDF Office/Helper/GlobalCommands.cs

@@ -23,5 +23,9 @@ namespace PDF_Master.Helper
         public static CompositeCommand PreViewCommand = new CompositeCommand();
         public static CompositeCommand PreViewCommand = new CompositeCommand();
 
 
         public static CompositeCommand NextViewCommand = new CompositeCommand();
         public static CompositeCommand NextViewCommand = new CompositeCommand();
+
+        public static CompositeCommand UpCommand = new CompositeCommand();
+
+        public static CompositeCommand DownCommand = new CompositeCommand();
     }
     }
 }
 }

+ 61 - 2
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -107,6 +107,10 @@ namespace PDF_Master.ViewModels
 
 
         public DelegateCommand<object> ShowViewModularCommand { get; set; }
         public DelegateCommand<object> ShowViewModularCommand { get; set; }
 
 
+        public DelegateCommand UpCommand { get; set; }
+
+        public DelegateCommand DownCommand { get; set; }
+
         /// <summary>
         /// <summary>
         /// 上一个视图
         /// 上一个视图
         /// </summary>
         /// </summary>
@@ -286,6 +290,11 @@ namespace PDF_Master.ViewModels
 
 
         private int oldPageIndex = 0;
         private int oldPageIndex = 0;
 
 
+        /// <summary>
+        /// 上下滑动的固定值
+        /// </summary>
+        private double scrolloffset = 50;
+
         private IRegionManager region;
         private IRegionManager region;
 
 
         private IDialogService dialogs;
         private IDialogService dialogs;
@@ -310,20 +319,66 @@ namespace PDF_Master.ViewModels
 
 
             NextViewCommnad = new DelegateCommand(redo);
             NextViewCommnad = new DelegateCommand(redo);
 
 
+            UpCommand = new DelegateCommand(up);
+
+            DownCommand = new DelegateCommand(down);
+
             //注册成全局命令
             //注册成全局命令
             GlobalCommands.FirstPageCommand.RegisterCommand(FirstPageCommand);
             GlobalCommands.FirstPageCommand.RegisterCommand(FirstPageCommand);
             GlobalCommands.LastPageCommand.RegisterCommand(LastPageCommand);
             GlobalCommands.LastPageCommand.RegisterCommand(LastPageCommand);
             GlobalCommands.NextPageCommand.RegisterCommand(NextPageCommand);
             GlobalCommands.NextPageCommand.RegisterCommand(NextPageCommand);
             GlobalCommands.PrePageCommand.RegisterCommand(PrePageCommand);
             GlobalCommands.PrePageCommand.RegisterCommand(PrePageCommand);
             GlobalCommands.PreViewCommand.RegisterCommand(PreViewCommand);
             GlobalCommands.PreViewCommand.RegisterCommand(PreViewCommand);
-            GlobalCommands.NextViewCommand.RegisterCommand(NextViewCommnad);
+            GlobalCommands.NextViewCommand.RegisterCommand(NextViewCommnad);
+            GlobalCommands.UpCommand.RegisterCommand(UpCommand);
+            GlobalCommands.DownCommand.RegisterCommand(DownCommand);
 
 
 
 
             InitString();
             InitString();
         }
         }
 
 
+        private void up()
+        {
+            //连续模式下下滑固定距离
+            if (((int)PDFViewer.ModeView)%2 == 0)
+            {
+                PDFViewer.ScrollToVerticalOffset(PDFViewer.GetVerticalOffset()-scrolloffset);
+            }
+            else
+            {
+                //非连续模式下翻页
+                if(CanPrePageExcute())
+                {
+                    PrePageCommand.Execute();
+                }
+            }
+
+        }
+
+        private void down()
+        {
+            //连续模式下下滑固定距离
+            if (((int)PDFViewer.ModeView) % 2 == 0)
+            {
+                PDFViewer.ScrollToVerticalOffset(PDFViewer.GetVerticalOffset()+scrolloffset);
+            }
+            else
+            {
+                //非连续模式下翻页
+                if (CanNextPageExcute())
+                {
+                    NextPageCommand.Execute();
+                }
+            }
+        }
+
         private void undo()
         private void undo()
         {
         {
+            if(!IsPreEnable)
+            {
+                return;
+            }
+
             RedoStack.Push(PDFViewer.CurrentIndex);
             RedoStack.Push(PDFViewer.CurrentIndex);
             IsNextEnable = true;
             IsNextEnable = true;
 
 
@@ -337,7 +392,11 @@ namespace PDF_Master.ViewModels
         }
         }
 
 
         private void redo()
         private void redo()
-        {
+        {
+            if (!IsNextEnable)
+            {
+                return;
+            }
             App.Current.Dispatcher.Invoke(() =>
             App.Current.Dispatcher.Invoke(() =>
             {
             {
                 UndoStack.Push(PDFViewer.CurrentIndex);
                 UndoStack.Push(PDFViewer.CurrentIndex);

+ 5 - 95
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -42,9 +42,6 @@ using PDF_Master.Views.PropertyPanel.ViewModular;
 using PDF_Master.Views.PropertyPanel;
 using PDF_Master.Views.PropertyPanel;
 using System.Windows.Threading;
 using System.Windows.Threading;
 using Dropbox.Api.Files;
 using Dropbox.Api.Files;
-using System.Windows.Media;
-using Color = System.Windows.Media.Color;
-using PDFSettings;
 
 
 namespace PDF_Master.ViewModels
 namespace PDF_Master.ViewModels
 {
 {
@@ -276,7 +273,7 @@ namespace PDF_Master.ViewModels
         /// 顶部提示栏的显示状态
         /// 顶部提示栏的显示状态
         /// </summary>
         /// </summary>
         public bool IsFileLocked = false;
         public bool IsFileLocked = false;
-
+       
         public Visibility TipVisible
         public Visibility TipVisible
         {
         {
             get { return tipVisible; }
             get { return tipVisible; }
@@ -899,6 +896,7 @@ namespace PDF_Master.ViewModels
             {
             {
                 //自动保存仅针对已经有文件路径的文档
                 //自动保存仅针对已经有文件路径的文档
                 saveFile();
                 saveFile();
+                App.Current.MainWindow.Activate();
             }
             }
         }
         }
 
 
@@ -1222,7 +1220,7 @@ namespace PDF_Master.ViewModels
                         if (PDFViewer.Document.UnlockWithPassword(result.Password))
                         if (PDFViewer.Document.UnlockWithPassword(result.Password))
                         {
                         {
                             PDFViewer.Document.CheckOwnerPassword(result.Password);
                             PDFViewer.Document.CheckOwnerPassword(result.Password);
-                        }
+                        } 
                     }
                     }
                 }
                 }
             }
             }
@@ -1404,30 +1402,7 @@ namespace PDF_Master.ViewModels
 
 
         private void SettingsEvent()
         private void SettingsEvent()
         {
         {
-            DialogParameters value = new DialogParameters();
-            value.Add(ParameterNames.ViewContentViewModel, this);
-
-            AnnotToolContentViewModel annotToolContent = null;
-            if (region.Regions.ContainsRegionWithName(ToolsBarContentRegionName))
-            {
-                var views = region.Regions[ToolsBarContentRegionName].Views;
-                var isHas = views.FindFirst(q => q is AnnotToolContent);
-                if (isHas is AnnotToolContent annotTool)
-                {
-                    annotToolContent = (AnnotToolContentViewModel)annotTool.DataContext;
-                }
-            }
-
-            dialogs.ShowDialog(DialogNames.SettingsDialog, null, e =>
-            {
-                var annotate = Settings.Default.AppProperties.Annotate;
-                if (annotToolContent != null)
-                {
-                    //与注释联动修改颜色
-                    UpdateFreeHand(annotate, annotToolContent);
-                    UpdateTextHighlight(annotate, annotToolContent);
-                }
-            });
+            dialogs.ShowDialog(DialogNames.SettingsDialog, null, null);
             if (PDFViewer != null)
             if (PDFViewer != null)
             {
             {
                 PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
                 PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
@@ -1443,71 +1418,6 @@ namespace PDF_Master.ViewModels
             }
             }
         }
         }
 
 
-        private void UpdateTextHighlight(AnnotatePropertyClass annotate, AnnotToolContentViewModel annotToolContent)
-        {
-            Color color2 = annotate.HighLightColor;
-            Color color1 = (annotToolContent.HighLightColor as SolidColorBrush).Color;
-            bool flag = ColorComparison(color2, color1);
-            if (flag)
-            {
-                annotToolContent.HighLightColor = new SolidColorBrush(color2);
-                if (string.IsNullOrEmpty(annotToolContent.StrAnnotToolChecked) == false)
-                {
-                    CreateRefreshComment(annotToolContent);
-                }
-            }
-        }
-
-        private void UpdateFreeHand(AnnotatePropertyClass annotate, AnnotToolContentViewModel annotToolContent)
-        {
-            Color color2 = annotate.FreeHandColor;
-            Color color1 = (annotToolContent.FreeHandColor as SolidColorBrush).Color;
-            bool flag = ColorComparison(color2, color1);
-
-            if (flag)
-            {
-                annotToolContent.FreeHandColor = new SolidColorBrush(color2);
-                if (annotToolContent.PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] != null)
-                {
-                    if (annotToolContent.PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotFreehand] is FreehandAnnotArgs freehandAnnotArgs)
-                    {
-                        freehandAnnotArgs.InkColor = color2;
-                    }
-                }
-                if (string.IsNullOrEmpty(annotToolContent.StrAnnotToolChecked) == false)
-                {
-                    CreateRefreshComment(annotToolContent);
-                }
-            }
-        }
-
-        private void CreateRefreshComment(AnnotToolContentViewModel annotToolContent)
-        {
-            AnnotHandlerEventArgs annotArgs = null;
-            string tag = annotToolContent.StrAnnotToolChecked;
-            annotToolContent.FindAnnotTypeKey(tag, ref annotArgs);
-            if (annotArgs != null)
-            {
-                //设置点击页面会创建对应选中注释工具的注释
-                annotArgs.Author = Settings.Default.AppProperties.Description.Author;
-                PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
-                PDFViewer.SetToolParam(annotArgs);
-            }
-        }
-
-        private bool ColorComparison(Color color2, Color color1)
-        {
-            if (color1.R == color2.R && color1.G == color2.G && color1.B == color2.B
-                   && color1.A == color2.A)
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-
         private bool CanSaveExcute()
         private bool CanSaveExcute()
         {
         {
             return CanSave;
             return CanSave;
@@ -2138,7 +2048,7 @@ namespace PDF_Master.ViewModels
                     PDFViewer.Document.UnlockWithPassword(passwordInfo.OpenPassword);
                     PDFViewer.Document.UnlockWithPassword(passwordInfo.OpenPassword);
                 }
                 }
 
 
-                if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword) && passwordInfo.PermissionsPassword != passwordInfo.OpenPassword)
+                if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword)&&passwordInfo.PermissionsPassword != passwordInfo.OpenPassword)
                 {
                 {
                     IsFileLocked = true;
                     IsFileLocked = true;
                     NavigationParameters param = new NavigationParameters();
                     NavigationParameters param = new NavigationParameters();

+ 13 - 2
PDF Office/Views/ViewContent.xaml

@@ -21,6 +21,7 @@
     Drop="UserControl_Drop"
     Drop="UserControl_Drop"
     IsVisibleChanged="UserControl_IsVisibleChanged"
     IsVisibleChanged="UserControl_IsVisibleChanged"
     KeyDown="UserControl_KeyDown"
     KeyDown="UserControl_KeyDown"
+    MouseDown="UserControl_MouseDown"
     Unloaded="UserControl_Unloaded"
     Unloaded="UserControl_Unloaded"
     mc:Ignorable="d">
     mc:Ignorable="d">
 
 
@@ -93,11 +94,21 @@
             Key="Down"
             Key="Down"
             Command="{x:Static helper:GlobalCommands.LastPageCommand}"
             Command="{x:Static helper:GlobalCommands.LastPageCommand}"
             Modifiers="Ctrl" />
             Modifiers="Ctrl" />
-        <KeyBinding Key="Up" Command="{x:Static helper:GlobalCommands.PrePageCommand}" />
+        <KeyBinding Key="Up" Command="{x:Static helper:GlobalCommands.UpCommand}" />
+        <KeyBinding Key="Down" Command="{x:Static helper:GlobalCommands.DownCommand}" />
         <KeyBinding Key="Left" Command="{x:Static helper:GlobalCommands.PrePageCommand}" />
         <KeyBinding Key="Left" Command="{x:Static helper:GlobalCommands.PrePageCommand}" />
         <KeyBinding Key="PageUp" Command="{x:Static helper:GlobalCommands.PrePageCommand}" />
         <KeyBinding Key="PageUp" Command="{x:Static helper:GlobalCommands.PrePageCommand}" />
-        <KeyBinding Key="Down" Command="{x:Static helper:GlobalCommands.NextPageCommand}" />
+        <KeyBinding Key="PageDown" Command="{x:Static helper:GlobalCommands.NextPageCommand}" />
         <KeyBinding Key="Right" Command="{x:Static helper:GlobalCommands.NextPageCommand}" />
         <KeyBinding Key="Right" Command="{x:Static helper:GlobalCommands.NextPageCommand}" />
+
+        <KeyBinding
+            Key="OemOpenBrackets"
+            Command="{x:Static helper:GlobalCommands.PreViewCommand}"
+            Modifiers="Ctrl" />
+        <KeyBinding
+            Key="OemCloseBrackets"
+            Command="{x:Static helper:GlobalCommands.NextViewCommand}"
+            Modifiers="Ctrl" />
     </UserControl.InputBindings>
     </UserControl.InputBindings>
 
 
     <UserControl.CommandBindings>
     <UserControl.CommandBindings>

+ 19 - 0
PDF Office/Views/ViewContent.xaml.cs

@@ -391,5 +391,24 @@ namespace PDF_Master.Views
         {
         {
             viewModel.mainViewModel.CloseTab.Execute(null);
             viewModel.mainViewModel.CloseTab.Execute(null);
         }
         }
+
+        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            //鼠标侧键无法在Xaml里绑定  因此写在后台代码里
+            if(e.ChangedButton == MouseButton.XButton2)
+            {
+                if(GlobalCommands.PreViewCommand.CanExecute(null))
+                {
+                    GlobalCommands.PreViewCommand.Execute(null);
+                }
+            }
+            else if(e.ChangedButton == MouseButton.XButton1)
+            {
+                if (GlobalCommands.NextViewCommand.CanExecute(null))
+                {
+                    GlobalCommands.NextViewCommand.Execute(null);
+                }
+            }
+        }
     }
     }
 }
 }