Browse Source

其他-同步

liuaoran 2 years ago
parent
commit
0957399b38

+ 3 - 8
PDF Office/App.xaml.cs

@@ -23,10 +23,9 @@ using PDF_Office.Model;
 using PDF_Office.Views.PageEdit;
 using PDF_Office.Properties;
 using PDFSettings.Settings;
-using PDF_Office.Views.Tools;
-using PDF_Office.ViewModels.Dialog.ToolsDialogs;
-using PDF_Office.Views.Dialog.ToolsDialogs;
+using PDF_Office.Views.Tools; 
 using PDF_Office.Views.Dialog.ToolsDialogs.SaftyDialogs;
+using PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs; 
 
 namespace PDF_Office
 {
@@ -89,7 +88,7 @@ namespace PDF_Office
             containerRegistry.RegisterDialog<SetPasswordDialog>(DialogNames.SetPasswordDialog);
             containerRegistry.RegisterDialog<CheckPasswordDialog>(DialogNames.CheckPasswordDialog);
             containerRegistry.RegisterDialog<CancelPasswordDialog>(DialogNames.CancelPasswordDialog);
-            containerRegistry.RegisterDialog<ToolsProgressBarDialog>(DialogNames.ToolsProgressBarDialog);
+            containerRegistry.RegisterDialog<CompressProgressBarDialog, PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs.CompresProgressBarDialogViewModel>(DialogNames.CompressProgressBarDialog);
         }
 
         protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
@@ -116,11 +115,7 @@ namespace PDF_Office
             string devKey = "";
             string devSecret = "";
 #if DEBUG
-<<<<<<< Updated upstream
-            devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
-=======
             devKey = " ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
->>>>>>> Stashed changes
             devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh";
 #endif
 

+ 23 - 23
PDF Office/Model/Dialog/ToolsDialogs/CompressDialogModel.cs

