Browse Source

其他-补充多页签部分右键菜单

ZhouJieSheng 2 years ago
parent
commit
42aafbb757

+ 82 - 1
PDF Office/ViewModels/MainContentViewModel.cs

@@ -34,7 +34,12 @@ namespace PDF_Office.ViewModels
         public string FileName
         {
             get { return fileName; }
-            set { SetProperty(ref fileName, value); }
+            set { SetProperty(ref fileName, value);
+                if (IsReNameTextShow == Visibility.Visible)
+                {
+                    dorenameFile();
+                }
+            }
         }
 
         private string filePath;
@@ -70,6 +75,10 @@ namespace PDF_Office.ViewModels
 
         public DelegateCommand<object> Loaded { get; set; }
 
+        public DelegateCommand ShowInFolderCommand { get; set; }
+
+        public DelegateCommand RenameCommand { get; set; }
+
 
         private string regionName;
 
@@ -79,6 +88,43 @@ namespace PDF_Office.ViewModels
             set { SetProperty(ref regionName, value); }
         }
 
+        private bool isReNameEnable = false;
+        /// <summary>
+        /// 是否能够重命名
+        /// </summary>
+        public bool IsReNameEnable
+        {
+            get { return isReNameEnable; }
+            set
+            {
+                SetProperty(ref isReNameEnable, value);
+            }
+        }
+
+        private bool isShowInFolderEnable = false;
+        /// <summary>
+        /// 是否能够显示文件浏览器
+        /// </summary>
+        public bool IsShowInFolderEnable
+        {
+            get { return isShowInFolderEnable; }
+            set
+            {
+                SetProperty(ref isShowInFolderEnable, value);
+            }
+        }
+
+        private Visibility isRenameTextShow = Visibility.Collapsed;
+
+        public Visibility IsReNameTextShow
+        {
+            get { return isRenameTextShow; }
+            set
+            {
+                SetProperty(ref isRenameTextShow, value);
+            }
+        }
+
         public IRegionManager toolregion;
 
         public IEventAggregator eventer;
@@ -95,6 +141,8 @@ namespace PDF_Office.ViewModels
             dialogs = dialogService;
 
             CloseTab = new DelegateCommand<object>(CloseTabItem);
+            ShowInFolderCommand = new DelegateCommand(showInFolder);
+            RenameCommand = new DelegateCommand(rename);
 
             MainContentRegionName = Guid.NewGuid().ToString();
 
@@ -111,6 +159,34 @@ namespace PDF_Office.ViewModels
             }));
         }
 
+        /// <summary>
+        /// 执行重命名操作
+        /// </summary>
+        private void dorenameFile()
+        {
+            var folder = PDFViewer.Document.FilePath.Substring(0, PDFViewer.Document.FilePath.LastIndexOf("\\"));
+            ////File.Move(PDFViewer.Document.FilePath,Path.Combine(folder,FileName));
+            ///TODO:
+            IsReNameTextShow = Visibility.Collapsed;
+        }
+
+        /// <summary>
+        /// 显示重命名文本框
+        /// </summary>
+        private void rename()
+        {
+            IsReNameTextShow = Visibility.Visible;
+        }
+
+        private void showInFolder()
+        {
+            if(!string.IsNullOrEmpty(PDFViewer.Document.FilePath))
+            {
+                CommonHelper.ShowFileBrowser(PDFViewer.Document.FilePath);
+            }
+   
+        }
+
         private void CloseTabItem(object item)
         {
             App.mainWindowViewModel?.CloseTabItem(item);
@@ -163,6 +239,11 @@ namespace PDF_Office.ViewModels
                 toolregion.RequestNavigate(MainContentRegionName, "ViewContent", parameters);
             }));
 
+            IsReNameEnable = true;
+            if(!string.IsNullOrEmpty(PDFViewer.Document.FilePath))
+            {
+                IsShowInFolderEnable = true;
+            }
         }
 
         /// <summary>

+ 1 - 1
PDF Office/Views/Form/FormsToolContent.xaml

@@ -177,7 +177,7 @@
                 </StackPanel>
                 <RadioButton.ContextMenu>
                     <ContextMenu Name="MenuAlignment" Placement="Bottom">
-                        <cus:MenuItemWithPath Header="Left Alignment" Path="M2.01361 15V1H3.51361V15H2.01361ZM4.99994 4H10.9999V7H4.99994V4ZM13.9999 9H4.99994V12H13.9999V9Z" />
+                        <cus:MenuItemWithPath  Header="Left Alignment" Path="M2.01361 15V1H3.51361V15H2.01361ZM4.99994 4H10.9999V7H4.99994V4ZM13.9999 9H4.99994V12H13.9999V9Z" />
                         <cus:MenuItemWithPath Header="Vertical Alignment" Path="M8.75006 7L8.75006 9L12.0001 9L12.0001 12L8.75006 12L8.75006 15L7.25006 15L7.25006 12L4.00006 12L4.00006 9L7.25006 9L7.25006 7L2.00006 7L2.00006 4L7.25006 4L7.25006 0.999999L8.75006 1L8.75006 4L14.0001 4L14.0001 7L8.75006 7Z" />
                         <cus:MenuItemWithPath Header="Right Alignment" Path="M14.0001 1L14.0001 15L12.5001 15L12.5001 1L14.0001 1ZM11.0001 12L2.00006 12L2.00006 9L11.0001 9L11.0001 12ZM4.00006 7L11.0001 7L11.0001 4L4.00006 4L4.00006 7Z" />
                         <cus:MenuItemWithPath Header="Top Alignment" Path="M15 2L1 2L1 3.5L15 3.5L15 2ZM12 5L12 11L9 11L9 5L12 5ZM7 5L7 14L4 14L4 5L7 5Z" />

