Browse Source

综合-调整已打开文件列表更新逻辑,调整打开、关闭页签快捷键形式

ZhouJieSheng 1 year ago
parent
commit
01e85614ee

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

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

+ 2 - 0
PDF Office/ViewModels/MainContentViewModel.cs

@@ -242,10 +242,12 @@ namespace PDF_Master.ViewModels
         }
 
         //关闭页签
+        //清除文件记录,释放Document对象
         private void unload()
         {
             if (PDFViewer != null)
             {
+                App.OpenedFileList.Remove(PDFViewer.Document?.FilePath);
                 PDFViewer.CloseDocument();
             }
         }

+ 3 - 8
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -456,8 +456,6 @@ namespace PDF_Master.ViewModels
                     ContentResult result = ShowSaveDialog((SelectedItem.DataContext as MainContentViewModel).viewContentViewModel);
                     if (result == ContentResult.Cancel)
                         return false;
-                    App.OpenedFileList.Remove(CurrentPDFViewer.Document.FilePath);
-                    CurrentPDFViewer.CloseDocument();
                 }
                 if (selectedItem != null)
                 {
@@ -489,19 +487,16 @@ namespace PDF_Master.ViewModels
                 {
                     return;
                 }
-                App.OpenedFileList.Remove(maincontentViewModel.PDFViewer.Document.FilePath);
-                if (maincontentViewModel.PDFViewer.Document != null)
-                {
-                    maincontentViewModel.PDFViewer.CloseDocument();
-                }
             }
+
+            //不要保存 可以直接关闭页签时
             if (region.Regions[RegionNames.MainRegion].Views.Count() > 1)
             {
                 region.Regions[RegionNames.MainRegion].Remove(item);
                 CheckViewsCount();
 
                 //关闭子窗体的最后一个页签时,子窗体关闭(不显示首页),参考福昕逻辑
-                if((App.Current.MainWindow as MainWindow).TabablzControl.Items.Count==0)
+                if ((App.Current.MainWindow as MainWindow).TabablzControl.Items.Count==0)
                 {
                     App.Current.MainWindow.Close();
                 }

+ 2 - 7
PDF Office/ViewModels/PageEdit/PageEditContentViewModel.cs

@@ -2421,11 +2421,6 @@ namespace PDF_Master.ViewModels.PageEdit
                     PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
 
                     ZoomIndex = 0;
-                    //if (viewContentViewModel != null)
-                    //{
-                    //    viewContentViewModel.PageEditUndo = Undo;
-                    //    viewContentViewModel.PageEditRedo = Redo;
-                    //}
                 }
                 //BOTA缩略图时,显示不同的菜单栏
                 if (isBOTA)
@@ -2441,9 +2436,9 @@ namespace PDF_Master.ViewModels.PageEdit
 
                 GetSourceItems(isFirstLoad);
 
+                //清空一下选中项,修复进入页面编辑后仍然选中多页的问题
+                ListSelectedIndex = -1;
                 ListSelectedIndex = PDFViewer.CurrentIndex;
-                //viewContentViewModel.CanUndo = this.CanUndo;
-                //viewContentViewModel.CanRedo = this.CanRedo;
                 RefreshBookMarkList();
                 isFirstLoad = false;
             }

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

@@ -525,7 +525,8 @@ namespace PDF_Master.ViewModels
             set
             {
                 //如果设置为手动展开属性面板时,则不响应代码控制的展开
-                if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty)
+                //或者手动点击按钮时 也展开
+                if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty||FromClick)
                 {
                     if (mainViewModel.IsBookMode)
                     {
@@ -537,6 +538,11 @@ namespace PDF_Master.ViewModels
             }
         }
 
+        /// <summary>
+        /// 是否是点击属性面板按钮
+        /// </summary>
+        private bool FromClick = false;
+
         private Visibility isReadMode = Visibility.Visible;
 
         /// <summary>
@@ -757,6 +763,8 @@ namespace PDF_Master.ViewModels
 
         public DelegateCommand ClosePropertyCommand { get; set; }
 
+        public DelegateCommand<object> OpenPropertyCommand { get; set; }
+
         #endregion 命令
 
         public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
@@ -787,6 +795,7 @@ namespace PDF_Master.ViewModels
             HelpCommand = new DelegateCommand<string>(help);
             CreateBlankFileCommand = new DelegateCommand(createBlankFile);
             CreateFromFile = new DelegateCommand(createfromFile);
+            OpenPropertyCommand = new DelegateCommand<object>(openProperty);
 
             ViwerRegionName = RegionNames.ViwerRegionName;
             SplitViewerRegionName = RegionNames.Viewer_SplitRegionName;
@@ -836,6 +845,17 @@ namespace PDF_Master.ViewModels
             StartAutoSave();
         }
 
+        /// <summary>
+        /// 点击展开折叠属性面板
+        /// </summary>
+        /// <param name="obj"></param>
+        private void openProperty(object obj)
+        {
+            FromClick = true;
+            IsPropertyOpen = (bool)obj;
+            FromClick = false;
+        }
+
         /// <summary>
         /// 开始自动保存
         /// </summary>