@@ -1,23 +1,23 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PDF_Office.Model.Dialog.ToolsDialogs
-{
-    public class CompressDialogModel
-    {
-       public enum qualityLevel { 
-        
-        _large=100,
-        _standard=80,
-        _default=45,
-        _little =40,
-        _micro=10
-        }
-        public qualityLevel CompressQuality { get; set; }
-
-        public static string PageIndex { get; set; }
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.Dialog.ToolsDialogs
+{
+    public class CompressDialogModel
+    {
+       public enum qualityLevel { 
+        
+        _large=100,
+        _standard=80,
+        _default=45,
+        _little =40,
+        _micro=10
+        }
+        public qualityLevel CompressQuality { get; set; }
+
+        public static string PageIndex { get; set; }
+    }
+}

+ 2 - 2
PDF Office/Model/DialogNames.cs

@@ -22,7 +22,7 @@ namespace PDF_Office.Model
         public static string FullScreenDialog = "FullScreenDialog";
 
         /// <summary>
-        /// 压缩弹窗
+        /// 压缩弹窗
         /// </summary>
         public static string CompressDialog = "CompressDialog";
 
@@ -44,7 +44,7 @@ namespace PDF_Office.Model
         /// <summary>
         /// 进度条
         /// </summary>
-        public static string ToolsProgressBarDialog = "ToolsProgressBarDialog";
+        public static string CompressProgressBarDialog = "CompressProgressBarDialog";
 
         
     }

+ 12 - 16
PDF Office/PDF Office.csproj

@@ -125,12 +125,8 @@
     <Compile Include="CustomControl\LoadingControl.xaml.cs">
       <DependentUpon>LoadingControl.xaml</DependentUpon>
     </Compile>
-<<<<<<< Updated upstream
-    <Compile Include="Model\Dialog\ToolsDialogs\CompressDialogModel.cs" />
-    <Compile Include="Model\Dialog\ToolsDialogs\SaftyDialogs\PasswordModel.cs" />
-=======
+    <Compile Include="Model\Dialog\ToolsDialogs\CompressDialogModel\CompressDialogModel.cs" />
     <Compile Include="Model\Dialog\ToolsDialogs\SaftyDialogs\SetPasswordDialogModel.cs" />
->>>>>>> Stashed changes
     <Compile Include="Model\PageEdit\PageEditItem.cs" />
     <Compile Include="Model\ParameterNames.cs" />
     <Compile Include="Model\PDFTool\ToolItem.cs" />
@@ -148,11 +144,11 @@
     <Compile Include="ViewModels\Dialog\PageEditDialogs\ExtractDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\PageEditDialogs\InsertDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\PageEditDialogs\SplitDialogViewModel.cs" />
-    <Compile Include="ViewModels\Dialog\ToolsDialogs\CompressDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\ToolsDialogs\CompressDialogs\CompressDialogViewModel.cs" />
+    <Compile Include="ViewModels\Dialog\ToolsDialogs\CompressDialogs\CompressProgressBarDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ToolsDialogs\SaftyDialogs\CancelPasswordDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ToolsDialogs\SaftyDialogs\CheckPasswordDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ToolsDialogs\SaftyDialogs\SetPasswordDialogViewModel.cs" />
-    <Compile Include="ViewModels\Dialog\ToolsDialogs\ToolsProgressBarDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\VerifyPassWordDialogViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeCloudContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\HomeGuidContentViewModel.cs" />
@@ -178,9 +174,12 @@
     <Compile Include="Views\Dialog\PageEditDialogs\SplitDialog.xaml.cs">
       <DependentUpon>SplitDialog.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Views\Dialog\ToolsDialogs\CompressDialog.xaml.cs">
+    <Compile Include="Views\Dialog\ToolsDialogs\CompressDialogs\CompressDialog.xaml.cs">
       <DependentUpon>CompressDialog.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Dialog\ToolsDialogs\CompressDialogs\CompressProgressBarDialog.xaml.cs">
+      <DependentUpon>CompressProgressBarDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Dialog\ToolsDialogs\SaftyDialogs\CancelPasswordDialog.xaml.cs">
       <DependentUpon>CancelPasswordDialog.xaml</DependentUpon>
     </Compile>
@@ -190,9 +189,6 @@
     <Compile Include="Views\Dialog\ToolsDialogs\SaftyDialogs\SetPasswordDialog.xaml.cs">
       <DependentUpon>SetPasswordDialog.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Views\Dialog\ToolsDialogs\ToolsProgressBarDialog.xaml.cs">
-      <DependentUpon>ToolsProgressBarDialog.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Views\Dialog\VerifyPassWordDialog.xaml.cs">
       <DependentUpon>VerifyPassWordDialog.xaml</DependentUpon>
     </Compile>
@@ -302,23 +298,23 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Views\Dialog\ToolsDialogs\CompressDialog.xaml">
+    <Page Include="Views\Dialog\ToolsDialogs\CompressDialogs\CompressDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Views\Dialog\ToolsDialogs\SaftyDialogs\CancelPasswordDialog.xaml">
+    <Page Include="Views\Dialog\ToolsDialogs\CompressDialogs\CompressProgressBarDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Views\Dialog\ToolsDialogs\SaftyDialogs\CheckPasswordDialog.xaml">
+    <Page Include="Views\Dialog\ToolsDialogs\SaftyDialogs\CancelPasswordDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Views\Dialog\ToolsDialogs\SaftyDialogs\SetPasswordDialog.xaml">
+    <Page Include="Views\Dialog\ToolsDialogs\SaftyDialogs\CheckPasswordDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Views\Dialog\ToolsDialogs\ToolsProgressBarDialog.xaml">
+    <Page Include="Views\Dialog\ToolsDialogs\SaftyDialogs\SetPasswordDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>

+ 0 - 16
PDF Office/ViewModels/CompressWindowViewModel.cs

@@ -1,16 +0,0 @@
-using Prism.Commands;
-using Prism.Mvvm;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace PDF_Office.ViewModels
-{
-    public class CompressWindowViewModel : BindableBase
-    {
-        public CompressWindowViewModel()
-        {
-
-        }
-    }
-}

+ 195 - 252
PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogViewModel.cs

@@ -1,252 +1,195 @@
-<<<<<<< Updated upstream
-using PDF_Office.Model.Dialog.ToolsDialogs;
-using Prism.Commands;
-=======
-using Prism.Commands;
->>>>>>> Stashed changes
-using Prism.Mvvm;
-using Prism.Services.Dialogs;
-using System;
-using System.Collections.Generic;
-<<<<<<< Updated upstream
-using System.Diagnostics;
-using System.Linq;
-using System.Windows.Forms;
-using Forms = System.Windows.Forms;
-using System.Xml.Linq;
-using ComPDFKit.PDFDocument;
-using PDF_Office.Model;
-using System.Threading.Tasks;
-using DialogResult = Prism.Services.Dialogs.DialogResult;
-using System.Windows.Controls;
-using System.Windows;
-using MessageBox = System.Windows.Forms.MessageBox;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
-
-namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
-{
-    public class CompressDialogViewModel : BindableBase,IDialogAware
-    {
-        private CPDFDocument document;
-
-        public IDialogService dialogs;
-
-        public DelegateCommand LargeQualityCommand { get; set; }
-
-        public DelegateCommand StandardQualityCommand { get; set; }
-
-        public DelegateCommand LittleQualityCommand { get; set; }
-
-        public DelegateCommand MicroQualityCommand { get; set; }
-
-        public DelegateCommand CompressCommand { get; set; }
-
-        public DelegateCommand ConfirmCompressCommand { get; set; }
-
-        private Visibility _compressLargeStyle = Visibility.Hidden;
-        public Visibility CompressLargeStyle
-        {
-            get { return _compressLargeStyle; }
-            set
-            {
-                SetProperty(ref _compressLargeStyle, value);
-            }
-        }
-
-        private Visibility _compressStandardStyle = Visibility.Hidden;
-        public Visibility CompressStandardStyle
-        {
-            get { return _compressStandardStyle; }
-            set
-            {
-                SetProperty(ref _compressStandardStyle, value);
-            }
-        }
-        private Visibility _compressLittleStyle = Visibility.Hidden;
-        public Visibility CompressLittleStyle
-        {
-            get { return _compressLittleStyle; }
-            set
-            {
-                SetProperty(ref _compressLittleStyle, value);
-            }
-        }
-        private Visibility _compressMicroStyle = Visibility.Hidden;
-        public Visibility CompressMicroStyle
-        {
-            get { return _compressMicroStyle; }
-            set
-            {
-                SetProperty(ref _compressMicroStyle, value);
-            }
-        }
-
-        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
-
-        CompressDialogModel compressDialogModel { get; set; }
-
-        private IntPtr compressingIntpr = IntPtr.Zero;
-
-        public CompressDialogViewModel(IDialogService dialogService)
-=======
-using System.Linq;
-
-namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
-{
-    public class CompressDialogViewModel : BindableBase,IDialogAware
-    {
-        public DelegateCommand LargeQualityCommand { get; set; }
-
-        public DelegateCommand StandardQualityCommand { get; set; }
-
-        public DelegateCommand LittleQualityCommand { get; set; }
-
-        public DelegateCommand MicroQualityCommand { get; set; }
-
-        public DelegateCommand WhiteSmokeCommand { get; set; }
-
-    public CompressDialogViewModel()
->>>>>>> Stashed changes
-        {
-            LargeQualityCommand = new DelegateCommand(LargeQuality);
-            StandardQualityCommand = new DelegateCommand(StandardQuality);
-            LittleQualityCommand = new DelegateCommand(LittleQuality);
-            MicroQualityCommand = new DelegateCommand(MicroQuality);
-<<<<<<< Updated upstream
-            CompressCommand = new DelegateCommand(Compress);
-            ConfirmCompressCommand = new DelegateCommand(ConfirmCompress);
-            dialogs = dialogService;
-        }
-
-        private void LargeQuality() {
-            compressDialogModel.CompressQuality=CompressDialogModel.qualityLevel._large;
-            CompressLargeStyle = Visibility.Visible;
-            CompressStandardStyle = Visibility.Hidden;
-            CompressLittleStyle = Visibility.Hidden;
-            CompressMicroStyle = Visibility.Hidden;
-        }
-        private void StandardQuality()
-        {
-            compressDialogModel.CompressQuality =CompressDialogModel.qualityLevel._standard;
-            CompressLargeStyle = Visibility.Hidden;
-            CompressStandardStyle = Visibility.Visible;
-            CompressLittleStyle = Visibility.Hidden;
-            CompressMicroStyle = Visibility.Hidden;
-        }
-        private void LittleQuality()
-        {
-            compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._little;
-            CompressLargeStyle = Visibility.Hidden;
-            CompressStandardStyle = Visibility.Hidden;
-            CompressLittleStyle = Visibility.Visible;
-            CompressMicroStyle = Visibility.Hidden;
-=======
-            WhiteSmokeCommand = new DelegateCommand(MicroQuality);
-        }
-        private void LargeQuality() { 
-        
-        }
-        private void StandardQuality()
-        {
-
-        }
-        private void LittleQuality()
-        {
-
->>>>>>> Stashed changes
-        }
-        private void MicroQuality()
-        {
-            compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._micro;
-            CompressLargeStyle = Visibility.Hidden;
-            CompressStandardStyle = Visibility.Hidden;
-            CompressLittleStyle = Visibility.Hidden;
-            CompressMicroStyle = Visibility.Visible;
-        }
-
-<<<<<<< Updated upstream
-        private void ConfirmCompress()
-        {
-            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-        }
-
-        private int GetIndex(int pageindex)
-        {
-            Trace.WriteLine(pageindex);
-            return 0;
-        }
-        private async void  Compress() {
-
-            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
-            Forms.SaveFileDialog sfd = new Forms.SaveFileDialog();
-            /*
-             *设置这个对话框的起始保存路径
-             */
-            sfd.InitialDirectory = document.FilePath;
-            /*
-             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
-             */
-            sfd.Filter = "PDF|*.pdf;";
-            /*
-             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
-             **/
-            sfd.FileName = document.FileName + "_CompressFile.pdf";
-            if (sfd.ShowDialog() == Forms.DialogResult.OK)
-            {
-                /*
-                 * 做一些工作
-                 */
-                
-                Trace.WriteLine("compressDialogModel.CompressQuality:  " + compressDialogModel.CompressQuality);
-                DialogParameters value = new DialogParameters();
-                value.Add(ParameterNames.PDFDocument,document );
-                value.Add(ParameterNames.FilePath, sfd.FileName);
-                value.Add("compressDialogModel.CompressQuality", (int)compressDialogModel.CompressQuality);
-                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-                dialogs.ShowDialog(DialogNames.ToolsProgressBarDialog, value, e => {
-
-                });
-                
-                
-                
-            }
-            else
-            {
-                MessageBox.Show("Cancel.");
-            }
-
-        }
-=======
-        }
-
->>>>>>> Stashed changes
-        public string Title => "";
-
-        public event Action<IDialogResult> RequestClose;
-
-        public bool CanCloseDialog()
-        {
-            return true;
-        }
-
-        public void OnDialogClosed()
-        {
-        }
-
-        public void OnDialogOpened(IDialogParameters parameters)
-        {
-<<<<<<< Updated upstream
-            CPDFDocument doc = null;
-            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
-            if (doc != null)
-            {
-                 CompressDialogModel compressdialogmodel =new CompressDialogModel();
-                 document = doc;
-                 compressDialogModel = compressdialogmodel;
-                 compressDialogModel.CompressQuality =CompressDialogModel.qualityLevel._default;
-            }
-=======
->>>>>>> Stashed changes
-        }
-    }
-}
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model.Dialog.ToolsDialogs;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Diagnostics;
+using System.Windows.Forms;
+using System.Windows;
+using DialogResult = Prism.Services.Dialogs.DialogResult;
+using MessageBox = System.Windows.Forms.MessageBox;
+
+namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
+{
+    public class CompressDialogViewModel : BindableBase, IDialogAware
+    {
+        private CPDFDocument document;
+
+        public IDialogService dialogs;
+
+        public DelegateCommand LargeQualityCommand { get; set; }
+
+        public DelegateCommand StandardQualityCommand { get; set; }
+
+        public DelegateCommand LittleQualityCommand { get; set; }
+
+        public DelegateCommand MicroQualityCommand { get; set; }
+
+        public DelegateCommand CompressCommand { get; set; }
+
+        public DelegateCommand ConfirmCompressCommand { get; set; }
+
+        private Visibility _compressLargeStyle = Visibility.Hidden;
+        public Visibility CompressLargeStyle
+        {
+            get { return _compressLargeStyle; }
+            set
+            {
+                SetProperty(ref _compressLargeStyle, value);
+            }
+        }
+
+        private Visibility _compressStandardStyle = Visibility.Hidden;
+        public Visibility CompressStandardStyle
+        {
+            get { return _compressStandardStyle; }
+            set
+            {
+                SetProperty(ref _compressStandardStyle, value);
+            }
+        }
+        private Visibility _compressLittleStyle = Visibility.Hidden;
+        public Visibility CompressLittleStyle
+        {
+            get { return _compressLittleStyle; }
+            set
+            {
+                SetProperty(ref _compressLittleStyle, value);
+            }
+        }
+        private Visibility _compressMicroStyle = Visibility.Hidden;
+        public Visibility CompressMicroStyle
+        {
+            get { return _compressMicroStyle; }
+            set
+            {
+                SetProperty(ref _compressMicroStyle, value);
+            }
+        }
+
+        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
+
+        CompressDialogModel compressDialogModel { get; set; }
+
+        private IntPtr compressingIntpr = IntPtr.Zero;
+
+        public CompressDialogViewModel(IDialogService dialogService)
+        {
+            LargeQualityCommand = new DelegateCommand(LargeQuality);
+            StandardQualityCommand = new DelegateCommand(StandardQuality);
+            LittleQualityCommand = new DelegateCommand(LittleQuality);
+            MicroQualityCommand = new DelegateCommand(MicroQuality);
+            CompressCommand = new DelegateCommand(Compress);
+            ConfirmCompressCommand = new DelegateCommand(ConfirmCompress);
+            dialogs = dialogService;
+        }
+
+        private void LargeQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._large;
+            CompressLargeStyle = Visibility.Visible;
+            CompressStandardStyle = Visibility.Hidden;
+            CompressLittleStyle = Visibility.Hidden;
+            CompressMicroStyle = Visibility.Hidden;
+        }
+        private void StandardQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._standard;
+            CompressLargeStyle = Visibility.Hidden;
+            CompressStandardStyle = Visibility.Visible;
+            CompressLittleStyle = Visibility.Hidden;
+            CompressMicroStyle = Visibility.Hidden;
+        }
+        private void LittleQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._little;
+            CompressLargeStyle = Visibility.Hidden;
+            CompressStandardStyle = Visibility.Hidden;
+            CompressLittleStyle = Visibility.Visible;
+            CompressMicroStyle = Visibility.Hidden;
+        }
+        private void MicroQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._micro;
+            CompressLargeStyle = Visibility.Hidden;
+            CompressStandardStyle = Visibility.Hidden;
+            CompressLittleStyle = Visibility.Hidden;
+            CompressMicroStyle = Visibility.Visible;
+        }
+
+        private void ConfirmCompress()
+        {
+            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+        }
+
+        private int GetIndex(int pageindex)
+        {
+            Trace.WriteLine(pageindex);
+            return 0;
+        }
+        private async void Compress()
+        {
+
+            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.pdf;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             **/
+            sfd.FileName = document.FileName + "_CompressFile.pdf";
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                /*
+                 * 做一些工作
+                 */
+
+                Trace.WriteLine("compressDialogModel.CompressQuality:  " + compressDialogModel.CompressQuality);
+                DialogParameters value = new DialogParameters();
+                value.Add(ParameterNames.PDFDocument, document);
+                value.Add(ParameterNames.FilePath, sfd.FileName);
+                value.Add("compressDialogModel.CompressQuality", (int)compressDialogModel.CompressQuality);
+                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+                dialogs.ShowDialog(DialogNames.CompressProgressBarDialog, value, e => { }); 
+            }
+            else
+            {
+                MessageBox.Show("Cancel.");
+            }
+
+        }
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            CPDFDocument doc = null;
+            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
+            if (doc != null)
+            {
+                CompressDialogModel compressdialogmodel = new CompressDialogModel();
+                document = doc;
+                compressDialogModel = compressdialogmodel;
+                compressDialogModel.CompressQuality = CompressDialogModel.qualityLevel._default;
+            }
+        }
+    }
+}

