Przeglądaj źródła

标记密文-添加标记密文右键菜单

ZhouJieSheng 2 lat temu
rodzic
commit
2e83ba4643

+ 1 - 0
PDF Office/App.xaml

@@ -12,6 +12,7 @@
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Themes/Alias_Light.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Themes/Global.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/TabControlStyle.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/SeparatorStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ButtonStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ToggleButton.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/TextBoxStyle.xaml" />

+ 26 - 0
PDF Office/EventAggregators/RedactionCommandEvent.cs

@@ -0,0 +1,26 @@
+using ComPDFKitViewer.AnnotEvent;
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.EventAggregators
+{
+    public class RedactionCommandEventArgs
+    {
+        public string UniCode { get; set; }
+
+        public object Sender { get; set; }
+
+        public AnnotCommandArgs args { get; set; }
+    }
+
+    /// <summary>
+    /// 绑定标记密文右键菜单的事件
+    /// </summary>
+    public class RedactionCommandEvent: PubSubEvent<RedactionCommandEventArgs>
+    {
+    }
+}

+ 5 - 0
PDF Office/PDF Office.csproj

@@ -300,6 +300,7 @@
     <Compile Include="EventAggregators\EditToolsEvent.cs" />
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />
+    <Compile Include="EventAggregators\RedactionCommandEvent.cs" />
     <Compile Include="EventAggregators\SendPrintInfoEvent.cs" />
     <Compile Include="EventAggregators\SplitEvent.cs" />
     <Compile Include="Helper\CacheFilePath.cs" />
@@ -1161,6 +1162,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Styles\SeparatorStyle.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="Styles\SliderStyle.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 14 - 0
PDF Office/Styles/ContextMenuStyle.xaml

@@ -82,4 +82,18 @@
         </MenuItem>
     </ContextMenu>
 
+    <ContextMenu x:Key="RedactionContextMenu">
+        <MenuItem
+            Name="MenuDelete"
+            Command="{x:Static ApplicationCommands.Delete}"
+            Header="Delete" />
+        <Separator Style="{StaticResource HorizontalSeparatorStyle}" />
+        <MenuItem Name="MenuProperties" Header="Properties..." />
+        <MenuItem Name="MenuSetDeufalt" Header="Use Current Properties as New Default" />
+        <Separator Style="{StaticResource HorizontalSeparatorStyle}" />
+        <MenuItem Name="MenuRepeat" Header="Repeat mark across pages" />
+        <MenuItem Name="MenuApply" Header="Apply Redactions" />
+        <MenuItem Name="MenuErase" Header="Erase Redactions" />
+    </ContextMenu>
+
 </ResourceDictionary>

+ 23 - 0
PDF Office/Styles/SeparatorStyle.xaml

@@ -0,0 +1,23 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+
+    <Style
+        x:Key="VerticalSeparatorStyle"
+        BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"
+        TargetType="{x:Type Separator}">
+        <Setter Property="Background" Value="{StaticResource color.sys.layout.divider}" />
+        <Setter Property="Height" Value="16" />
+        <Setter Property="Width" Value="1" />
+        <Setter Property="HorizontalAlignment" Value="Stretch" />
+        <Setter Property="Margin" Value="12,0" />
+    </Style>
+
+    <Style
+        x:Key="HorizontalSeparatorStyle"
+        BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"
+        TargetType="{x:Type Separator}">
+        <Setter Property="Background" Value="{StaticResource color.sys.layout.divider}" />
+        <Setter Property="Height" Value="1" />
+        <Setter Property="HorizontalAlignment" Value="Stretch" />
+        <Setter Property="Margin" Value="8,4" />
+    </Style>
+</ResourceDictionary>

+ 82 - 8
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -17,11 +17,13 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
 using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.EditTools.Redaction
 {
-    public class RedactionContentViewModel : BindableBase,INavigationAware
+    public class RedactionContentViewModel : BindableBase, INavigationAware
     {
         public IEventAggregator eventAggregator;
 
@@ -46,10 +48,12 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
 
         public DelegateCommand ApplyCommmand { get; set; }
 
-        public DelegateCommand RemoveCommand { get; set; }
-
         public DelegateCommand PageRedactionCommand { get; set; }
 
+        public DelegateCommand EraseCommand { get; set; }
+
+        public RedactionCommandEventArgs TempArgs { get; set; }
+
         private int currentPage = 0;
 
         /// <summary>
@@ -63,9 +67,9 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
             set
             {
                 SetProperty(ref currentPage, value);
-                if(value>=1&&value<=PDFViewer.Document.PageCount&&!isFromSelf)
+                if (value >= 1 && value <= PDFViewer.Document.PageCount && !isFromSelf)
                 {
-                    PDFViewer.GoToPage(value-1);
+                    PDFViewer.GoToPage(value - 1);
                 }
             }
         }
@@ -82,7 +86,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
         }
 
 