+ 32 - 7
PDF Office/Views/MainWindow.xaml

@@ -46,7 +46,10 @@
                                     BorderThickness="0"
                                     CornerRadius="4,4,0,0"
                                     WindowChrome.IsHitTestVisibleInChrome="True">
-                                    <Grid>
+                                    <Grid
+                                        Name="GridRoot"
+                                        Focusable="True"
+                                        WindowChrome.IsHitTestVisibleInChrome="True">
                                         <Grid.ColumnDefinitions>
                                             <ColumnDefinition Width="auto" />
                                             <ColumnDefinition Width="*" MinWidth="10" />
@@ -107,15 +110,36 @@
                                             CommandParameter="{Binding}">
                                             <Path Data="M6.50006 7.06072L9.96973 10.5304L11.0304 9.46973L7.56072 6.00006L11.0304 2.53039L9.96973 1.46973L6.50006 4.9394L3.03039 1.46973L1.96973 2.53039L5.4394 6.00006L1.96973 9.46973L3.03039 10.5304L6.50006 7.06072Z" Fill="{StaticResource color.icon.base.neutral.norm.lv2}" />
                                         </Button>
+
+                                        <TextBox
+                                            x:Name="TxtRename"
+                                            MaxWidth="145"
+                                            Margin="8,0,10,0"
+                                            VerticalContentAlignment="Center"
+                                            FontFamily="Segoe UI,Microsoft YaHei"
+                                            Foreground="{TemplateBinding Foreground}"
+                                            PreviewKeyDown="TxtRename_PreviewKeyDown"
+                                            Text="{Binding DataContext.FileName, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
+                                            Visibility="{Binding DataContext.IsReNameTextShow}"
+                                            WindowChrome.IsHitTestVisibleInChrome="True" />
                                     </Grid>
                                 </Border>
                                 <Grid.ContextMenu>
                                     <ContextMenu>
-                                        <MenuItem Header="Rename" />
-                                        <MenuItem Header="Show In Folder" />
-                                        <MenuItem Header="Close Tab" />
+                                        <MenuItem
+                                            Command="{Binding DataContext.RenameCommand}"
+                                            Header="Rename"
+                                            IsEnabled="{Binding DataContext.IsReNameEnable}" />
+                                        <MenuItem
+                                            Command="{Binding DataContext.ShowInFolderCommand}"
+                                            Header="Show In Folder"
+                                            IsEnabled="{Binding DataContext.IsShowInFolderEnable}" />
+                                        <MenuItem
+                                            Command="{Binding DataContext.CloseTab}"
+                                            CommandParameter="{Binding}"
+                                            Header="Close Tab" />
                                         <MenuItem Header="Close All Tab" />
-                                        <MenuItem Header="Open In New Window" />
+                                        <MenuItem Header="Open In New Window" Visibility="Collapsed" />
                                     </ContextMenu>
                                 </Grid.ContextMenu>
                             </Grid>
@@ -162,6 +186,7 @@
                 Name="TabablzControl"
                 Grid.RowSpan="3"
                 BorderThickness="0"
+                FocusVisualStyle="{x:Null}"
                 ItemContainerStyle="{StaticResource DragablzItemStyle}"
                 SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                 WindowChrome.IsHitTestVisibleInChrome="True">
@@ -248,8 +273,8 @@
                     <Polygon Fill="{StaticResource color.btn.sec.text.def}" Points="11.2919922 12 12 11.2919922 6.70800781 6 12 0.708007813 11.2919922 0 6 5.29199219 0.708007812 9.76996262e-15 -2.27456942e-13 0.708007813 5.29199219 6 0 11.2919922 0.708007812 12 6 6.70800781" />
                 </Button>
             </StackPanel>
-            
-            <!--OCR Progress Control-->
+
+            <!--  OCR Progress Control  -->
             <Grid Grid.RowSpan="2" Visibility="{Binding IsProcessVisible}">
                 <Grid.Background>
                     <SolidColorBrush Opacity="0.05" Color="Black" />

+ 8 - 0
PDF Office/Views/MainWindow.xaml.cs

@@ -135,5 +135,13 @@ namespace PDF_Office.Views
                 ico_max.Visibility = Visibility.Collapsed;
             }
         }
+
+        private void TxtRename_PreviewKeyDown(object sender, KeyEventArgs e)
+        {
+            if(e.Key == Key.Enter)
+            {
+                TabablzControl.Focus();
+            }
+        }
     }
 }