+ 93 - 99
PDF Office/ViewModels/Dialog/ToolsDialogs/ToolsProgressBarDialogViewModel.cs

@@ -1,99 +1,93 @@
-using ComPDFKit.PDFDocument;
-using PDF_Office.Model;
-using PDF_Office.Model.Dialog.ToolsDialogs;
-using Prism.Commands;
-using Prism.Mvvm;
-using Prism.Services.Dialogs;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Xml.Linq;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
-
-namespace PDF_Office.ViewModels.Dialog.ToolsDialogs
-{
-    public class ToolsProgressBarDialogViewModel : BindableBase, IDialogAware
-    {
-        private IntPtr compressingIntpr = IntPtr.Zero;
-
-        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
-
-        private CPDFDocument tempDocument;
-
-        private string _pageIndex = "0";
-        /// <summary>
-        /// 页面尺寸
-        /// </summary>
-        public string PageIndex
-        {
-            get { return _pageIndex; }
-            set
-            {
-                SetProperty(ref _pageIndex, value);
-            }
-        }
-
-        private string _pageNumber = "";
-        /// <summary>
-        /// 页面尺寸
-        /// </summary>
-        public string PageNumber
-        {
-            get { return _pageNumber; }
-            set
-            {
-                SetProperty(ref _pageNumber, value);
-            }
-        }
-
-        private int GetIndex(int pageindex)
-        {
-            PageIndex= pageindex.ToString();
-            return 0;
-        }
-
-        public ToolsProgressBarDialogViewModel()
-        {
-
-        }
-
-        public string Title => "";
-
-        public event Action<IDialogResult> RequestClose;
-
-        public bool CanCloseDialog()
-        {
-            return true;
-        }
-
-        public void OnDialogClosed()
-        {
-            tempDocument.CompressFile_Cancel(compressingIntpr);
-        }
-
-        public async void OnDialogOpened(IDialogParameters parameters)
-        {
-            CPDFDocument doc = null;
-            string filepath = "";
-            int compressquality=45;
-            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
-            parameters.TryGetValue<string>(ParameterNames.FilePath, out filepath);
-            parameters.TryGetValue<int>("compressDialogModel.CompressQuality", out compressquality);
-            if (doc != null)
-            {
-                PageNumber = doc.PageCount.ToString();
-                CPDFDocument document = CPDFDocument.InitWithFilePath(doc.FilePath);
-                indexDelegate += GetIndex;
-                compressingIntpr = document.CompressFile_Init(compressquality, indexDelegate);
-                //GC.KeepAlive(indexDelegate);
-                tempDocument = document;
-                Trace.WriteLine("compressDialogModel.CompressQuality" + compressquality);
-                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filepath); });
-                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-                document.Release();
-            }
-        }
-    }
-}
+using PDF_Office.Model.Dialog.ToolsDialogs;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
+{
+    public class CompresProgressBarDialogViewModel : BindableBase, IDialogAware
+    {
+        private IntPtr compressingIntpr = IntPtr.Zero;
+
+        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
+
+        private CPDFDocument tempDocument;
+
+        private string _pageIndex = "0";
+        /// <summary>
+        /// 页面尺寸
+        /// </summary>
+        public string PageIndex
+        {
+            get { return _pageIndex; }
+            set
+            {
+                SetProperty(ref _pageIndex, value);
+            }
+        }
+
+        private string _pageNumber = "";
+        /// <summary>
+        /// 页面尺寸
+        /// </summary>
+        public string PageNumber
+        {
+            get { return _pageNumber; }
+            set
+            {
+                SetProperty(ref _pageNumber, value);
+            }
+        }
+
+        private int GetIndex(int pageindex)
+        {
+            PageIndex = pageindex.ToString();
+            return 0;
+        }
+
+
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+            tempDocument.CompressFile_Cancel(compressingIntpr);
+        }
+
+        public async void OnDialogOpened(IDialogParameters parameters)
+        {
+            CPDFDocument doc = null;
+            string filepath = "";
+            int compressquality = 45;
+            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
+            parameters.TryGetValue<string>(ParameterNames.FilePath, out filepath);
+            parameters.TryGetValue<int>("compressDialogModel.CompressQuality", out compressquality);
+            if (doc != null)
+            {
+                PageNumber = doc.PageCount.ToString();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(doc.FilePath);
+                indexDelegate += GetIndex;
+                compressingIntpr = document.CompressFile_Init(compressquality, indexDelegate);
+                //GC.KeepAlive(indexDelegate);
+                tempDocument = document;
+                Trace.WriteLine("compressDialogModel.CompressQuality" + compressquality);
+                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filepath); });
+                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+                document.Release();
+            }
+        }
+    }
+}