@@ -1329,7 +1349,9 @@ namespace PDF_Master.ViewModels
 
         private void CloseProperty()
         {
+            FromClick = true;
             IsPropertyOpen = false;
+            FromClick = false;
         }
 
         /// <summary>

+ 2 - 2
PDF Office/Views/PageEdit/PageEditContent.xaml

@@ -22,9 +22,9 @@
     d:DesignWidth="800"
     prism:ViewModelLocator.AutoWireViewModel="True"
     FocusVisualStyle="{x:Null}"
-    Unloaded="PageEdit_Unloaded"
     IsVisibleChanged="PageEdit_IsVisibleChanged"
     SizeChanged="PageEdit_SizeChanged"
+    Unloaded="PageEdit_Unloaded"
     mc:Ignorable="d">
     <UserControl.Resources>
         <ResourceDictionary>
@@ -380,7 +380,7 @@
                         <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_PreviewMouseLeftButtonDown" />
                         <EventSetter Event="PreviewMouseDoubleClick" Handler="ListBoxItem_PreviewMouseDoubleClick" />
                         <Style.Triggers>
-                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=DataContext.IsBOTAThumb}" Value="Visible">
+                            <DataTrigger Binding="{Binding ElementName=GridBOTAHeader, Path=Visibility}" Value="Visible">
                                 <Setter Property="Template" Value="{StaticResource BOTAListBoxItemTemplate}" />
                             </DataTrigger>
                         </Style.Triggers>

+ 21 - 4
PDF Office/Views/ViewContent.xaml

@@ -47,6 +47,8 @@
             <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
             <RoutedUICommand x:Key="CloseLeft" Text="CloseLeft" />
             <RoutedUICommand x:Key="CloseRight" Text="CloseRight" />
+            <RoutedUICommand x:Key="AddTab" Text="AddTab" />
+            <RoutedUICommand x:Key="CloseTab" Text="CloseTab" />
         </ResourceDictionary>
     </UserControl.Resources>
     <UserControl.InputBindings>
@@ -59,11 +61,17 @@
             Command="{StaticResource CloseRight}"
             Modifiers="Ctrl+Shift" />
         <KeyBinding Command="{Binding OpenFileCommand}" Gesture="Ctrl+O" />
-        <KeyBinding Command="{Binding mainViewModel.mainWindowViewModel.AddTab}" Gesture="Ctrl+T" />
+        <KeyBinding
+            Key="T"
+            Command="{StaticResource AddTab}"
+            Modifiers="Ctrl" />
         <KeyBinding Command="{Binding SaveFile}" Gesture="Ctrl+S" />
         <KeyBinding Command="{Binding SaveAsFile}" Gesture="Ctrl+Shift+S" />
         <KeyBinding Command="{Binding CloseWindowCommand}" Gesture="Ctrl+Shift+W" />
-        <KeyBinding Command="{Binding mainViewModel.CloseTab}" Gesture="Ctrl+W" />
+        <KeyBinding
+            Key="W"
+            Command="{StaticResource CloseTab}"
+            Modifiers="Ctrl" />
         <KeyBinding
             Key="P"
             Command="{Binding PrintCommand}"
@@ -84,6 +92,14 @@
             x:Name="CloseLeftCommand"
             Command="{StaticResource CloseLeft}"
             Executed="CloseLeftCommand_Executed" />
+        <CommandBinding
+            x:Name="AddTabCommand"
+            Command="{StaticResource AddTab}"
+            Executed="AddTabCommand_Executed" />
+        <CommandBinding
+            x:Name="CloseTabCommand"
+            Command="{StaticResource CloseTab}"
+            Executed="CloseTabCommand_Executed" />
         <CommandBinding
             x:Name="CloseRightCommand"
             Command="{StaticResource CloseRight}"
@@ -322,7 +338,9 @@
                     Width="28"
                     Height="28"
                     BorderThickness="0"
-                    IsChecked="{Binding IsPropertyOpen}"
+                    Command="{Binding OpenPropertyCommand}"
+                    CommandParameter="{Binding ElementName=TbtnProperty, Path=IsChecked}"
+                    IsChecked="{Binding IsPropertyOpen, Mode=OneWay}"
                     IsEnabled="{Binding isInPageEdit, Converter={StaticResource UnBoolConvert}}"
                     Style="{StaticResource SubToolbarTgb}"
                     ToolTip="{Binding T_Properties}">
@@ -411,7 +429,6 @@
         <ContentControl
             Name="ContentToolsBar"
             Grid.Row="{Binding GridToolRow}"
-            Panel.ZIndex="2"
             prism:RegionManager.RegionName="{Binding ToolsBarContentRegionName}"
             Visibility="{Binding ToolsBarContentVisible}" />
 

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

@@ -379,5 +379,15 @@ namespace PDF_Master.Views
                 }));
             }
         }
+
+        private void AddTabCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+        {
+            viewModel.mainViewModel.mainWindowViewModel.AddTab.Execute();
+        }
+
+        private void CloseTabCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+        {
+            viewModel.mainViewModel.CloseTab.Execute(null);
+        }
     }
 }