Ver Fonte

其他-提交标记密文部分代码

ZhouJieSheng há 2 anos atrás
pai
commit
5743526ae2

+ 24 - 1
PDF Office/ViewModels/Dialog/Redaction/MarkSettingDialogViewModel.cs

@@ -1,4 +1,5 @@
-using Prism.Mvvm;
+using Prism.Commands;
+using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
@@ -14,6 +15,28 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public event Action<IDialogResult> RequestClose;
 
+        public DelegateCommand OkCommand { get; set; }
+
+        public DelegateCommand CancelCommand { get; set; }
+
+
+
+        public MarkSettingDialogViewModel()
+        {
+            OkCommand = new DelegateCommand(ok);
+            CancelCommand = new DelegateCommand(cancel);
+        }
+
+        private void cancel()
+        {
+            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+
+        private void ok()
+        {
+            
+        }
+
         public bool CanCloseDialog()
         {
             return true;

+ 145 - 3
PDF Office/ViewModels/Dialog/Redaction/PageMarkDialogViewModel.cs

@@ -1,4 +1,8 @@
-using Prism.Mvvm;
+using PDF_Office.CustomControl;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
@@ -10,10 +14,142 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 {
     public class PageMarkDialogViewModel : BindableBase, IDialogAware
     {
-        public string Title =>"";
+        public string Title => "";
 
         public event Action<IDialogResult> RequestClose;
 
+        public DelegateCommand OkCommand { get; set; }
+
+        public DelegateCommand CancelCommand { get; set; }
+
+        public DelegateCommand<string> CheckedCommand { get; set; }
+
+
+        /// <summary>
+        /// 当前页
+        /// </summary>
+        public int CurrentPageIndex { get; set; }
+
+
+        private string pagecount = "/1";
+
+        /// <summary>
+        /// 页面总数
+        /// </summary>
+        public string PageCount
+        {
+            get { return pagecount; }
+            set
+            {
+                SetProperty(ref pagecount, value);
+            }
+        }
+
+        /// <summary>
+        /// 页码集合
+        /// </summary>
+        public List<int> PageList = new List<int>();
+
+        /// <summary>
+        /// 文档页面总数
+        /// </summary>
+        public int pageCount = 0;
+
+        private string custompage;
+        /// <summary>
+        /// 自定义页面
+        /// </summary>
+        public string CustomPage
+        {
+            get { return custompage; }
+            set
+            {
+                SetProperty(ref custompage, value);
+                if(!string.IsNullOrEmpty(value))
+                {
+                    CheckCustomPage();
+                }
+            }
+        }
+
+
+        public PageMarkDialogViewModel()
+        {
+            OkCommand = new DelegateCommand(ok);
+            CancelCommand = new DelegateCommand(cancel);
+            CheckedCommand = new DelegateCommand<string>(check);
+        }
+
+        private void cancel()
+        {
+            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+
+        private void ok()
+        {
+            DialogParameters valuePairs = new DialogParameters();
+            valuePairs.Add(ParameterNames.PageList, PageList);
+            RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
+        }
+
+        private void CheckCustomPage()
+        {
+            var result = CommonHelper.GetPagesInRange(ref PageList,CustomPage,pageCount,new char[]{ ','},new char[] { '-'});
+            if(!result)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("","页码错误","ok");
+                CustomPage = "";
+                return;
+            }
+        }
+
+        private void check(string args)
+        {
+            switch (args)
+            {
+                case "Old":
+                    PageList = new List<int>();
+                    for (int i = 1; i <=pageCount; i++)
+                    {
+                        if (i % 2 != 0)
+                        {
+                            PageList.Add(i-1);
+                        }
+                    }
+                    break;
+                case "Even":
+                    PageList = new List<int>();
+                    for (int i = 1; i <= pageCount; i++)
+                    {
+                        if (i % 2 == 0)
+                        {
+                            PageList.Add(i - 1);
+                        }
+                    }
+                    break;
+                case "All":
+                    PageList = new List<int>();
+                    for(int i=0;i<pageCount;i++)
+                    {
+                        PageList.Add(i);
+                    }
+                    break;
+                case "Custom":
+                    if(!string.IsNullOrEmpty(CustomPage))
+                    {
+                        CheckCustomPage();
+                    }
+                    break;
+                default:
+                case "Current":
+                    PageList = new List<int>();
+                    PageList.Add(CurrentPageIndex);
+                    break;
+            }
+        }
+
+
         public bool CanCloseDialog()
         {
             return true;
@@ -26,7 +162,13 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public void OnDialogOpened(IDialogParameters parameters)
         {
-    
+            int page = parameters.GetValue<int>(ParameterNames.PageCount);
+            if(page>0)
+            {
+                PageCount = "/ " + page;
+                pageCount = page;
+            }
+            CurrentPageIndex = parameters.GetValue<int>(ParameterNames.CurrentPageIndex);
         }
     }
 }

+ 22 - 1
PDF Office/ViewModels/Dialog/Redaction/RepeatMarkDialogViewModel.cs

@@ -1,4 +1,5 @@
-using Prism.Mvvm;
+using Prism.Commands;
+using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
@@ -14,6 +15,26 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public event Action<IDialogResult> RequestClose;
 
+        public DelegateCommand OkCommand { get; set; }
+
+        public DelegateCommand CancelCommand { get; set; }
+
+        public RepeatMarkDialogViewModel()
+        {
+            OkCommand = new DelegateCommand(ok);
+            CancelCommand = new DelegateCommand(cancel);
+        }
+
+        private void ok()
+        {
+
+        }
+
+        private void cancel()
+        {
+            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+
         public bool CanCloseDialog()
         {
             return true;

+ 2 - 0
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -234,6 +234,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
                 redactionRegion.Regions[RegionNames.ViwerRegionName].Remove(PDFViewer);
                 redactionRegion.Regions[RedactionDocumentRegionName].Remove(PDFViewer);
                 this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
+                App.mainWindowViewModel.SelectedItem.IsInReadctonMode = false;
             }
         }
 
@@ -268,6 +269,7 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            App.mainWindowViewModel.SelectedItem.IsInReadctonMode = true;
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
             PDFViewer.InfoChanged += PDFViewer_InfoChanged;

+ 1 - 1
PDF Office/ViewModels/PageEdit/PageEditContentViewModel.cs

@@ -2241,7 +2241,7 @@ namespace PDF_Office.ViewModels.PageEdit
         {
             if(e.Key== "PageNum")
             {
-                NotifyUIToRefresh(new List<int> { (int)e.Value});
+                NotifyUIToRefresh(new List<int> { (e.Value as ComPDFKitViewer.RenderData).PageIndex});
             }
         }
         #endregion

+ 5 - 0
PDF Office/Views/MainContent.xaml.cs

@@ -35,6 +35,11 @@ namespace PDF_Office.Views
         /// </summary>
         public Dictionary<string, string> RegionContentNames { get; set; }
 
+        /// <summary>
+        /// 是否处于标记密文模式
+        /// </summary>
+        public bool IsInReadctonMode { get; set; } = false;
+
         public MainContent()
         {
             InitializeComponent();