+ 23 - 53
PDF Office/ViewModels/Dialog/ToolsDialogs/SaftyDialogs/SetPasswordDialogViewModel.cs

@@ -28,18 +28,10 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
         public DelegateCommand DelegateCanEditTextChangedCommand { get; set; }
         public DelegateCommand DelegateConfirmEncryptCommand { get; set; }
         public DelegateCommand DelegateCancelEncryptCommand { get; set; }
-
-<<<<<<< Updated upstream
         public DelegateCommand InputPasswordCommand { get; set; }
-
-        private PasswordModel passwordModel = new PasswordModel();
-
-        private string _permissionPassword;
-        public string PermissionPassword
-=======
+         
         private bool _canOpen;
-        public bool CanOpen
->>>>>>> Stashed changes
+        public bool CanOpen 
         {
             get { return _canOpen; }
             set
@@ -181,58 +173,36 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs
             sfd.FileName = document.FileName + "_SetPassword.pdf";
             if (sfd.ShowDialog() == Forms.DialogResult.OK)
             {
-<<<<<<< Updated upstream
-                
                 /*
                  * 做一些工作
                  */
-                if (AllowsCopying == "True")
-                {
-                    Trace.WriteLine("111111111"+"True");
-                    passwordModel.PermissionsInfo.AllowsCopying = true;
-=======
-                CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
-                if (setPasswordDialogModel.CanOpen)
-                {
-                    if (!string.IsNullOrEmpty(SetPasswordDialogModel.CanOpenPassword))
+
+                    CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
+                    if (setPasswordDialogModel.CanOpen)
                     {
-                        openPassword = SetPasswordDialogModel.CanOpenPassword;
+                        if (!string.IsNullOrEmpty(SetPasswordDialogModel.CanOpenPassword))
+                        {
+                            openPassword = SetPasswordDialogModel.CanOpenPassword;
+                        }
                     }
->>>>>>> Stashed changes
-                }
-                if (setPasswordDialogModel.CanEdit)
-                {
-<<<<<<< Updated upstream
-                    passwordModel.PermissionsInfo.AllowsPrinting = true;
-                }
-                else {
-                    Trace.WriteLine("2222222"+"false");
-                    passwordModel.PermissionsInfo.AllowsPrinting = false; 
-                }
-                passwordModel.PermissionPassword=PermissionPassword;
-                document.Encrypt(PasswordModel.UserPassword, passwordModel.PermissionPassword, passwordModel.PermissionsInfo);
-=======
-                    if (!string.IsNullOrEmpty(SetPasswordDialogModel.CanEditPassword))
+                    if (setPasswordDialogModel.CanEdit)
                     {
-                        editPassword = SetPasswordDialogModel.CanEditPassword;
-                        Dictionary<string, SetPasswordDialogModel.PrintMod> GetPrintMod = new Dictionary<string, SetPasswordDialogModel.PrintMod>();
-                        Dictionary<string, SetPasswordDialogModel.ChangeMod> GetChangeMod = new Dictionary<string, SetPasswordDialogModel.ChangeMod>(); ;
-                        InitPermissionsDictionary(ref GetPrintMod, ref GetChangeMod);
-                        permissionsInfo = setPasswordDialogModel.CreatePermissionsInfo(GetPrintMod[PrintMod], GetChangeMod[ChangeMod]);
+                        if (!string.IsNullOrEmpty(SetPasswordDialogModel.CanEditPassword))
+                        {
+                            editPassword = SetPasswordDialogModel.CanEditPassword;
+                            Dictionary<string, SetPasswordDialogModel.PrintMod> GetPrintMod = new Dictionary<string, SetPasswordDialogModel.PrintMod>();
+                            Dictionary<string, SetPasswordDialogModel.ChangeMod> GetChangeMod = new Dictionary<string, SetPasswordDialogModel.ChangeMod>(); ;
+                            InitPermissionsDictionary(ref GetPrintMod, ref GetChangeMod);
+                            permissionsInfo = setPasswordDialogModel.CreatePermissionsInfo(GetPrintMod[PrintMod], GetChangeMod[ChangeMod]);
+                        }
                     }
-                } 
-                document.Encrypt(openPassword, editPassword, permissionsInfo);
->>>>>>> Stashed changes
-                document.WriteToFilePath(sfd.FileName);
-                MessageBox.Show(sfd.FileName + " 保存成功");
-                RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
-            }
-            else
-            {
-                MessageBox.Show("Cancel.");
+                    document.Encrypt(openPassword, editPassword, permissionsInfo);
+
+                    document.WriteToFilePath(sfd.FileName);
+                    MessageBox.Show(sfd.FileName + " 保存成功");
+                    RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
             }
         }