-        public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator,IDialogService dialogService)
+        public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IDialogService dialogService)
         {
             this.redactionRegion = regionManager;
             this.eventAggregator = eventAggregator;
@@ -92,10 +96,80 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             CloseEditToolCommand = new DelegateCommand(CloseEditTool);
             ApplyCommmand = new DelegateCommand(apply);
-            RemoveCommand = new DelegateCommand(remove);
+            EraseCommand = new DelegateCommand(erase);
             PageRedactionCommand = new DelegateCommand(pageMark);
+
+            eventAggregator.GetEvent<RedactionCommandEvent>().Subscribe(SetContextMenu, e => e.UniCode == Unicode);
+        }
+
+        private void SetContextMenu(RedactionCommandEventArgs obj)
+        {
+            var contextmenu = App.Current.FindResource("RedactionContextMenu") as ContextMenu;
+            obj.args.PopupMenu = contextmenu;
+            for(int i=0;i<contextmenu.Items.Count;i++)
+            {
+                if(contextmenu.Items[i] is MenuItem) 
+                {
+                    var item = contextmenu.Items[i] as MenuItem;
+                    switch (item.Name)
+                    {
+                        case "MenuSetDeufalt":
+                            item.Command = new DelegateCommand<RedactionCommandEventArgs>(SetDefualtProperty);
+                            item.CommandParameter = obj;
+                            break;
+                        case "MenuProperties":
+                            item.Command = new DelegateCommand<RedactionCommandEventArgs>(ShowProperty);
+                            item.CommandParameter = obj;
+                            break;
+                        case "MenuRepeat":
+                            item.Command = new DelegateCommand<RedactionCommandEventArgs>(RepreatMark);
+                            item.CommandParameter = obj;
+                            break;
+                        case "MenuApply":
+                            item.Command = this.ApplyCommmand;
+                            break;
+                        case "MenuErase":
+                            item.Command = this.EraseCommand;
+                            break;
+                        default:
+                            break;
+                    }
+
+                }
+            }
         }
 
+        /// <summary>
+        /// 设置当前为默认属性
+        /// </summary>
+        /// <param name="args"></param>
+        private void SetDefualtProperty(RedactionCommandEventArgs args)
+        {
+            DialogParameters keyValues = new DialogParameters();
+            keyValues.Add(ParameterNames.DataModel,args.args.AnnotEventArgsList[0] as RedactionAnnotArgs);
+        }
+
+        /// <summary>
+        /// 显示属性弹窗
+        /// </summary>
+        /// <param name="args"></param>
+        private void ShowProperty(RedactionCommandEventArgs args)
+        {
+            DialogParameters keyValues = new DialogParameters();
+            keyValues.Add(ParameterNames.DataModel, args.args.AnnotEventArgsList[0] as RedactionAnnotArgs);
+            dialogs.ShowDialog(DialogNames.MarkSettingDialog,keyValues,null);
+        }
+
+        /// <summary>
+        /// 显示跨页标记弹窗
+        /// </summary>
+        /// <param name="args"></param>
+        private void RepreatMark(RedactionCommandEventArgs args)
+        {
+            DialogParameters keyValues = new DialogParameters();
+            keyValues.Add(ParameterNames.PageCount,PDFViewer.Document.PageCount);
+            dialogs.ShowDialog(DialogNames.RepeatMarkDialog, keyValues, null);
+        }
         /// <summary>
         /// 应用
         /// </summary>
@@ -114,7 +188,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
         /// <summary>
         /// 擦除
         /// </summary>
-        private void remove()
+        private void erase()
         {
 
         }

+ 15 - 3
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -4,6 +4,7 @@ using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using Microsoft.Win32;
 using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Properties;
@@ -11,6 +12,7 @@ using PDF_Office.ViewModels.PropertyPanel;
 using PDF_Office.Views.PropertyPanel.AnnotPanel;
 using PDFSettings;
 using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
@@ -28,10 +30,12 @@ namespace PDF_Office.ViewModels.Tools
 {
     public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
-        public AnnotToolContentViewModel(IRegionManager regionManager)
+        private IEventAggregator events;
+
+        public AnnotToolContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
         {
             region = regionManager;
-
+            events = eventAggregator;
             MyToolsCommand = new DelegateCommand<CustomIconToggleBtn>(BtnMyTools_Click);
             PropertyRegionName = Guid.NewGuid().ToString();
             BindingEvent();
@@ -455,7 +459,15 @@ namespace PDF_Office.ViewModels.Tools
                 case CommandType.Context:
                     if (e.AnnotEventArgsList.Count > 0)
                     {
-                        e.PopupMenu = SelectAnnotContextMenu(sender);
+                        if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
+                        {
+                            //绑定标记密文处右键菜单
+                            events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
+                        }
+                        else
+                        {
+                            e.PopupMenu = SelectAnnotContextMenu(sender);
+                        }
                         if (e.PopupMenu != null)
                         {
                             e.Handle = true;

+ 3 - 2
PDF Office/Views/Dialog/Redaction/RepeatMarkDialog.xaml

@@ -35,7 +35,7 @@
                 GroupName="Page" />
 
             <StackPanel
-                Margin="0,8"
+                Margin="0,7"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Center"
                 Orientation="Horizontal">
@@ -55,7 +55,8 @@
                 <TextBlock
                     Margin="8,0,0,0"
                     VerticalAlignment="Center"
-                    Text="/" />
+                    Text="/ " />
+                <TextBlock VerticalAlignment="Center" Text="1" />
             </StackPanel>
         </StackPanel>
         <cus:DialogContent.BottmBar>