-
         public void CancelEncrypt() =>
             RequestClose?.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
 

+ 0 - 16
PDF Office/ViewModels/ToolbarViewModel.cs

@@ -1,16 +0,0 @@
-using Prism.Commands;
-using Prism.Mvvm;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace PDF_Office.ViewModels
-{
-    public class ToolbarViewModel : BindableBase
-    {
-        public ToolbarViewModel()
-        {
-
-        }
-    }
-}

+ 2 - 2
PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs

@@ -43,14 +43,14 @@ namespace PDF_Office.ViewModels.Tools
         {
             DialogParameters value = new DialogParameters();
             value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
-            dialogs.ShowDialog(DialogNames.CompressDialog, value, e => {   });
+            dialogs.ShowDialog(DialogNames.CompressDialog, value, e => {  });
         }
 
         private void OpenSetPasswordDialog()
         {
             DialogParameters value = new DialogParameters();
             value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
-            dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e => { });
+            dialogs.ShowDialog(DialogNames.CompressProgressBarDialog, value, e => { });
         }
 
         private void OpenCancelPasswordDialog()

+ 0 - 16
PDF Office/ViewModels/ToolsContentViewModel.cs

@@ -1,16 +0,0 @@
-using Prism.Commands;
-using Prism.Mvvm;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace PDF_Office.ViewModels
-{
-    public class ToolsContentViewModel : BindableBase
-    {
-        public ToolsContentViewModel()
-        {
-
-        }
-    }
-}

+ 5 - 8
PDF Office/Views/Dialog/ToolsDialogs/CompressDialog.xaml

@@ -1,17 +1,14 @@
-<UserControl x:Class="PDF_Office.Views.Dialog.ToolsDialogs.CompressDialog"
+<UserControl x:Class="PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs.CompressDialog"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:prism="http://prismlibrary.com/"             
-             prism:ViewModelLocator.AutoWireViewModel="True"
-             d:DesignHeight="500"
-             d:DesignWidth="600"
-             mc:Ignorable="d">
+             prism:ViewModelLocator.AutoWireViewModel="True">
     <UserControl.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="../../../Styles/CustomBtnStyle.xaml"/>
+                <ResourceDictionary Source="../../../../Styles/CustomBtnStyle.xaml"/>
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </UserControl.Resources>
@@ -24,7 +21,7 @@
         <TextBlock Grid.Row="0" Text="压缩PDF" FontSize="20" FontWeight="ExtraBlack" VerticalAlignment="Center" HorizontalAlignment="Left"  Margin="20,0,0,0" Height="28" Width="120"/>
         <Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1,0,1">
             <StackPanel>
-                
+
                 <Button  Style="{StaticResource CompressBtn}" Margin="0,10,0,16"  Command="{Binding LargeQualityCommand}">
                     <StackPanel Orientation="Horizontal" >
                         <Border HorizontalAlignment="Right" Margin="0,0,350,0">
@@ -35,7 +32,7 @@
                         </Border>
                     </StackPanel>
                 </Button>
-                
+
                 <Button Style="{StaticResource CompressBtn}" Margin="0,0,0,16"  Command="{Binding StandardQualityCommand}">
                     <StackPanel Orientation="Horizontal" >
                         <Border HorizontalAlignment="Right" Margin="0,0,350,0">

+ 1 - 1
PDF Office/Views/Dialog/ToolsDialogs/CompressDialog.xaml.cs

@@ -1,6 +1,6 @@
 using System.Windows.Controls;
 
-namespace PDF_Office.Views.Dialog.ToolsDialogs
+namespace PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs
 {
     /// <summary>
     /// Interaction logic for CompressDialog

+ 25 - 25
PDF Office/Views/Dialog/ToolsDialogs/ToolsProgressBarDialog.xaml

@@ -1,25 +1,25 @@
-<UserControl x:Class="PDF_Office.Views.Dialog.ToolsDialogs.ToolsProgressBarDialog"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             xmlns:prism="http://prismlibrary.com/"             
-             prism:ViewModelLocator.AutoWireViewModel="True"
-             d:DesignHeight="40"
-             d:DesignWidth="220"
-             mc:Ignorable="d">
-    <Grid Height="40" Width="220">
-        <StackPanel>
-            <StackPanel Orientation="Horizontal" Margin="13,5,0,10">
-                <TextBlock Text="Compress  "></TextBlock>
-                <TextBlock Text="("></TextBlock>
-                <TextBlock Text="{Binding PageIndex}"></TextBlock>
-                <TextBlock Text="/"></TextBlock>
-                <TextBlock Text="{Binding PageNumber}"></TextBlock>
-                <TextBlock Text=")"></TextBlock>
-
-            </StackPanel>
-            <ProgressBar Minimum="0" Maximum="{Binding PageNumber}" Value="{Binding PageIndex}"  Height="4" Width="194"/>
-        </StackPanel>
-    </Grid>
-</UserControl>
+<UserControl x:Class="PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs.CompressProgressBarDialog"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             d:DesignHeight="40"
+             d:DesignWidth="220"
+             mc:Ignorable="d">
+    <Grid Height="40" Width="220">
+        <StackPanel>
+            <StackPanel Orientation="Horizontal" Margin="13,5,0,10">
+                <TextBlock Text="Compress  "></TextBlock>
+                <TextBlock Text="("></TextBlock>
+                <TextBlock Text="{Binding PageIndex}"></TextBlock>
+                <TextBlock Text="/"></TextBlock>
+                <TextBlock Text="{Binding PageNumber}"></TextBlock>
+                <TextBlock Text=")"></TextBlock>
+
+            </StackPanel>
+            <ProgressBar Minimum="0" Maximum="{Binding PageNumber}" Value="{Binding PageIndex}"  Height="4" Width="194"/>
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 15 - 0
PDF Office/Views/Dialog/ToolsDialogs/CompressDialogs/CompressProgressBarDialog.xaml.cs

@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs
+{
+    /// <summary>
+    /// Interaction logic for CompressProgressBarDialog
+    /// </summary>
+    public partial class CompressProgressBarDialog : UserControl
+    {
+        public CompressProgressBarDialog()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 0 - 15
PDF Office/Views/Dialog/ToolsDialogs/ToolsProgressBarDialog.xaml.cs

@@ -1,15 +0,0 @@
-using System.Windows.Controls;
-
-namespace PDF_Office.Views.Dialog.ToolsDialogs
-{
-    /// <summary>
-    /// Interaction logic for ToolsProgressBarDialog
-    /// </summary>
-    public partial class ToolsProgressBarDialog : UserControl
-    {
-        public ToolsProgressBarDialog()
-        {
-            InitializeComponent();
-        }
-    }
-}