Browse Source

Merge branch 'dev' into practice2

# Conflicts:
#	PDF Office/App.xaml.cs
#	PDF Office/ComPDFKit.Viewer.dll
#	PDF Office/PDF Office.csproj
#	PDF Office/Views/Dialog/CustomCreateDialog.xaml
#	PDF Office/Views/PropertyPanel/AnnotPanel/SignatureAnnotProperty.xaml
#	PDF Office/Views/PropertyPanel/AnnotPanel/StampAnnotProperty.xaml
OYXH\oyxh 2 years ago
parent
commit
dd31404e08
100 changed files with 5148 additions and 1599 deletions
  1. 3 16
      PDF Office/App.xaml.cs
  2. BIN
      PDF Office/ComPDFKit.Desk.dll
  3. BIN
      PDF Office/ComPDFKit.Viewer.dll
  4. 222 0
      PDF Office/CustomControl/Form/LayoutAglinContent.xaml
  5. 67 0
      PDF Office/CustomControl/Form/LayoutAglinContent.xaml.cs
  6. 4 0
      PDF Office/CustomControl/NumericUpDown.xaml.cs
  7. 87 0
      PDF Office/CustomControl/ScanViewControl/CustomDraw.cs
  8. 223 0
      PDF Office/CustomControl/ScanViewControl/CustomPanel.cs
  9. 4 4
      PDF Office/CustomControl/WritableComboBox.xaml
  10. 12 0
      PDF Office/CustomControl/WritableComboBox.xaml.cs
  11. 94 0
      PDF Office/EventAggregators/ScanEvent.cs
  12. 25 2
      PDF Office/EventAggregators/SendPrintInfoEvent.cs
  13. 62 0
      PDF Office/Helper/HomePageEditHelper.cs
  14. 55 10
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs
  15. 2 1
      PDF Office/Model/ParameterNames.cs
  16. 8 0
      PDF Office/Model/RegionNames.cs
  17. 20 0
      PDF Office/PDF Office.csproj
  18. BIN
      PDF Office/Resources/BOTA/no_outline.png
  19. BIN
      PDF Office/Resources/PropertyPanel/nosign.png
  20. 1 0
      PDF Office/Styles/ContextMenuStyle.xaml
  21. 1 0
      PDF Office/Styles/OutLineItemStyle.xaml
  22. 3 3
      PDF Office/ViewModels/BOTA/OutLineControlViewModel.cs
  23. 1 1
      PDF Office/ViewModels/BottomToolContentViewModel.cs
  24. 49 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/CreateFromHtmlDialogViewModel.cs
  25. 9 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContentViewModel.cs
  26. 12 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContentViewModel.cs
  27. 173 27
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs
  28. 4 5
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs
  29. 15 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContentViewModel.cs
  30. 23 3
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs
  31. 8 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogViewModel.cs
  32. 18 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContentViewModel.cs
  33. 162 26
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs
  34. 14 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContentViewModel.cs
  35. 14 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs
  36. 93 8
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs
  37. 12 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterCreateContentViewModel.cs
  38. 147 16
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs
  39. 15 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterTemplateListContentViewModel.cs
  40. 12 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs
  41. 14 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs
  42. 13 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContentViewModel.cs
  43. 9 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContentViewModel.cs
  44. 170 19
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs
  45. 5 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContentViewModel.cs
  46. 17 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs
  47. 21 3
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs
  48. 74 11
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialogViewModel.cs
  49. 332 138
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs
  50. 921 251
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs
  51. 8 0
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContentViewModel.cs
  52. 61 7
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs
  53. 12 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContentViewModel.cs
  54. 60 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContentViewModel.cs
  55. 2 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageSplitDialogViewModel.cs
  56. 223 3
      PDF Office/ViewModels/Dialog/Redaction/MarkSettingDialogViewModel.cs
  57. 96 3
      PDF Office/ViewModels/Dialog/Redaction/RepeatMarkDialogViewModel.cs
  58. 9 5
      PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressDialogViewModel.cs
  59. 4 1
      PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressProgressBarDialogViewModel.cs
  60. 2 38
      PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs
  61. 9 1
      PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs
  62. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs
  63. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs
  64. 1 0
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs
  65. 29 6
      PDF Office/ViewModels/Form/ButtonPropertyViewModel.cs
  66. 34 5
      PDF Office/ViewModels/Form/CheckBoxPropertyViewModel.cs
  67. 35 7
      PDF Office/ViewModels/Form/ComboxPropertyViewModel.cs
  68. 10 3
      PDF Office/ViewModels/Form/FormBaseVM.cs
  69. 2 43
      PDF Office/ViewModels/Form/FormsToolContentViewModel.cs
  70. 35 6
      PDF Office/ViewModels/Form/ListBoxPropertyViewModel.cs
  71. 35 5
      PDF Office/ViewModels/Form/RadioButtonPropertyViewModel.cs
  72. 32 3
      PDF Office/ViewModels/Form/TextFieldPropertyViewModel.cs
  73. 2 6
      PDF Office/ViewModels/HomeContentViewModel.cs
  74. 45 1
      PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs
  75. 15 0
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/SignatureAnnotPropertyViewModel.cs
  76. 6 0
      PDF Office/ViewModels/PropertyPanel/AnnotPanel/SignatureCreateDialogViewModel.cs
  77. 32 2
      PDF Office/ViewModels/PropertyPanel/Scan/ScanPropertyPanelViewModel.cs
  78. 222 0
      PDF Office/ViewModels/Scan/ScanViwerViewModel.cs
  79. 1 8
      PDF Office/ViewModels/Tools/ScanContentViewModel.cs
  80. 1 1
      PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs
  81. 43 1
      PDF Office/ViewModels/ViewContentViewModel.cs
  82. 6 0
      PDF Office/Views/BOTA/OutLineControl.xaml
  83. 1 1
      PDF Office/Views/BOTA/OutLineControl.xaml.cs
  84. 174 413
      PDF Office/Views/Dialog/CustomCreateDialog.xaml
  85. 6 0
      PDF Office/Views/Dialog/CustomCreateDialog.xaml.cs
  86. 71 63
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml
  87. 136 136
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContent.xaml
  88. 106 106
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContent.xaml
  89. 24 11
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml
  90. 46 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml.cs
  91. 1 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContent.xaml
  92. 1 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContent.xaml
  93. 117 111
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContent.xaml
  94. 29 14
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml
  95. 52 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml.cs
  96. 2 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContent.xaml
  97. 20 7
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml
  98. 10 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml.cs
  99. 28 8
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialog.xaml
  100. 0 0
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialog.xaml.cs

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

@@ -54,8 +54,7 @@ using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomeP
 using ComDocumentAIKit;
 using PDF_Office.Views.PropertyPanel.Scan;
 using PDF_Office.Views.Dialog.Redaction;
-using ComPDFKitViewer.PdfViewer;
-using ComPDFKitViewer;
+using PDF_Office.Views.Scan;
 
 namespace PDF_Office
 {
@@ -73,17 +72,10 @@ namespace PDF_Office
         /// </summary>
         public static List<string> OpenedFileList = new List<string>();
 
-        /// <summary>
-        /// 分屏PDF
-        /// </summary>
-        public static CPDFViewer SplitScreenPDFViewer = null;
-
         public static CacheFilePath CachePath;
-
         /// <summary>
         /// OCR数据模型所在目录
         /// </summary>
-        public static COCREngine ocrEngine = null;
         public static string modelFolderPath = null;
 
         public static bool IsFirstOpen = true;
@@ -163,6 +155,7 @@ namespace PDF_Office
 
             containerRegistry.RegisterForNavigation<HomeContent>();
             containerRegistry.RegisterForNavigation<ViewContent>();
+            containerRegistry.RegisterForNavigation<ScanViwer>();
             containerRegistry.RegisterForNavigation<MainContent>();
             containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
             containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
@@ -177,14 +170,13 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<BookmarkContent>();
             containerRegistry.RegisterForNavigation<SearchContent>();
             containerRegistry.RegisterForNavigation<OutLineControl>();
-            //视图
             containerRegistry.RegisterForNavigation<ViewModularContent>();
             containerRegistry.RegisterForNavigation<SplitScreenContent>();
             containerRegistry.RegisterForNavigation<ThemesContent>();
             containerRegistry.RegisterForNavigation<ReadModeContent>();
             containerRegistry.RegisterForNavigation<AnnotationContent>();
             containerRegistry.RegisterForNavigation<ReadViewContent>();
-            containerRegistry.RegisterForNavigation<PageContent>();
+
 
             containerRegistry.RegisterForNavigation<HomePagePrinterDocumentContent>();
             containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
@@ -316,7 +308,6 @@ namespace PDF_Office
             containerRegistry.RegisterDialog<MarkSettingDialog>(DialogNames.MarkSettingDialog);
             containerRegistry.RegisterDialog<PageMarkDialog>(DialogNames.PageMarkDialog);
             containerRegistry.RegisterDialog<RepeatMarkDialog>(DialogNames.RepeatMarkDialog);
-
             #endregion 注册弹窗
         }
 
@@ -393,10 +384,6 @@ namespace PDF_Office
                 }
                 CPDFConverter.Init(resPath);
 
-                //加载OCR库
-                if (!DocumentAIKitLicenseVerify())
-                {
-                }
             }
             catch { }
             return result;

BIN
PDF Office/ComPDFKit.Desk.dll


BIN
PDF Office/ComPDFKit.Viewer.dll


+ 222 - 0
PDF Office/CustomControl/Form/LayoutAglinContent.xaml

@@ -0,0 +1,222 @@
+<UserControl x:Class="PDF_Office.CustomControl.Form.LayoutAglinContent"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
+             xmlns:prism="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:local="clr-namespace:PDF_Office.CustomControl.Form"
+             mc:Ignorable="d" 
+             x:Name="usercontrol"
+             d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../Styles/SliderStyle.xaml" />
+                <ResourceDictionary Source="../../Styles/CustomBtnStyle.xaml" />
+                <ResourceDictionary Source="../../Styles/RadioButtonStyle.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid
+            x:Name="LayoutAlignGrid"
+            Grid.Row="1"
+            Width="150"
+            Margin="0,10,0,0"
+            HorizontalAlignment="Left">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*" />
+            <RowDefinition Height="*" />
+        </Grid.RowDefinitions>
+
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="*" />
+        </Grid.ColumnDefinitions>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignLeft"
+                Grid.Row="0"
+                Grid.Column="0"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="AlignLeft">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M2.01367 15V1H3.51367V15H2.01367ZM5 4H11V7H5V4ZM14 9H5V12H14V9Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignLeft, Path=Foreground}" />
+            </RadioButton.Content>
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignHorizonCenter"
+                Grid.Row="0"
+                Grid.Column="1"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="AlignHorizonCenter">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M8.75 7L8.75 9L12 9L12 12L8.75 12L8.75 15L7.25 15L7.25 12L4 12L4 9L7.25 9L7.25 7L2 7L2 4L7.25 4L7.25 0.999999L8.75 1L8.75 4L14 4L14 7L8.75 7Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignHorizonCenter, Path=Foreground}" />
+            </RadioButton.Content>
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignRight"
+                Grid.Row="0"
+                Grid.Column="2"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="AlignRight">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M14 1L14 15L12.5 15L12.5 1L14 1ZM11 12L2 12L2 9L11 9L11 12ZM4 7L11 7L11 4L4 4L4 7Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignRight, Path=Foreground}" />
+            </RadioButton.Content>
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignDistributeHorizontal"
+                Grid.Row="0"
+                Grid.Column="3"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAvgAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="DistributeHorizontal">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M15 12.5L1 12.5L1 14L15 14L15 12.5ZM12 9.5L4 9.5L4 6.5L12 6.5L12 9.5ZM1 2L15 2L15 3.5L1 3.5L1 2Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignDistributeHorizontal, Path=Foreground}" />
+            </RadioButton.Content>
+           
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignTop"
+                Grid.Row="1"
+                Grid.Column="0"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="AlignTop">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M15 2L1 2L1 3.5L15 3.5L15 2ZM12 5L12 11L9 11L9 5L12 5ZM7 5L7 14L4 14L4 5L7 5Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignTop, Path=Foreground}" />
+            </RadioButton.Content>
+           
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignVerticalCenter"
+                Grid.Row="1"
+                Grid.Column="1"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="AlignVerticalCenter">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M7 7.25L9 7.25L9 4L12 4L12 7.25L15 7.25L15 8.75L12 8.75L12 12L9 12L9 8.75L7 8.75L7 14L4 14L4 8.75L1 8.75L1 7.25L4 7.25L4 2L7 2L7 7.25Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignVerticalCenter, Path=Foreground}" />
+            </RadioButton.Content>
+           
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutAlignBottom"
+                Grid.Row="1"
+                Grid.Column="2"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="AlignBottom">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M9 2H12V11H9V2ZM4 5H7V11H4V5ZM1 14H15V12.5H1V14Z"
+                        Fill="{Binding ElementName=BtnImgLayoutAlignBottom, Path=Foreground}" />
+            </RadioButton.Content>
+           
+        </RadioButton>
+
+        <RadioButton
+                x:Name="BtnImgLayoutDistributeVertical"
+                Grid.Row="1"
+                Grid.Column="3"
+                Width="32"
+                Height="32"
+                VerticalContentAlignment="Center"
+                Background="Transparent"
+                Foreground="#616469"
+                GroupName="ImgAlign"
+                Checked="Align_Checked"
+                IsEnabled="{Binding ElementName=usercontrol,Path=IsLayoutAvgAlign}"
+                Style="{DynamicResource GreyBgRadioBtnStyle}"
+                Tag="DistributeVertical">
+            <RadioButton.Content>
+                <Path
+                        Margin="5,0,0,0"
+                        Data="M2 15V1H3.5V15H2ZM6.5 4H9.5V12H6.5V4ZM12.5 1V15H14V1H12.5Z"
+                        Fill="{Binding ElementName=BtnImgLayoutDistributeVertical, Path=Foreground}" />
+            </RadioButton.Content>
+        </RadioButton>
+
+    </Grid>
+</UserControl>

+ 67 - 0
PDF Office/CustomControl/Form/LayoutAglinContent.xaml.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl.Form
+{
+    /// <summary>
+    /// LayoutAglinContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class LayoutAglinContent : UserControl
+    {
+        public event RoutedEventHandler ValueChanged;
+        public LayoutAglinContent()
+        {
+            InitializeComponent();
+        }
+
+        public bool IsLayoutAvgAlign
+        {
+            get { return (bool)GetValue(IsLayoutAvgAlignProperty); }
+            set { SetValue(IsLayoutAvgAlignProperty, value); }
+        }
+
+        public static readonly DependencyProperty IsLayoutAvgAlignProperty =
+      DependencyProperty.Register("IsLayoutAvgAlign", typeof(bool), typeof(LayoutAglinContent), new PropertyMetadata(true));
+
+
+        public bool IsLayoutAlign
+        {
+            get { return (bool)GetValue(IsLayoutAlignProperty); }
+            set { SetValue(IsLayoutAvgAlignProperty, value); }
+        }
+
+        public static readonly DependencyProperty IsLayoutAlignProperty =
+      DependencyProperty.Register("IsLayoutAlign", typeof(bool), typeof(LayoutAglinContent), new PropertyMetadata(true));
+
+        public string Btntag
+        {
+            get { return (string)GetValue(BtntagProperty); }
+            set { SetValue(BtntagProperty, value); }
+        }
+
+        public static readonly DependencyProperty BtntagProperty =
+      DependencyProperty.Register("Btntag", typeof(string), typeof(LayoutAglinContent), new PropertyMetadata(""));
+
+        private void Align_Checked(object sender, RoutedEventArgs e)
+        {
+            var btn = sender as RadioButton;
+            if (btn != null && btn.Tag != null && string.IsNullOrEmpty(btn.Tag.ToString()) == false)
+            {
+                Btntag = btn.Tag.ToString();
+                ValueChanged?.Invoke(btn.Tag.ToString(), null);
+            }
+        }
+    }
+}

+ 4 - 0
PDF Office/CustomControl/NumericUpDown.xaml.cs

@@ -182,6 +182,10 @@ namespace PDF_Office.CustomControl
             {
                 this.TextBox_Num.Text = Minimum.ToString();
             }
+            if (int.Parse(this.TextBox_Num.Text) < Minimum)
+            {
+                this.TextBox_Num.Text = Minimum.ToString();
+            }
             Text = this.TextBox_Num.Text;
             Value = (int)double.Parse(this.TextBox_Num.Text);
         }

+ 87 - 0
PDF Office/CustomControl/ScanViewControl/CustomDraw.cs

@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+
+namespace PDF_Office.CustomControl.ScanViewControl
+{
+    class CustomDraw : DrawingVisual
+    {
+        public Rect PaintRect;
+        public Rect RawRect;
+        public string PaintText;
+        public double FontSize = 0;
+        private Pen DrawPen;
+        private SolidColorBrush CoverBrush = Brushes.Transparent;// new SolidColorBrush(Color.FromArgb(0x01, 0xFF, 0xFF, 0xFF));
+        public CustomDraw()
+        {
+            DrawPen = new Pen(Brushes.Red, 1);
+        }
+
+        public void Draw()
+        {
+            DrawingContext dc = RenderOpen();
+            dc.DrawRectangle(null, DrawPen, PaintRect);
+            if (string.IsNullOrEmpty(PaintText) == false)
+            {
+                double fontSize = 1;
+                FormattedText formatText = new FormattedText(PaintText,
+                    CultureInfo.CurrentCulture,
+                    FlowDirection.LeftToRight,
+                    new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
+                    fontSize,
+                    Brushes.Green,Helper.DpiHelpers.Dpi/96F);
+                while (formatText.Width + fontSize < PaintRect.Width && formatText.Height < PaintRect.Height)
+                {
+                    fontSize += 1;
+                    formatText.SetFontSize(fontSize);
+                }
+                if (fontSize > 1)
+                {
+                    formatText.SetFontSize(fontSize - 1);
+                }
+                FontSize = fontSize;
+                dc.DrawRectangle(Brushes.White, null, PaintRect);
+                Array x = PaintText.ToCharArray();
+                double w = 0;
+
+                List<FormattedText> drawFormatList = new List<FormattedText>();
+                for (int i = 0; i < x.Length; i++)
+                {
+                    FormattedText formatText1 = new FormattedText(x.GetValue(i).ToString(),
+                    CultureInfo.CurrentCulture,
+                    FlowDirection.LeftToRight,
+                    new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
+                    fontSize,
+                    Brushes.Green, Helper.DpiHelpers.Dpi / 96F);
+                    formatText1.SetFontSize(fontSize);
+                    w += formatText1.Width;
+                    drawFormatList.Add(formatText1);
+                }
+
+                Point startPos = new Point(PaintRect.Left, (int)(PaintRect.Top));
+                double subLength = PaintRect.Width - w;
+                double offset = subLength / x.Length;
+
+                foreach (FormattedText subFormat in drawFormatList)
+                {
+                    dc.DrawText(subFormat, startPos);
+                    startPos.X += subFormat.Width + offset;
+                }
+
+            }
+            dc.Close();
+        }
+
+        public void DrawBounds()
+        {
+            DrawingContext dc = RenderOpen();
+            dc.DrawRectangle(CoverBrush, DrawPen, PaintRect);
+            dc.Close();
+        }
+    }
+}

+ 223 - 0
PDF Office/CustomControl/ScanViewControl/CustomPanel.cs

@@ -0,0 +1,223 @@
+using PDF_Office.Helper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace PDF_Office.CustomControl.ScanViewControl
+{
+    class CustomPanel: Panel
+    {
+        public SolidColorBrush CoverBrush { get; set; } = new SolidColorBrush(Color.FromArgb(0xA0, 0xFF, 0xFF, 0xFF));
+        public bool DrawCover { get; set; } = false;
+
+        private WriteableBitmap BackgroundImage = null;
+        private int BackgroundWidth = 0;
+        private int BackgroundHeight = 0;
+        private Point OffsetPos = new Point(0, 0);
+        private double ScaleRate = 1;
+        private CustomDraw HoverChild = null;
+        public TextBlock ParentBlock;
+        private int RawWidth = 0;
+        private int RawHeight = 0;
+
+
+        /// <summary>
+        /// 展示用的背景图
+        /// </summary>
+        public WriteableBitmap BGImage
+        {
+            get { return (WriteableBitmap)GetValue(BGImageProperty); }
+            set 
+            { 
+                SetValue(BGImageProperty, value); 
+            }
+        }
+
+        // Using a DependencyProperty as the backing store for BGImage.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty BGImageProperty =
+            DependencyProperty.Register("BGImage", typeof(WriteableBitmap), typeof(CustomPanel), new FrameworkPropertyMetadata(null,new PropertyChangedCallback(OnImageChanged)));
+
+        private static void OnImageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            if ((e.NewValue as  WriteableBitmap)!=null)
+            {
+                (d as CustomPanel).SetBackgroundImage(e.NewValue as WriteableBitmap);
+            }
+        }
+
+
+        /// <summary>
+        ///  当前页的OCR结果
+        /// </summary>
+        public List<KeyValuePair<Rect, string>> OCRTextRectList
+        {
+            get { return (List<KeyValuePair<Rect, string>>)GetValue(OCRTextRectListProperty); }
+            set { SetValue(OCRTextRectListProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for OCRTextRectList.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty OCRTextRectListProperty =
+            DependencyProperty.Register("OCRTextRectList", typeof(List<KeyValuePair<Rect, string>>), typeof(CustomPanel), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnOCRChanged)));
+
+        private static void OnOCRChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            if ((e.NewValue as List<KeyValuePair<Rect, string>>) != null)
+            {
+                (d as CustomPanel).SetTextsRects(e.NewValue as List<KeyValuePair<Rect, string>>);
+            }
+        }
+
+        private List<CustomDraw> VisualControlList = new List<CustomDraw>();
+        protected override int VisualChildrenCount => VisualControlList.Count;
+        protected override Visual GetVisualChild(int index)
+        {
+            return VisualControlList[index];
+        }
+        protected override void OnRender(DrawingContext dc)
+        {
+            Rect drawRect = new Rect(0, 0, ActualWidth, ActualHeight);
+            dc.DrawRectangle(Brushes.LightGray, null, drawRect);
+            DrawBackground(dc);
+        }
+
+        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
+        {
+            double scale = Math.Min(sizeInfo.NewSize.Width / BackgroundWidth, sizeInfo.NewSize.Height / BackgroundHeight);
+            scale = Math.Min(scale, 1);
+            int drawWidth = (int)(scale * BackgroundWidth);
+            int drawHeight = (int)(scale * BackgroundHeight);
+            if (drawWidth < 10 || drawHeight < 10)
+            {
+                return;
+            }
+
+            int offsetX = (int)((sizeInfo.NewSize.Width - drawWidth) / 2);
+            int offsetY = (int)((sizeInfo.NewSize.Height - drawHeight) / 2);
+            foreach (CustomDraw drawVisual in VisualControlList)
+            {
+                Rect paintRect = drawVisual.RawRect;
+                drawVisual.PaintRect = new Rect((int)(paintRect.Left * scale + offsetX),
+                   (int)(paintRect.Top * scale + offsetY),
+                   (int)(paintRect.Width * scale),
+                   (int)(paintRect.Height * scale));
+                drawVisual.Draw();
+            }
+        }
+
+        private void DrawBackground(DrawingContext dc)
+        {
+            if (BackgroundImage != null && BackgroundWidth > 0 && BackgroundHeight > 0)
+            {
+                double scale = Math.Min(ActualWidth / BackgroundWidth, ActualHeight / BackgroundHeight);
+                scale = Math.Min(scale, 1);
+                int drawWidth = (int)(scale * BackgroundWidth);
+                int drawHeight = (int)(scale * BackgroundHeight);
+                if (drawWidth < 10 || drawHeight < 10)
+                {
+                    return;
+                }
+                ScaleRate = scale;
+                OffsetPos.X = (int)((ActualWidth - drawWidth) / 2);
+                OffsetPos.Y = (int)((ActualHeight - drawHeight) / 2);
+                Rect drawRect = new Rect(OffsetPos.X, OffsetPos.Y, drawWidth, drawHeight);
+                dc.DrawImage(BackgroundImage, drawRect);
+                if (DrawCover)
+                {
+                    dc.DrawRectangle(CoverBrush, null, drawRect);
+                }
+            }
+        }
+
+        private void CleanChild()
+        {
+            foreach (DrawingVisual child in VisualControlList)
+            {
+                RemoveLogicalChild(child);
+                RemoveVisualChild(child);
+            }
+            VisualControlList.Clear();
+        }
+
+        public void SetBackgroundImage(WriteableBitmap bgImage)
+        {
+            DrawCover = false;
+            BackgroundImage = bgImage;
+            BackgroundWidth = 0;
+            BackgroundHeight = 0;
+            RawWidth = 0;
+            RawHeight = 0;
+            OffsetPos = new Point(0, 0);
+            CleanChild();
+            if (BackgroundImage != null && BackgroundImage.PixelHeight > 0 && BackgroundImage.PixelWidth > 0)
+            {
+                RawWidth = BackgroundImage.PixelWidth;
+                RawHeight = BackgroundImage.PixelHeight;
+                BackgroundWidth = DpiHelpers.GetDpiUnrelatedNum(BackgroundImage.PixelWidth);
+                BackgroundHeight = DpiHelpers.GetDpiUnrelatedNum(BackgroundImage.PixelHeight);
+
+                double scale = Math.Min(ActualWidth / BackgroundWidth, ActualHeight / BackgroundHeight);
+                scale = Math.Min(scale, 1);
+                int drawWidth = (int)(scale * BackgroundWidth);
+                int drawHeight = (int)(scale * BackgroundHeight);
+                if (drawWidth < 10 || drawHeight < 10)
+                {
+                    return;
+                }
+                ScaleRate = scale;
+                OffsetPos.X = (int)((ActualWidth - drawWidth) / 2);
+                OffsetPos.Y = (int)((ActualHeight - drawHeight) / 2);
+
+                InvalidateVisual();
+            }
+        }
+
+        public int GetBackgroundImageWidth()
+        {
+            if (BackgroundImage != null)
+            {
+                return RawWidth;
+            }
+            return 0;
+        }
+
+        public int GetBackgroundImageHeight()
+        {
+            if (BackgroundImage != null)
+            {
+                return RawHeight;
+            }
+            return 0;
+        }
+
+        public void SetTextsRects(List<KeyValuePair<Rect, string>> textsRect)
+        {
+            CleanChild();
+            foreach (KeyValuePair<Rect, string> textRect in textsRect)
+            {
+                CustomDraw drawVisual = new CustomDraw();
+                drawVisual.PaintText = textRect.Value;
+                Rect paintRect = DpiHelpers.GetDpiUnrelatedRect(textRect.Key);
+                drawVisual.RawRect = paintRect;
+                drawVisual.PaintRect = new Rect((int)(paintRect.Left * ScaleRate + OffsetPos.X),
+                    (int)(paintRect.Top * ScaleRate + OffsetPos.Y),
+                    (int)(paintRect.Width * ScaleRate),
+                    (int)(paintRect.Height * ScaleRate));
+                drawVisual.Draw();
+                VisualControlList.Add(drawVisual);
+                AddLogicalChild(drawVisual);
+                AddVisualChild(drawVisual);
+            }
+        }
+
+        public void RePaint()
+        {
+            InvalidateVisual();
+        }
+    }
+}

+ 4 - 4
PDF Office/CustomControl/WritableComboBox.xaml

@@ -15,25 +15,25 @@
             MinWidth="58"
             MinHeight="24"
             VerticalContentAlignment="Center"
-            SelectionChanged="writableComboBox_SelectionChanged"
             SelectedIndex="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=SelectedIndex}"
+            SelectionChanged="writableComboBox_SelectionChanged"
             Visibility="Visible">
             <ComboBoxItem Tag="AllPage" Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=IsAllPageVisible}">全部页面</ComboBoxItem>
             <ComboBoxItem Tag="OddPage">奇数页</ComboBoxItem>
-            <ComboBoxItem Tag="EvenPage">偶数页</ComboBoxItem>
+            <ComboBoxItem IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=EvenPageIsEnabled}" Tag="EvenPage">偶数页</ComboBoxItem>
             <ComboBoxItem Tag="CustomPage">自定义页面</ComboBoxItem>
         </ComboBox>
         <TextBox
             x:Name="writableTextBox"
             Grid.Column="0"
-            Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=Text}"
             MinHeight="{Binding ElementName=writableComboBox, Path=MinHeight}"
             HorizontalAlignment="Left"
             VerticalContentAlignment="Center"
+            Panel.ZIndex="1"
             LostFocus="writableTextBox_LostFocus"
             PreviewKeyDown="writableTextBox_PreviewKeyDown"
+            Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=Text}"
             TextChanged="writableTextBox_TextChange"
             Visibility="Hidden" />
-
     </Grid>
 </UserControl>

+ 12 - 0
PDF Office/CustomControl/WritableComboBox.xaml.cs

@@ -72,6 +72,16 @@ namespace PDF_Office.CustomControl
         public static readonly DependencyProperty CurrentPageProperty =
             DependencyProperty.Register("CurrentPage", typeof(bool), typeof(WritableComboBox), new PropertyMetadata(false));
 
+        public bool EvenPageIsEnabled
+        {
+            get { return (bool)GetValue(EvenPageIsEnabledProperty); }
+            set { SetValue(EvenPageIsEnabledProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty EvenPageIsEnabledProperty =
+            DependencyProperty.Register("EvenPageIsEnabled", typeof(bool), typeof(WritableComboBox), new PropertyMetadata(true));
+
         public string SelectedIndex
         {
             get { return (string)GetValue(SelectedIndexProperty); }
@@ -152,8 +162,10 @@ namespace PDF_Office.CustomControl
 
         private void writableComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
+            
             if (this.writableComboBox.SelectedIndex == this.writableComboBox.Items.Count - 1)
             {
+                if (this.writableComboBox.ActualWidth == 0) { this.writableTextBox.Width = 210; this.writableTextBox.Visibility = Visibility.Visible; return; }
                 this.writableTextBox.Width = this.writableComboBox.ActualWidth - 18;
                 Trace.WriteLine(this.writableComboBox.ActualWidth);
                 this.writableTextBox.Visibility = Visibility.Visible;

+ 94 - 0
PDF Office/EventAggregators/ScanEvent.cs

@@ -0,0 +1,94 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.EventAggregators
+{
+    public enum ScanMode
+    {
+        Unknown,
+        /// <summary>
+        /// 点击OCR按钮
+        /// </summary>
+        OCR,
+        /// <summary>
+        /// 区域识别
+        /// </summary>
+        Area
+    }
+
+    public enum ScanLanguageMode
+    {
+        /// <summary>
+        /// 简体中文
+        /// </summary>
+        ChineseS,
+        /// <summary>
+        /// 繁体中文
+        /// </summary>
+        ChineseT,
+        English,
+        French,
+    }
+    public class ScanEventArgs
+    {
+        private ScanMode mode = ScanMode.Unknown;
+        public ScanMode Mode 
+        {
+            get
+            {
+                return mode;
+            }
+            set
+            {
+                mode = value;
+            }
+        }
+
+        private ScanLanguageMode scanLanguage = ScanLanguageMode.English;
+        public ScanLanguageMode ScanLanguage 
+        { 
+            get
+            {
+                return scanLanguage;
+            }
+            set
+            {
+                scanLanguage = value;
+            } 
+        }
+
+        private List<int> pageRange ;
+        public List<int> PageRange 
+        {
+            get
+            {
+                return pageRange;
+            }
+            set
+            {
+                pageRange = value;
+            }
+        }
+
+        private string unicode = "";
+        public string Unicode 
+        {
+            get
+            {
+                return unicode;
+            }
+            set 
+            {
+                unicode = value;
+            }
+        }
+    }
+    class ScanEvent : PubSubEvent<ScanEventArgs>
+    {
+
+    }
+}

+ 25 - 2
PDF Office/EventAggregators/SendPrintInfoEvent.cs

@@ -27,20 +27,43 @@ namespace PDF_Office.EventAggregators
     public class PrintQueueWithUnicode
     {
         public PrintQueue printQueue;
+        public EnumBothSidesStage EnumBothSidesStage;
         public string Unicode;
     }
 
-    public class SendPrintSettingsInfoEvent:PubSubEvent<PrintSettingsInfoWithUnicode>
+    public class LabelWithUnicode
     {
+        public string Label;
+        public string Unicode;
+    }
 
+    public class EnumDuplexPrintModWithUnicode
+    {
+        public EnumDuplexPrintMod enumDuplexPrintMod;
+        public string Unicode;
     }
 
-    public class SendPrintSettingsModInfoEvent:PubSubEvent<PrintModInfoWithUnicode>
+    public class GetCurrentViewEvent
     {
+    }
 
+    public class SendPrintSettingsInfoEvent : PubSubEvent<PrintSettingsInfoWithUnicode>
+    {
+    }
+
+    public class SendPrintSettingsModInfoEvent : PubSubEvent<PrintModInfoWithUnicode>
+    {
     }
 
     public class SendPrintQueueEvent : PubSubEvent<PrintQueueWithUnicode>
     {
     }
+
+    public class SendLabelEvent : PubSubEvent<LabelWithUnicode>
+    {
+    }
+
+    public class SendDuplexPrintModEvent : PubSubEvent<EnumDuplexPrintModWithUnicode>
+    {
+    }
 }

+ 62 - 0
PDF Office/Helper/HomePageEditHelper.cs

@@ -8,6 +8,8 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Documents;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model.EditTools.Bates;
 
 namespace PDF_Office.Helper
 {
@@ -148,6 +150,66 @@ namespace PDF_Office.Helper
 
             }
         }
+
+        public static string UpDataPageRange(int pagecount,string pagerange) {
+
+            List<int> PageIndexLists = new List<int>();
+            string str = "";
+            if(CommonHelper.GetPagesInRange(ref PageIndexLists, pagerange, 9999, new char[] { ',' }, new char[] { '-' }))
+            {
+                
+                foreach (var PageIndex in PageIndexLists) {
+                   int pageindex = PageIndex + 1;
+                    if (pageindex<= pagecount)
+                    {
+                        str = str + pageindex.ToString();
+                        str = str + ",";
+                    }
+                }
+                if(str=="")
+                    return str;
+                return str.Remove(str.LastIndexOf(","),1);
+            }
+            return str;
+        }
+
+        public static string ReverseDate(string str,CPDFDocument Document)
+        {
+            string yyyy = DateTime.Now.ToString("yyyy");
+            string yy = DateTime.Now.ToString("yy");
+            string mm = DateTime.Now.ToString("MM");
+            string m = DateTime.Now.ToString("%M");
+            string dd = DateTime.Now.ToString("dd");
+            string d = DateTime.Now.ToString("%d");
+            str = str.Replace("<<m/d>>", m + "/" + d)
+            .Replace("<<m/d/yy>>", m + "/" + d + "/" + yy)
+            .Replace("<<m/d/yyyy>>", m + "/" + d + "/" + yyyy)
+            .Replace("<<mm/dd/yy>>", mm + "/" + dd + "/" + yy)
+            .Replace("<<mm/dd/yyyy>>", mm + "/" + dd + "/" + yyyy)
+            .Replace("<<d/m/yy>>", d + "/" + m + "/" + yy)
+            .Replace("<<d/m/yyyy>>", d + "/" + m + "/" + yyyy)
+            .Replace("<<dd/mm/yy>>", dd + "/" + mm + "/" + yy)
+            .Replace("<<dd/mm/yyyy>>", dd + "/" + mm + "/" + yyyy)
+            .Replace("<<mm/yy>>", mm + "/" + yy)
+            .Replace("<<mm/yyyy>>", mm + "/" + yyyy)
+            .Replace("<<m.d.yy>>", m + "." + d + "." + yy)
+            .Replace("<<m.d.yyyy>>", m + "." + d + "." + yyyy)
+            .Replace("<<mm.dd.yy>>", mm + "." + dd + "." + yy)
+            .Replace("<<mm.dd.yyyy>>", mm + "." + dd + "." + yyyy)
+            .Replace("<<mm.yy>>", mm + "." + yy)
+            .Replace("<<mm.yyyy>>", mm + "." + yyyy)
+            .Replace("<<d.m.yy>>", d + "." + m + "." + yy)
+            .Replace("<<d.m.yyyy>>", d + "." + m + "." + yyyy)
+            .Replace("<<dd.mm.yy>>", dd + "." + mm + "." + yy)
+            .Replace("<<dd.mm.yyyy>>", dd + "." + mm + "." + yyyy)
+            .Replace("<<yy-mm-dd>>", yy + "-" + mm + "-" + dd)
+            .Replace("<<yyyy-mm-dd>>", yyyy + "-" + mm + "-" + dd)
+            .Replace("<<1 of n>>", "<<1>>" + " of " + Document.PageCount)
+            .Replace("<<1/n>>", "<<1>>" + "/" + Document.PageCount)
+            .Replace("<<Page 1>>", "Page" + "<<1>>")
+            .Replace("<<Page 1 of n>>", "Page " + "<<1>>" + " of " + Document.PageCount);
+            return str;
+        }
     }
 
 }

+ 55 - 10
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogModel.cs

@@ -7,6 +7,7 @@ using System.Printing;
 using System.Runtime.Remoting.Channels;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Forms;
 using static PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter.HomePagePrinterDialogModel;
 
 namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
@@ -24,7 +25,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// <summary>
         /// 页码范围
         /// </summary>
-        public EnumPageRange EnumPageRange = EnumPageRange.StatusAllRange;
+        public int EnumPageRange = 0;
         /// <summary>
         /// 逆页序
         /// </summary>
@@ -66,18 +67,35 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// <summary>
         /// 打印Mod
         /// </summary>
-        public PrintModInfo printModInfo  = new SizeInfo();
-
-
+        public PrintModInfo PrintModInfo = new SizeInfo();
+        /// <summary>
+        /// Document对象,用于打印
+        /// </summary>
+        public PrintDocument PrintDocument = new PrintDocument();
+        /// <summary>
+        /// 是否双面打印 
+        /// </summary>
         public bool IsBothSides = false;
-
+        /// <summary>
+        /// 边距
+        /// </summary>
         public List<int> Margin = new List<int>();
+
+        /// <summary>
+        /// 需要重新渲染?
+        /// </summary>
+        public bool needRerendering = true;
+
+        public PrintSettingsInfo()
+        {
+            PrintDocument.DefaultPageSettings.Landscape = false;
+        }
     }
 
     public class HomePagePrinterDialogModel
     {
 
-    } 
+    }
 
 
     public enum EnumSizeType
@@ -86,13 +104,31 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         StatusActural,
         StatusCustomized,
     }
+    /// <summary>
+    /// 双面打印阶段
+    /// </summary>
+    public enum EnumBothSidesStage
+    {
+        StatusNone,
+        StatusFrontSide,
+        StatusBackSide
+    }
+
+    public enum EnumPageRangeWithoutCurrentPage
+    {
+        StatusAllRange,
+        StatusOddRange,
+        StatusEvenRange,
+        StatusCustomizedRange,
+    }
 
-    public enum EnumPageRange
+    public enum EnumPageRangeWithCurrentPage
     {
         StatusAllRange,
+        StatusCurrentPage,
         StatusOddRange,
         StatusEvenRange,
-        StatusCustomizedRange
+        StatusCustomizedRange,
     }
 
     public enum EnumPrintOrientation
@@ -154,10 +190,20 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         StatusRight
     }
 
+    public enum EnumDuplexPrintMod
+    {
+        StatusNone,
+        StatusFlipLongEdge,
+        StatusFlipShortEdge
+    }
 
     public class PrintModInfo
     {
         public EnumPrintMod EnumPrintMod = EnumPrintMod.StatusSize;
+        /// <summary>
+        /// 双面打印
+        /// </summary>
+        public EnumDuplexPrintMod EnumDuplexPrintMod = EnumDuplexPrintMod.StatusNone;
     }
 
     public class SizeInfo : PrintModInfo
@@ -179,7 +225,6 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         public int TileRatio { get; set; }
 
         public string Label;
-
     }
 
     public class MultipleInfo : PrintModInfo
@@ -188,7 +233,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePagePrinter
         public EnumDisplayPageNumber EnumDisplayPageNumber = EnumDisplayPageNumber.StatusTwo;
         public int HorizontalPageNumber = 2;
         public int VerticalPageNumber = 1;
-        public bool IsAutoRotate  = false;
+        public bool IsAutoRotate = false;
     }
 
     public class BookletInfo : PrintModInfo

+ 2 - 1
PDF Office/Model/ParameterNames.cs

@@ -40,7 +40,7 @@ namespace PDF_Office.Model
 
         public static string BatchProcessing_Name = "BatchProcessing_Name";
 
-        /// <summary>
+        /// <summary>
         /// 页码集合
         /// </summary>
         public static string PageList = "PageList";
@@ -105,5 +105,6 @@ namespace PDF_Office.Model
         /// </summary>
         public static string PrintQueue = "PrintQueue";
         public static string PrintSettingsInfo = "PrintSettingsInfo";
+        public static string PrintCurrentPage = "PrintCurrentPage";
     }
 }

+ 8 - 0
PDF Office/Model/RegionNames.cs

@@ -208,6 +208,14 @@ namespace PDF_Office.Model
             }
         }
 
+        public static string OCRViewerRegionName
+        {
+            get
+            {
+                return GetRegionName("OCRViewerRegionName");
+            }
+        }
+
         /// <summary>
         /// 获取MainWindowsViewModel RegionNames字典里的RegionName,
         /// 如果字典里没有键值就新建一个GUID,并插入到

+ 20 - 0
PDF Office/PDF Office.csproj

@@ -245,6 +245,9 @@
     <Compile Include="CustomControl\Form\FormFieldCombox.xaml.cs">
       <DependentUpon>FormFieldCombox.xaml</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\Form\LayoutAglinContent.xaml.cs">
+      <DependentUpon>LayoutAglinContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\IconAndTextTabItem.cs" />
     <Compile Include="CustomControl\ImageButton.cs" />
     <Compile Include="CustomControl\ImageRadioButton .cs" />
@@ -265,6 +268,8 @@
     </Compile>
     <Compile Include="CustomControl\PathButton.cs" />
     <Compile Include="CustomControl\PathRadioButton.cs" />
+    <Compile Include="CustomControl\ScanViewControl\CustomDraw.cs" />
+    <Compile Include="CustomControl\ScanViewControl\CustomPanel.cs" />
     <Compile Include="CustomControl\SystemControl\CustomCommandAction .cs" />
     <Compile Include="CustomControl\SystemControl\RoutedEventTrigger.cs" />
     <Compile Include="CustomControl\TextBoxEx.cs" />
@@ -301,6 +306,7 @@
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />
     <Compile Include="EventAggregators\RedactionCommandEvent.cs" />
+    <Compile Include="EventAggregators\ScanEvent.cs" />
     <Compile Include="EventAggregators\SendPrintInfoEvent.cs" />
     <Compile Include="EventAggregators\SplitEvent.cs" />
     <Compile Include="Helper\CacheFilePath.cs" />
@@ -487,6 +493,7 @@
     <Compile Include="ViewModels\Dialog\CustomCreateDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\DynamicPropertyDialogViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\ViewModular\PageContentViewModel.cs" />
+    <Compile Include="ViewModels\Scan\ScanViwerViewModel.cs" />
     <Compile Include="ViewModels\Tools\ConverterBarContentViewModel.cs" />
     <Compile Include="ViewModels\Dialog\ExtractDialogViewModel.cs" />
     <Compile Include="ViewModels\Dialog\FullScreenWindowViewModel.cs" />
@@ -1017,6 +1024,9 @@
     <Compile Include="Views\PropertyPanel\ViewModular\ViewModularContent.xaml.cs">
       <DependentUpon>ViewModularContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Scan\ScanViwer.xaml.cs">
+      <DependentUpon>ScanViwer.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Tools\AnnotToolContent.xaml.cs">
       <DependentUpon>AnnotToolContent.xaml</DependentUpon>
     </Compile>
@@ -1067,6 +1077,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="CustomControl\Form\LayoutAglinContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="CustomControl\LoadingControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1842,6 +1856,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Views\Scan\ScanViwer.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Tools\AnnotToolContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -1894,6 +1912,8 @@
     <Resource Include="Resources\ToolBarIcon\Scan\batch.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>
+    <Resource Include="Resources\BOTA\no_outline.png" />
+    <Resource Include="Resources\PropertyPanel\nosign.png" />
     <Content Include="source\AnalysisWord\Res\word\_rels\document.xml.rels">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

BIN
PDF Office/Resources/BOTA/no_outline.png


BIN
PDF Office/Resources/PropertyPanel/nosign.png


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

@@ -162,6 +162,7 @@
         <MenuItem
             Name="MenuDelete"
             Command="{x:Static ApplicationCommands.Delete}"
+            CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"
             Header="Delete" />
         <Separator Style="{StaticResource HorizontalSeparatorStyle}" />
         <MenuItem Name="MenuProperties" Header="Properties..." />

File diff suppressed because it is too large
+ 1 - 0
PDF Office/Styles/OutLineItemStyle.xaml


+ 3 - 3
PDF Office/ViewModels/BOTA/OutLineControlViewModel.cs

@@ -502,7 +502,7 @@ namespace PDF_Office.ViewModels.BOTA
         /// <summary>
         /// 获取对应大纲所需的缩略图数据
         /// </summary>
-        public WriteableBitmap LoadPreview(OutlineNode outlineNode)
+        public WriteableBitmap LoadPreview(OutlineNode outlineNode,int Width,int Height)
         {
             CPDFPage page = PDFViewer.Document.PageAtIndex(Convert.ToInt32(outlineNode.PageIndex) - 1);
             Size size = PDFViewer.Document.GetPageSize(Convert.ToInt32(outlineNode.PageIndex) - 1);
@@ -516,7 +516,7 @@ namespace PDF_Office.ViewModels.BOTA
             {
                 zoomXY.Y = 0;
             }
-            Size zoomSize = new Size((int)(size.Width * outlineNode.Zoom), (int)(size.Height * outlineNode.Zoom));
+            Size zoomSize = new Size((int)(Width * outlineNode.Zoom), (int)(Height * outlineNode.Zoom));
             bmpData = new byte[(int)(zoomSize.Width * zoomSize.Height * 4)];
             WirteBitmap = new WriteableBitmap((int)zoomSize.Width, (int)zoomSize.Height, 96, 96, PixelFormats.Bgra32, null);
 
@@ -524,7 +524,7 @@ namespace PDF_Office.ViewModels.BOTA
             {
                 return null;
             }
-            page.RenderPageBitmapWithMatrix((float)outlineNode.Zoom, new Rect(zoomXY.X, zoomXY.Y, zoomSize.Width, zoomSize.Height), 0xFFFFFFFF, bmpData, 1, true);
+            page.RenderPageBitmapWithMatrix((float)outlineNode.Zoom, new Rect(zoomXY.X, size.Height-zoomXY.Y, zoomSize.Width, zoomSize.Height), 0xFFFFFFFF, bmpData, 1, true);
             WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)zoomSize.Width, (int)zoomSize.Height), bmpData, WirteBitmap.BackBufferStride, 0);
             WirteBitmap.Freeze();
             return WirteBitmap;

+ 1 - 1
PDF Office/ViewModels/BottomToolContentViewModel.cs

@@ -124,7 +124,7 @@ namespace PDF_Office.ViewModels
                 }
             }
         }
-
+        
         private int pageCount;
 
         public int PageCount

+ 49 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/CreateFromHtmlDialogViewModel.cs

@@ -55,10 +55,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             set
             {
                 SetProperty(ref selectedIndex, value);
+                if (value>0)
+                {
+                    Model.PageSize = (Microsoft.Office.Interop.Word.WdPaperSize)value;
+                }
             }
         }
 
-        public List<string> PageSizes { get; set; }
+        public List<string> PageSizes { get; set; } = new List<string>();
 
         /// <summary>
         /// 数据模型
@@ -76,6 +80,50 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             OpenFileCommnad = new DelegateCommand(openFile);
             CreateCommand = new DelegateCommand(createFile);
             CancelCommand = new DelegateCommand(cancel);
+            InitPageSize();
+        }
+
+        private void InitPageSize()
+        {
+            PageSizes.Add("10x14");
+            PageSizes.Add("11x17");
+            PageSizes.Add("Letter");
+            PageSizes.Add("LetterSmall");
+            PageSizes.Add("Legal");
+            PageSizes.Add("Executive");
+            PageSizes.Add("A3");
+            PageSizes.Add("A4");
+            PageSizes.Add("A4Small");
+            PageSizes.Add("A5");
+            PageSizes.Add("B4");
+            PageSizes.Add("B5");
+            PageSizes.Add("CSheet");
+            PageSizes.Add("DSheet");
+            PageSizes.Add("ESheet");
+            PageSizes.Add("FanfoldLegalGerman");
+            PageSizes.Add("FanfoldStdGerman");
+            PageSizes.Add("FanfoldUS");
+            PageSizes.Add("Folio");
+            PageSizes.Add("Ledger");
+            PageSizes.Add("Note");
+            PageSizes.Add("Quarto");
+            PageSizes.Add("Statement");
+            PageSizes.Add("Tabloid");
+            PageSizes.Add("Envelope9");
+            PageSizes.Add("Envelope10");
+            PageSizes.Add("Envelope11");
+            PageSizes.Add("Envelope12");
+            PageSizes.Add("EnvelopeB4");
+            PageSizes.Add("EnvelopeB5");
+            PageSizes.Add("EnvelopeB6");
+            PageSizes.Add("EnvelopeC3");
+            PageSizes.Add("EnvelopeC4");
+            PageSizes.Add("EnvelopeC6");
+            PageSizes.Add("EnvelopeC65");
+            PageSizes.Add("EnvelopeDL");
+            PageSizes.Add("EnvelopeItaly");
+            PageSizes.Add("EnvelopeMonarch");
+            PageSizes.Add("EnvelopePersonal");
         }
 
         private void createFile()

+ 9 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContentViewModel.cs

@@ -15,6 +15,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Windows.Media;
+using PDF_Office.Model.EditTools.Bates;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
 {
@@ -166,9 +167,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             get { return _pageRangeText; }
             set
             {
+                List<int> PageIndexLists = new List<int>();
                 _pageRangeText = value;
-                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
-                
+                BackgroundInfo.PageRange = PageRangeText;
+                if (PageRangeSelectIndex == 3 && !CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' }))
+                {
+                    BackgroundInfo.PageRangeIndex = 0;
+                }
+                BackgroundInfo.PageRangeIndex = 3;
+
             }
         }
 

+ 12 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContentViewModel.cs

@@ -230,9 +230,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             get { return _pageRangeText; }
             set
             {
+                List<int> PageIndexLists = new List<int>();
                 _pageRangeText = value;
-               // EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
-                
+                BackgroundInfo.PageRange = PageRangeText;
+                if (PageRangeSelectIndex == 3 && !CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' }))
+                {
+                    BackgroundInfo.PageRangeIndex = 0;
+                }
+                BackgroundInfo.PageRangeIndex = 3;
+
+
             }
         }
 
@@ -243,6 +250,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             set
             {
                 SetProperty(ref _pageRangeSelectIndex, value);
+                BackgroundInfo.PageRangeIndex = PageRangeSelectIndex;
                 //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BackgroundInfo.PageRange, PageRangeText);
             }
         }
@@ -396,6 +404,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             backgroundItem.rotation = backgroundInfo.Rotation;
             backgroundItem.isRelativeScale = backgroundInfo.IsRelativeScale;
             backgroundItem.scale = backgroundInfo.Scale;
+            backgroundItem.PageRangeIndex = backgroundInfo.PageRangeIndex;
+            backgroundItem.pageRange = backgroundInfo.PageRange;
             //backgroundItem.pagRangeMode = backgroundInfo.PageRange;
         }
 

+ 173 - 27
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs

@@ -18,6 +18,9 @@ using Prism.Events;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDFSettings;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.Background;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
 {
@@ -26,11 +29,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         #region 参数和属性
         private List<string> fileNames;
 
+        public BackgroundInfo BackgroundInfo;
 
         private CPDFDocument tempDocument;
 
         public string PageNumber = "";
 
+        private CPDFBackground background;
+
         public IRegionManager backgroundRegion;
         public IEventAggregator eventAggregator;
 
@@ -184,6 +190,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
         #endregion
 
         #region 委托声明
@@ -204,10 +234,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             this.backgroundRegion = backgroundRegion;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
             PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FilePageRangeText");
             PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
@@ -228,10 +260,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListBaseName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateBaseName);
             }
         }
@@ -239,6 +275,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             if (SelectedContentName == TemplateListBaseName)
             {
                 param.Add("CurrentCreateModName", CurrentCreateMod);
@@ -286,43 +323,83 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("BackgroundItem", backgroundItem);
             backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, CreateBaseName, param);
             BackgroundSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         private void create()
         {
-
+            updateListview("待确定");
             fileNamesIndex = 0;
             BackgroundGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-            //    FileInfo fileinfo = new FileInfo(filename);
-            //    string OutputPath = fileinfo.DirectoryName;
-            //    char[] enumerationSeparator = new char[] { ',' };
-            //    char[] rangeSeparator = new char[] { '-' };
-            //    List<int> PageIndexLists = new List<int>();
-            //    CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-            //    if (document == null)
-            //    {
-            //        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-            //        continue;
-            //    }
-            //    if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
-            //    { //TODO
-            //        Trace.WriteLine("输入不对");
-            //        MessageBoxEx.Show("输入不对");
-            //        return;
-            //    }
-
-            //    document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null || document.IsEncrypted)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateBackground(document);
+                document.WriteToFilePath(filename + "_Background.pdf");
+                //    if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
+                //    { //TODO
+                //        Trace.WriteLine("输入不对");
+                //        MessageBoxEx.Show("输入不对");
+                //        return;
+                //    }
+
+                //    document.Release();
+                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             BackgroundGridIsEnabled = "True";
         }
+
+        public void CreateBackground(CPDFDocument document)
+        {
+            if (BackgroundInfo != null)
+            {
+                background = document.GetBackground();
+                if (BackgroundInfo.BackgroundType == C_Background_Type.BG_TYPE_COLOR)
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_COLOR);
+                    background.SetColor(BackgroundInfo.Color);
+                }
+                else
+                {
+                    background.SetBackgroundType(C_Background_Type.BG_TYPE_IMAGE);
+                    background.SetImage(BackgroundInfo.ImageArray, BackgroundInfo.ImageWidth, BackgroundInfo.ImageHeight, ComPDFKit.Import.C_Scale_Type.fitCenter);
+                }
+                if (!BackgroundInfo.IsRelativeScale)
+                {
+                    background.SetScale(1);
+                }
+                else
+                {
+                    background.SetScale((float)(BackgroundInfo.Scale / 100));
+                }
+                background.SetRotation((float)((BackgroundInfo.Rotation / 180) * Math.PI));
+                background.SetOpacity((byte)(((float)BackgroundInfo.Opacity / 100) * 255));
+                background.SetVertalign(BackgroundInfo.Vertalign);
+                background.SetHorizalign(BackgroundInfo.Horizalign);
+                background.SetXOffset(BackgroundInfo.HorizOffset);
+                background.SetYOffset(BackgroundInfo.VertOffset);
+                background.SetAllowsPrint(true);
+                background.SetAllowsView(true);
+                background.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+                background.Update();
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -372,6 +449,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             Filenames = filenames;
         }
 
+
         /// <summary>
         /// 添加PDF文件夹
         /// </summary>
@@ -411,15 +489,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FilePageRangeText");
             pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
             int datatableindex = 0;
+            List<int> PageIndexLists = new List<int>();
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]); 
+                if (!isEvenPage(fileName) && PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "2")
+                {
+
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), CPDFDocument.InitWithFilePath(fileName).PageCount, new char[] { ',' }, new char[] { '-' }, true))
+                {
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]); 
                 datatableindex++;
             }
             PDFDataTable = pdfdatatable;
@@ -429,15 +518,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         /// <summary>
         /// 更新Currentlistview显示
-        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
         /// </summary>
-        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0",bool isevenpageisenabled=true,string state = "待完成")
         {
             if (fileNames.Count >= FileNameNumber)
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
                 }
             }
             else
@@ -450,6 +539,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 判断是否关闭偶数页
+        /// document 文档对象 )
+        /// </summary>
+        public bool isEvenPage(string filename)
+        {
+            CPDFDocument document= CPDFDocument.InitWithFilePath(filename);
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            document.Release();
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -491,6 +622,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateListview("待确定");
         }
 
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+
+            if (fileNames.Count < 1)
+            {
+                SetBackgroundGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
 
         public void PDFFileCount()
         {
@@ -520,6 +664,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 fileNames = filepath;
                 PDFFileCount();
                 updateListview("待确定");
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListBaseName);
             }
         }

+ 4 - 5
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListBaseContentViewModel.cs

@@ -14,7 +14,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
     {
         public IRegionManager backgroundTemplateListRegion;
         private readonly IEventAggregator eventAggregator;
-
+        private HomePageBackgroundDialogViewModel homePageBackgroundDialogViewModel;
         private string BackgroundTemplateListColorContentName = "HomePageBackgroundTemplateListColorContent";
         private string BackgroundTemplateListFileContentName = "HomePageBackgroundTemplateListFileContent";
 
@@ -75,8 +75,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void EnterSelectedTemplateListMod(string currentTemplateListName)
         {
             NavigationParameters param = new NavigationParameters();
-            param.Add("UniCode", unicode);
-            backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName);
+            param.Add("ViewModel", homePageBackgroundDialogViewModel);
+            backgroundTemplateListRegion.RequestNavigate(BackgroundTemplateListRegionName, currentTemplateListName,param);
             backgroundTemplateListVisible = System.Windows.Visibility.Visible;
         }
 
@@ -106,8 +106,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-
-            navigationContext.Parameters.TryGetValue<string>("UniCode", out unicode);
+            navigationContext.Parameters.TryGetValue<HomePageBackgroundDialogViewModel>("ViewModel", out homePageBackgroundDialogViewModel);
             if (IsFirstEnter)
             {
                 CurrentTemplateListModName = BackgroundTemplateListColorContentName;

+ 15 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContentViewModel.cs

@@ -1,4 +1,7 @@
-using PDF_Office.EventAggregators;
+using ComPDFKit.PDFDocument;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Properties;
 using PDFSettings;
@@ -21,6 +24,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         private readonly IEventAggregator eventAggregator;
         public BackgroundInfo BackgroundInfo = new BackgroundInfo();
         public BackgroundItem BackgroundItem = new BackgroundItem();
+        private HomePageBackgroundDialogViewModel homePageBackgroundDialogViewModel;
         public int TemplateIndex = 0;
 
         private ObservableCollection<BackgroundItem> backgroundModcolorCollection = new ObservableCollection<BackgroundItem>();
@@ -197,6 +201,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             backgroundInfo.Opacity = backgroundItem.opacity;
             backgroundInfo.Rotation = backgroundItem.rotation;
             backgroundInfo.Scale = backgroundItem.scale;
+            backgroundInfo.PageRangeIndex = backgroundItem.PageRangeIndex;
+            backgroundInfo.PageRange = backgroundItem.pageRange;
             //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
 
         }
@@ -206,7 +212,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (template != null)
             {
                 ConvertItemToInfo(template, ref BackgroundInfo);
-               
+                homePageBackgroundDialogViewModel.BackgroundInfo = BackgroundInfo;
+                for (int i = 0; homePageBackgroundDialogViewModel.PDFDataTable.Rows.Count > i; i++)
+                {
+                    homePageBackgroundDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = HomePageEditHelper.UpDataPageRange(CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[i]).PageCount, BackgroundInfo.PageRange);
+                    homePageBackgroundDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = BackgroundInfo.PageRangeIndex.ToString();
+                    homePageBackgroundDialogViewModel.updateListview("待确定");
+                }
             }
 
         }
@@ -231,6 +243,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageBackgroundDialogViewModel>("ViewModel", out homePageBackgroundDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 23 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContentViewModel.cs

@@ -1,6 +1,12 @@
-using PDF_Office.EventAggregators;
+using ComPDFKit.PDFDocument;
+using Microsoft.Office.Interop.Word;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Bates;
 using PDF_Office.Properties;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
 using PDFSettings;
 using Prism.Commands;
 using Prism.Events;
@@ -21,6 +27,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         private readonly IEventAggregator eventAggregator;
         public BackgroundInfo BackgroundInfo = new BackgroundInfo();
         public BackgroundItem BackgroundItem = new BackgroundItem();
+        private HomePageBackgroundDialogViewModel homePageBackgroundDialogViewModel;
         public int TemplateIndex = 0;
 
         public ObservableCollection<BackgroundItem> backgroundModFileCollection = new ObservableCollection<BackgroundItem>();
@@ -207,13 +214,25 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 backgroundInfo.Opacity = backgroundItem.opacity;
                 backgroundInfo.Rotation = backgroundItem.rotation;
                 backgroundInfo.Scale = backgroundItem.scale;
+                backgroundInfo.PageRangeIndex = backgroundItem.PageRangeIndex;
+                backgroundInfo.PageRange = backgroundItem.pageRange;
                 //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
             }
         }
 
-        public void SendTemplateItemToDocument(BackgroundItem BackgroundItem)
+        public void SendTemplateItemToDocument(BackgroundItem template)
         {
-            ConvertItemToInfo(BackgroundItem, ref BackgroundInfo);
+            if (template != null)
+            {
+                ConvertItemToInfo(template, ref BackgroundInfo);
+                homePageBackgroundDialogViewModel.BackgroundInfo = BackgroundInfo;
+                for (int i = 0; homePageBackgroundDialogViewModel.PDFDataTable.Rows.Count > i; i++)
+                {
+                    homePageBackgroundDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = HomePageEditHelper.UpDataPageRange(CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[i]).PageCount, BackgroundInfo.PageRange);
+                    homePageBackgroundDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = BackgroundInfo.PageRangeIndex.ToString();
+                    homePageBackgroundDialogViewModel.updateListview("待确定");
+                }
+            }
         }
 
         public void SelectTemplateItem(object e)
@@ -235,6 +254,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageBackgroundDialogViewModel>("ViewModel", out homePageBackgroundDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 8 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBatchProcessingDialogViewModel.cs

@@ -22,6 +22,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public IRegionManager BatchProcessingRegion;
 
+        int convertertypeindex = 0;
+
         private string batchProcessingRegionName;
         public string BatchProcessingRegionName
         {
@@ -58,6 +60,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.FilePath, HomePageBatchProcessingDialogModel.FilePaths);
             BatchProcessingVisible = Visibility.Collapsed;
+            if (index =="0") {
+                param.Add("ConverterTypeIndex", convertertypeindex);
+            }
             BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, HomePageBatchProcessingDialogModel.GetBatchProcessing[int.Parse(index)], param);
             BatchProcessingVisible = Visibility.Visible;
         }
@@ -83,10 +88,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             string batchprocessingname = "";
             string[] filepath = null;
+            int convertertypeindex=0;
             parameters.TryGetValue<string>(ParameterNames.BatchProcessing_Name, out batchprocessingname);
             parameters.TryGetValue<string[]>(ParameterNames.FilePath, out filepath);
+            parameters.TryGetValue<int>("ConverterTypeIndex", out convertertypeindex);
             if (batchprocessingname != null || filepath != null) {
                 fileNames = filepath.ToList();
+                this.convertertypeindex = convertertypeindex;
                 ChangeBatchProcessing(batchprocessingname);
             }
         }

+ 18 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContentViewModel.cs

@@ -15,6 +15,11 @@ using System.IO;
 using System.Linq;
 using System.Windows.Media;
 using System.Windows;
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer;
+using Microsoft.Office.Interop.Word;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using System.Diagnostics;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
@@ -140,9 +145,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             get { return _pageRangeText; }
             set
             {
+                List<int> PageIndexLists = new List<int>();
                 _pageRangeText = value;
+                BatesInfo.PageRange =PageRangeText;
+                if (PageRangeSelectIndex == 3 && !CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' })) {
+                    BatesInfo.PageRangeIndex = 0;
+                }
+                BatesInfo.PageRangeIndex = 3;
+                //CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' });
+                //foreach (var a in PageIndexLists) {
+                //    Trace.WriteLine("页面范围:" + a);
+                //}
+                //CommonHelper.GetPagesInRange(ref PageIndexLists, BatesInfo.PageRange, , new char[] { ',' }, new char[] { '-' }, true))
                 //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
-                
+
             }
         }
 
@@ -586,6 +602,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
             batesInfo.margin = batesItem.margin;
             batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+            batesInfo.PageRange=batesItem.PageRange;
             //EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
 
         }

+ 162 - 26
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs

@@ -19,6 +19,10 @@ using Prism.Events;
 using PDF_Office.EventAggregators;
 using PDFSettings;
 using ImTools;
+using PDF_Office.Model.EditTools.Watermark;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.Background;
+using MessageBox = System.Windows.MessageBox;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
@@ -32,6 +36,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string PageNumber = "";
 
+        private CPDFBates bates;
+
+        public BatesInfo BatesInfo;
+
         public IEventAggregator eventAggregator;
         public IRegionManager batesRegion;
 
@@ -50,7 +58,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private int fileNamesIndex = 0;
 
-        private int FileNameNumber = 0;
+        public int FileNameNumber = 0;
 
         private string _batesSettingsRegionName;
         /// <summary>
@@ -156,6 +164,31 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
         #endregion
 
         #region 委托声明
@@ -178,10 +211,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
             PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FilePageRangeText");
             PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
             ADDPDFCommand = new DelegateCommand(addpicture);
@@ -200,6 +235,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("BatesItem", batesItem);
             batesRegion.RequestNavigate(BatesSettingsRegionName, CreateName, param);
             BatesSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
@@ -207,10 +244,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateName);
             }
         }
@@ -219,28 +260,33 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             batesRegion.RequestNavigate(BatesSettingsRegionName, SelectedContentName, param);
             BatesSettingsVisible = Visibility.Visible;
         }
 
         private void create()
         {
-
+            updateListview("待确定");
             fileNamesIndex = 0;
             BatesGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-                //FileInfo fileinfo = new FileInfo(filename);
-                //string OutputPath = fileinfo.DirectoryName;
-                //char[] enumerationSeparator = new char[] { ',' };
-                //char[] rangeSeparator = new char[] { '-' };
-                //List<int> PageIndexLists = new List<int>();
-                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                //if (document == null)
-                //{
-                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-                //    continue;
-                //}
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null||document.IsEncrypted)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
+                    continue; 
+                }
+               // MessageBox.Show(filename);
+                CreateBates(document);
+                document.WriteToFilePath(filename + "_Bates.pdf");
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -249,15 +295,43 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //}
 
                 //document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             BatesGridIsEnabled = "True";
         }
+
+        public void CreateBates(CPDFDocument document)
+        {
+            if (BatesInfo != null)
+            {
+                if (bates != null) { bates.Release(); }
+                
+                    bates = document.GetBates();
+                
+                
+                for (int i = 0; i < 6; i++)
+                {
+                    bates.SetText(i, BatesInfo.TextData[i].text);
+
+                    bates.SetFontName(i, BatesInfo.TextData[i].fontName);
+                    bates.SetFontSize(i, BatesInfo.TextData[i].fontSize);
+
+                    bates.SetTextColor(i, BatesInfo.TextData[i].Color);
+                }
+                bates.SetPageOffset(BatesInfo.StarPagetNumber + 1);
+
+                bates.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+
+                bates.SetMargin(BatesInfo.margin);
+                bates.Update();
+
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -348,20 +422,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FilePageRangeText");
             pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
             int datatableindex = 0;
+            List<int> PageIndexLists = new List<int>();
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
+                if (!isEvenPage(fileName)&& PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString()=="2") {
 
-                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
-                datatableindex++;
-
-
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), CPDFDocument.InitWithFilePath(fileName).PageCount, new char[] { ',' }, new char[] { '-' },true)) {
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
 
+                }
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
             }
             PDFDataTable = pdfdatatable;
             HomePageBatchProcessingDialogModel.FilePaths = fileNames;
@@ -369,18 +449,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         }
         /// <summary>
         /// 更新Currentlistview显示
-        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
         /// </summary>
-        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", bool isevenpageisenabled = true, string state = "待完成")
         {
             if (fileNames.Count >= FileNameNumber)
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
-                    //PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
-                    //PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
-                    //PDFCurrentDataTable.Rows[i]["FileState"] = state;
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
                 }
             }
             else
@@ -392,6 +469,49 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 }
             }
         }
+
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 判断是否关闭偶数页
+        /// document 文档对象 )
+        /// </summary>
+        public bool isEvenPage(string filename)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            document.Release();
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -433,7 +553,21 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             updateListview("待确定");
         }
+        public void removepdffile(int index)
+        {
 
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+            
+            if (fileNames.Count < 1)
+            {
+                SetBatesGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+            
+        }
 
         public void PDFFileCount()
         {
@@ -464,6 +598,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (filepath != null)
             {
                 fileNames = filepath;
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 PDFFileCount();
                 updateListview("待确定");
                 EnterSelectedContent(TemplateListName);

+ 14 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContentViewModel.cs

@@ -15,11 +15,16 @@ using System.Collections.ObjectModel;
 using System.Linq;
 using System.Windows.Controls;
 using System.Windows;
+using Prism.Common;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using ComPDFKit.PDFDocument;
+using Microsoft.Office.Interop.Word;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
     public class HomePageBatesTemplateListContentViewModel : BindableBase, INavigationAware
     {
+        private HomePageBatesDialogViewModel homePageBatesDialogViewModel;
         private CPDFViewer PDFViewer;
         public IEventAggregator eventAggregator;
         public BatesInfo BatesInfo = new BatesInfo();
@@ -168,9 +173,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (template != null)
             {
                 ConvertItemToInfo(template, ref BatesInfo);
-                
-            }
+                homePageBatesDialogViewModel.BatesInfo = BatesInfo;
+                for(int i =0; homePageBatesDialogViewModel.PDFDataTable.Rows.Count> i;i++) {
 
+                    homePageBatesDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = HomePageEditHelper.UpDataPageRange(CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[i]).PageCount, BatesInfo.PageRange);
+                    homePageBatesDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = BatesInfo.PageRangeIndex.ToString();
+                    homePageBatesDialogViewModel.updateListview("待确定");
+                }
+            }
         }
 
         private void GetBatesSource()
@@ -196,6 +206,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
             batesInfo.margin = batesItem.margin;
             batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
+            batesInfo.PageRange = batesItem.PageRange;
             //EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
 
         }
@@ -223,6 +234,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<HomePageBatesDialogViewModel>("ViewModel", out homePageBatesDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 14 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs

@@ -365,6 +365,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateListview("待确定");
         }
 
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+
+            if (fileNames.Count < 1)
+            {
+                SetCompressGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
+
 
         public void PDFFileCount()
         {

+ 93 - 8
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs

@@ -44,8 +44,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public IRegionManager ConverterRegion;
 
-        public int ConverterTypeIndex=0;
-
         public List<int> fileNamesView = new List<int>();
 
         private int fileNamesIndex = 0;
@@ -132,6 +130,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        private int converterTypeIndex = 0;
+        public int ConverterTypeIndex
+        {
+            get { return converterTypeIndex; }
+            set
+            {
+                SetProperty(ref converterTypeIndex, value);
+            }
+        }
         private string converterRegionName;
         public string ConverterRegionName
         {
@@ -163,6 +170,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
         #endregion
 
         #region 委托声明
@@ -179,8 +187,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
 
             SetImageTypeOrigin();
+
+            PDFCurrentDataTable.Columns.Add("FilePageRangeText");
+            PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
+            PDFDataTable.Columns.Add("FilePageRangeText");
+            PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
             ADDPDFCommand = new DelegateCommand(addpicture);
@@ -199,7 +214,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private async void convert()
         {
-
+            updateListview("待确定");
             bool result = false;
             OnProgress GetProgress = null;
             GetProgress += SetProgress;
@@ -385,15 +400,28 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateCurrentListview();
             DataTable pdfdatatable = new DataTable();
             pdfdatatable.Columns.Add("FileName");
+            pdfdatatable.Columns.Add("FilePageRangeText");
+            pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
             int datatableindex = 0;
+            List<int> PageIndexLists = new List<int>();
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                if (!isEvenPage(fileName) && PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "2")
+                {
+
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), CPDFDocument.InitWithFilePath(fileName).PageCount, new char[] { ',' }, new char[] { '-' }, true))
+                {
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
                 datatableindex++;
             }
             PDFDataTable = pdfdatatable;
@@ -403,15 +431,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         /// <summary>
         /// 更新Currentlistview显示
-        /// state 状态显示字符串
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
         /// </summary>
-        public void updateCurrentListview(string state = "待完成")
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", bool isevenpageisenabled = true, string state = "待完成")
         {
             if (fileNames.Count >= FileNameNumber)
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    PDFCurrentDataTable.Rows.Add(state);
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
                 }
             }
             else
@@ -424,6 +452,49 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 判断是否关闭偶数页
+        /// document 文档对象 )
+        /// </summary>
+        public bool isEvenPage(string filename)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            document.Release();
+            return isevenpage;
+        }
+
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -464,7 +535,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
             updateListview("待确定");
         }
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
 
+            if (fileNames.Count < 1)
+            {
+                SetConverterGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
 
         public void PDFFileCount()
         {
@@ -499,13 +582,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             List<string> filepath = new List<string>();
+            int convertertypeindex=0;
             navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
+            navigationContext.Parameters.TryGetValue<int>("ConverterTypeIndex", out convertertypeindex);
             if (filepath != null)
             {
                 fileNames = filepath;
                 PDFFileCount();
                 updateListview("待确定");
-                ChangeConverter(0);
+                ChangeConverter(ConverterTypeIndex);
             }
         }
        

+ 12 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterCreateContentViewModel.cs

@@ -15,6 +15,8 @@ using System.IO;
 using System.Linq;
 using System.Windows.Media;
 using System.Windows;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.Model.EditTools.Background;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
 {
@@ -219,9 +221,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             get { return _pageRangeText; }
             set
             {
+               
+                List<int> PageIndexLists = new List<int>();
                 _pageRangeText = value;
+                HeaderFooterInfo.PageRange = PageRangeText;
+                if (PageRangeSelectIndex == 3 && !CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' }))
+                {
+                    HeaderFooterInfo.PageRangeIndex = 0;
+                }
+                HeaderFooterInfo.PageRangeIndex = 3;
                 //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
-                
+
             }
         }
 
@@ -602,6 +612,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
             headerFooterInfo.margin = headerFooterItem.margin;
             headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
+            headerFooterInfo.PageRange=headerFooterItem.PageRange;
             //EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
         }
 

+ 147 - 16
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs

@@ -18,6 +18,7 @@ using Prism.Events;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDFSettings;
+using PDF_Office.Model.EditTools.HeaderFooter;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
 {
@@ -31,11 +32,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string PageNumber = "";
 
+        private CPDFHeaderFooter headerFooter;
+
         public IRegionManager headerFooterRegion;
         public IEventAggregator eventAggregator;
 
         private CPDFViewer PDFViewer;
 
+        public HeaderFooterInfo HeaderFooterInfo;
+
         private ViewContentViewModel viewContentViewModel;
 
         public string TemplateListName = "HomePageHeaderFooterTemplateListContent";
@@ -167,6 +172,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
         #endregion
 
         #region 委托声明
@@ -190,10 +219,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
             PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FilePageRangeText");
             PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
             ADDPDFCommand = new DelegateCommand(addpicture);
@@ -213,6 +244,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("HeaderFooterItem", headerfooterItem);
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
@@ -220,10 +253,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateName);
             }
         }
@@ -232,28 +269,31 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
         }
 
         private  void create()
         {
-
+            updateListview("待确定");
             fileNamesIndex = 0;
             HeaderFooterGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-                //FileInfo fileinfo = new FileInfo(filename);
-                //string OutputPath = fileinfo.DirectoryName;
-                //char[] enumerationSeparator = new char[] { ',' };
-                //char[] rangeSeparator = new char[] { '-' };
-                //List<int> PageIndexLists = new List<int>();
-                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                //if (document == null)
-                //{
-                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-                //    continue;
-                //}
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null || document.IsEncrypted)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateHeaderFooter(document);
+                document.WriteToFilePath(filename + "_HeaderFooter.pdf");
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -271,6 +311,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
             HeaderFooterGridIsEnabled = "True";
         }
+
+        public void CreateHeaderFooter(CPDFDocument document)
+        {
+            if (HeaderFooterInfo != null)
+            {
+
+                //document.(HeaderFooterInfo.TextData, HeaderFooterInfo.margin, HeaderFooterInfo.PageRange, HeaderFooterInfo.StarPagetNumber + 1);
+                headerFooter = document.GetHeaderFooter();
+                for (int i = 0; i < 6; i++)
+                {
+                    headerFooter.SetText(i, HomePageEditHelper.ReverseDate(HeaderFooterInfo.TextData[i].text, document));
+
+                    headerFooter.SetFontName(i, HeaderFooterInfo.TextData[i].fontName);
+                    headerFooter.SetFontSize(i, HeaderFooterInfo.TextData[i].fontSize);
+
+                    headerFooter.SetTextColor(i, HeaderFooterInfo.TextData[i].Color);
+                }
+                    headerFooter.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+                headerFooter.SetPageOffset(HeaderFooterInfo.StarPagetNumber + 1);
+                
+                headerFooter.SetMargin(HeaderFooterInfo.margin);
+                headerFooter.Update();
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -359,15 +423,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FilePageRangeText");
             pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
             int datatableindex = 0;
+            List<int> PageIndexLists = new List<int>();
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]); 
+                if (!isEvenPage(fileName) && PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "2")
+                {
+
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), CPDFDocument.InitWithFilePath(fileName).PageCount, new char[] { ',' }, new char[] { '-' }, true))
+                {
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]); 
                 datatableindex++;
             }
             PDFDataTable = pdfdatatable;
@@ -377,15 +452,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         /// <summary>
         /// 更新Currentlistview显示
-        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
         /// </summary>
-        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", bool isevenpageisenabled = true, string state = "待完成")
         {
             if (fileNames.Count >= FileNameNumber)
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
                 }
             }
             else
@@ -398,6 +473,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 判断是否关闭偶数页
+        /// document 文档对象 )
+        /// </summary>
+        public bool isEvenPage(string filename)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            document.Release();
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -439,7 +556,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateListview("待确定");
         }
 
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+
+            if (fileNames.Count < 1)
+            {
+                SetHeaderFooterGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
 
+            updateListview("待确定");
+        }
         public void PDFFileCount()
         {
             if (fileNames.Count == 0)
@@ -467,6 +596,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             {
                 fileNames = filepath;
                 PDFFileCount();
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 updateListview("待确定");
                 EnterSelectedContent(TemplateListName);
             }

+ 15 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterTemplateListContentViewModel.cs

@@ -15,6 +15,10 @@ using System.Collections.ObjectModel;
 using System.Linq;
 using System.Windows.Controls;
 using System.Windows;
+using PDF_Office.Model.EditTools.Bates;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
 {
@@ -24,6 +28,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         private CPDFViewer PDFViewer;
         public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
         public BatesHeaderFooterItem HeaderFooterItem = new BatesHeaderFooterItem();
+        private HomePageHeaderFooterDialogViewModel homePageHeaderFooterDialogViewModel;
         public int TemplateIndex = 0;
 
         private ObservableCollection<BatesHeaderFooterItem> headerFooterModCollection = new ObservableCollection<BatesHeaderFooterItem>();
@@ -167,6 +172,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             if (template != null)
             {
                 ConvertItemToInfo(template, ref HeaderFooterInfo);
+                homePageHeaderFooterDialogViewModel.HeaderFooterInfo = HeaderFooterInfo;
+                for (int i = 0; homePageHeaderFooterDialogViewModel.PDFDataTable.Rows.Count > i; i++)
+                {
+                    homePageHeaderFooterDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = HomePageEditHelper.UpDataPageRange(CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[i]).PageCount, HeaderFooterInfo.PageRange);
+                    homePageHeaderFooterDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = HeaderFooterInfo.PageRangeIndex.ToString();
+                    homePageHeaderFooterDialogViewModel.updateListview("待确定");
+                }
             }
 
         }
@@ -193,7 +205,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
             headerFooterInfo.margin = headerFooterItem.margin;
             headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
-            EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
+            headerFooterInfo.PageRange = headerFooterItem.PageRange;
+            //EditToolsHelper.GetPageRange(headerFooterInfo.PageRangeIndex, PDFViewer.Document, ref headerFooterInfo.PageRange, headerFooterItem.PageRange);
         }
         private void CheckTemplateListIsEmpty(List<BatesHeaderFooterItem> headerFooterTemplateList)
         {
@@ -219,6 +232,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<HomePageHeaderFooterDialogViewModel>("ViewModel", out homePageHeaderFooterDialogViewModel);
             InitBackgroundTemplateList();
         }
     }

+ 12 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs

@@ -402,7 +402,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, file_size, state);
                 pdfdatatable.Rows.Add(f.Name, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
                 datatableindex++;
             }
@@ -474,7 +473,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
             updateListview("待确定");
         }
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
 
+            if (fileNames.Count < 1)
+            {
+                SetOptionsRemoveGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
 
         public void PDFFileCount()
         {

+ 14 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs

@@ -487,6 +487,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateListview("待确定");
         }
 
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+
+            if (fileNames.Count < 1)
+            {
+                SetSafetyGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
+
         public void PDFFileCount()
         {
             if (fileNames.Count == 0)

+ 13 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateFileContentViewModel.cs

@@ -20,6 +20,8 @@ using System.IO;
 using System.Linq;
 using System.Windows;
 using System.Threading.Tasks;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.HeaderFooter;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
 {
@@ -230,9 +232,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             get { return _pageRangeText; }
             set
             {
+                
+                List<int> PageIndexLists = new List<int>();
                 _pageRangeText = value;
+                WatermarkInfo.PageRange = PageRangeText;
+                if (PageRangeSelectIndex == 3 && !CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' }))
+                {
+                    WatermarkInfo.PageRangeIndex = 0;
+                }
+                WatermarkInfo.PageRangeIndex = 3;
                 //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
-                
+
             }
         }
 
@@ -403,6 +413,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRange=watermarkItem.pageRange;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
         }

+ 9 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkCreateTextContentViewModel.cs

@@ -370,9 +370,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             get { return _pageRangeText; }
             set
             {
+                List<int> PageIndexLists = new List<int>();
                 _pageRangeText = value;
-                //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, PageRangeText);
-                
+                WatermarkInfo.PageRange = PageRangeText;
+                if (PageRangeSelectIndex == 3 && !CommonHelper.GetPagesInRange(ref PageIndexLists, PageRangeText, 99999, new char[] { ',' }, new char[] { '-' }))
+                {
+                    WatermarkInfo.PageRangeIndex = 0;
+                }
+                WatermarkInfo.PageRangeIndex = 3;
+
             }
         }
 
@@ -474,13 +480,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRange = watermarkItem.pageRange;
                 watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
-
         }
 
-
         public void SaveCurrentTemplate()
         {
             var watermarkItem = new WatermarkItem();

+ 170 - 19
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs

@@ -18,6 +18,8 @@ using ComPDFKitViewer.PdfViewer;
 using Prism.Events;
 using PDF_Office.EventAggregators;
 using PDFSettings;
+using PDF_Office.Model.EditTools.Watermark;
+using ComPDFKit.PDFWatermark;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
 {
@@ -35,6 +37,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer PDFViewer;
 
+        private CPDFWatermark watermark;
+
+        public WatermarkInfo WatermarkInfo;
+
         private CPDFViewer CurrentPDFViewer;
 
         private ViewContentViewModel viewContentViewModel;
@@ -178,6 +184,31 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
             }
         }
+
+        private string createGridSpan = "1";
+        public string CreateGridSpan
+        {
+            get { return createGridSpan; }
+            set
+            {
+                SetProperty(ref createGridSpan, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
+        private Visibility createGridSpanVisibility = Visibility.Visible;
+        public Visibility CreateGridSpanVisibility
+        {
+            get { return createGridSpanVisibility; }
+            set
+            {
+                SetProperty(ref createGridSpanVisibility, value);
+                RaisePropertyChanged();
+
+            }
+        }
+
         #endregion
 
         #region 委托声明
@@ -200,10 +231,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             WatermarkSettingsVisible = Visibility.Visible;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
             PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
             PDFDataTable.Columns.Add("FilePageRangeText");
             PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
+            PDFDataTable.Columns.Add("IsEvenPageIsEnabled");
             PDFDataTable.Columns.Add("FileSize");
             PDFDataTable.Columns.Add("FileState");
             ADDPDFCommand = new DelegateCommand(addpicture);
@@ -223,10 +256,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
             if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
             }
             else
             {
+                CreateGridSpan = "2";
+                CreateGridSpanVisibility = Visibility.Collapsed;
                 EnterSelectedContent(CreateBaseName);
             }
         }
@@ -235,6 +272,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("ViewModel", this);
             if (SelectedContentName == TemplateListName)
             {
                 param.Add("CurrentCreateModName", CurrentCreateMod);
@@ -288,26 +326,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             param.Add("WatermarkItem", watermarkItem);
             watermarkRegion.RequestNavigate(WatermarkSettingsRegionName, CreateBaseName, param);
             WatermarkSettingsVisible = Visibility.Visible;
+            CreateGridSpan = "2";
+            CreateGridSpanVisibility = Visibility.Collapsed;
         }
 
         private void create()
         {
-
+            updateListview("待确定");
             fileNamesIndex = 0;
             WatermarkGridIsEnabled = "False";
             foreach (var filename in fileNames)
             {
-                //FileInfo fileinfo = new FileInfo(filename);
-                //string OutputPath = fileinfo.DirectoryName;
-                //char[] enumerationSeparator = new char[] { ',' };
-                //char[] rangeSeparator = new char[] { '-' };
-                //List<int> PageIndexLists = new List<int>();
-                //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                //if (document == null)
-                //{
-                //    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
-                //    continue;
-                //}
+                FileInfo fileinfo = new FileInfo(filename);
+                string OutputPath = fileinfo.DirectoryName;
+                char[] enumerationSeparator = new char[] { ',' };
+                char[] rangeSeparator = new char[] { '-' };
+                List<int> PageIndexLists = new List<int>();
+                CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+                if (document == null || document.IsEncrypted)
+                {
+                    PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    continue;
+                }
+                CreateWatermark(document);
+                document.WriteToFilePath(filename + "_Watermark.pdf");
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -316,15 +358,55 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //}
 
                 //document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
+                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }
             WatermarkGridIsEnabled = "True";
         }
+
+        public void CreateWatermark(CPDFDocument document)
+        {
+            if (WatermarkInfo != null)
+            {
+                 document.DeleteWatermarks(); 
+
+                if (WatermarkInfo.WatermarkType == C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
+                    watermark.SetText(WatermarkInfo.Text);
+                    watermark.SetFontName(WatermarkInfo.FontName);
+                    watermark.SetFontSize(WatermarkInfo.TextSize);
+                    watermark.SetTextRGBColor(WatermarkInfo.TextColor);
+                }
+                else
+                {
+
+                    watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_IMG);
+                    if (WatermarkInfo.ImageArray != null)
+                    {
+                        watermark.SetImage(WatermarkInfo.ImageArray, WatermarkInfo.ImageWidth, WatermarkInfo.ImageHeight);
+                    }
+                    watermark.SetScale(WatermarkInfo.ImageSize / 100);
+                }
+                watermark.SetRotation((float)((WatermarkInfo.Rotation / 180) * Math.PI));
+                watermark.SetOpacity((byte)(((float)WatermarkInfo.Opacity / 100) * 255));
+                watermark.SetFront(WatermarkInfo.IsFront);
+                watermark.SetVertalign(WatermarkInfo.WatermarkVertalign);
+                watermark.SetHorizalign(WatermarkInfo.WatermarkHorizalign);
+                watermark.SetFullScreen(WatermarkInfo.Isfull);
+                watermark.SetVertOffset(WatermarkInfo.VertOffset);
+                watermark.SetHorizOffset(WatermarkInfo.HorizOffset);
+                watermark.SetHorizontalSpacing(WatermarkInfo.HorizontalSpacing);
+                watermark.SetVerticalSpacing(WatermarkInfo.VerticalSpacing);
+                watermark.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
+                Trace.WriteLine("IsCreateWatermark: " + watermark.CreateWatermark());
+                Trace.WriteLine("IsUpdateWatermark: " + watermark.UpdateWatermark());
+            }
+        }
         #endregion
 
         #region 批量处理逻辑函数
@@ -413,15 +495,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             pdfdatatable.Columns.Add("FileName");
             pdfdatatable.Columns.Add("FilePageRangeText");
             pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
+            pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
             pdfdatatable.Columns.Add("FileSize");
             pdfdatatable.Columns.Add("FileState");
             int datatableindex = 0;
+            List<int> PageIndexLists = new List<int>();
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length) / 1024).ToString() + " K";
-                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
+                if (!isEvenPage(fileName) && PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "2")
+                {
+
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), CPDFDocument.InitWithFilePath(fileName).PageCount, new char[] { ',' }, new char[] { '-' }, true))
+                {
+                    PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
+                }
+                pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
                 datatableindex++;
             }
             PDFDataTable = pdfdatatable;
@@ -431,15 +524,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         /// <summary>
         /// 更新Currentlistview显示
-        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
         /// </summary>
-        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
+        public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", bool isevenpageisenabled = true, string state = "待完成")
         {
             if (fileNames.Count >= FileNameNumber)
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
+                    PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
                 }
             }
             else
@@ -452,6 +545,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             }
         }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            for (int i = 0; fileNames.Count > i; i++)
+            {
+
+                PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
+                PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
+            }
+        }
+        /// <summary>
+        /// 获取文件列表单个文件对应的页码范围
+        /// document 文档对象 pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
+        /// </summary>
+        public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
+        {
+            string filePageRange = "1";
+            EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
+            return filePageRange;
+        }
+
+        /// <summary>
+        /// 判断是否关闭偶数页
+        /// document 文档对象 )
+        /// </summary>
+        public bool isEvenPage(string filename)
+        {
+            CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
+            bool isevenpage = false;
+            if (document.PageCount > 1)
+            {
+                isevenpage = true;
+            }
+            document.Release();
+            return isevenpage;
+        }
+
         /// <summary>
         /// 逆序int类型集合
         /// </summary>
@@ -493,6 +628,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             updateListview("待确定");
         }
 
+        public void removepdffile(int index)
+        {
+            PDFCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+
+            if (fileNames.Count < 1)
+            {
+                SetWatermarkGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
+
+            updateListview("待确定");
+        }
+
 
         public void PDFFileCount()
         {
@@ -520,6 +669,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
             if (filepath != null)
             {
+                CreateGridSpan = "1";
+                CreateGridSpanVisibility = Visibility.Visible;
                 EnterSelectedContent(TemplateListName);
                 fileNames = filepath;
                 PDFFileCount();

+ 5 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListBaseContentViewModel.cs

@@ -2,6 +2,7 @@
 using PDF_Office.CustomControl;
 using PDF_Office.EventAggregators;
 using PDF_Office.Model;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
@@ -20,6 +21,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer CurrentPDFViewer;
 
+        private HomePageWatermarkDialogViewModel homePageWatermarkDialogViewModel;
+
         private string WatermarkTemplateListTextContentName = "HomePageWatermarkTemplateListTextContent";
         private string WatermarkTemplateListFileContentName = "HomePageWatermarkTemplateListFileContent";
 
@@ -106,6 +109,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         {
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, CurrentPDFViewer);
+            param.Add("ViewModel",homePageWatermarkDialogViewModel);
             watermarkTemplateListRegion.RequestNavigate(WatermarkTemplateListRegionName, currentTemplateListName, param);
             eventAggregator.GetEvent<CurrentWatermarkPDFViewerEvent>().Publish(new CPDFViewerUnicode
             {
@@ -141,6 +145,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageWatermarkDialogViewModel>("ViewModel", out homePageWatermarkDialogViewModel);
             if (IsFirstEnter)
             {
                 CurrentTemplateListModName = WatermarkTemplateListTextContentName;

+ 17 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListFileContentViewModel.cs

@@ -4,6 +4,7 @@ using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
 using PDF_Office.EventAggregators;
 using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.EditTools.Watermark;
 using PDF_Office.Properties;
 using PDFSettings;
@@ -29,6 +30,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer CurrentPDFViewer;
 
+        private HomePageWatermarkDialogViewModel homePageWatermarkDialogViewModel;
+
         public WatermarkInfo WatermarkInfo = new WatermarkInfo();
 
         public WatermarkItem WatermarkItem = new WatermarkItem();
@@ -264,6 +267,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRange = watermarkItem.pageRange;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, CurrentPDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
         }
@@ -286,8 +291,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void SendTemplateItemToDocument(WatermarkItem WatermarkItem)
         {
-            ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
-            
+            if (WatermarkItem != null)
+            {
+                ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
+                homePageWatermarkDialogViewModel.WatermarkInfo = WatermarkInfo;
+                for (int i = 0; homePageWatermarkDialogViewModel.PDFDataTable.Rows.Count > i; i++)
+                {
+                    homePageWatermarkDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = HomePageEditHelper.UpDataPageRange(CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[i]).PageCount, WatermarkInfo.PageRange);
+                    homePageWatermarkDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = WatermarkInfo.PageRangeIndex.ToString();
+                    homePageWatermarkDialogViewModel.updateListview("待确定");
+                }
+            }
         }
 
 
@@ -302,6 +316,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageWatermarkDialogViewModel>("ViewModel",out homePageWatermarkDialogViewModel);
             InitWatermarkTemplateList();
         }
     }

+ 21 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkTemplateListTextContentViewModel.cs

@@ -1,9 +1,13 @@
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKit.PDFDocument;
+using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
 using PDF_Office.EventAggregators;
 using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
+using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Model.EditTools.Watermark;
 using PDF_Office.Properties;
+using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
 using PDFSettings;
 using Prism.Commands;
 using Prism.Events;
@@ -24,6 +28,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         private CPDFViewer CurrentPDFViewer;
 
+        private HomePageWatermarkDialogViewModel homePageWatermarkDialogViewModel;
+
         public WatermarkInfo WatermarkInfo = new WatermarkInfo();
 
         public WatermarkItem WatermarkItem = new WatermarkItem();
@@ -237,6 +243,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRange = watermarkItem.pageRange;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 //EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, CurrentPDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
 
@@ -244,8 +252,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void SendTemplateItemToDocument(WatermarkItem WatermarkItem)
         {
-            ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
-            
+            if (WatermarkItem != null) {
+
+                ConvertItemToInfo(WatermarkItem, ref WatermarkInfo);
+                homePageWatermarkDialogViewModel.WatermarkInfo = WatermarkInfo;
+                for (int i = 0; homePageWatermarkDialogViewModel.PDFDataTable.Rows.Count > i; i++)
+                {
+                    homePageWatermarkDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = HomePageEditHelper.UpDataPageRange(CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[i]).PageCount, WatermarkInfo.PageRange);
+                    homePageWatermarkDialogViewModel.PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = WatermarkInfo.PageRangeIndex.ToString();
+                    homePageWatermarkDialogViewModel.updateListview("待确定");
+                }
+            }
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -259,6 +276,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<HomePageWatermarkDialogViewModel>("ViewModel", out homePageWatermarkDialogViewModel);
             InitWatermarkTemplateList();
         }
     }

+ 74 - 11
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialogViewModel.cs

@@ -25,6 +25,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         private List<string> fileNames;
 
         private int fileNamesIndex = 0;
+        private int FileNameNumber = 0;
 
         public List<int> fileNamesView = new List<int>();
 
@@ -65,6 +66,17 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 SetProperty(ref imagesDataTable, value);
             }
         }
+
+        private DataTable imagesCurrentDataTable = new DataTable();
+        public DataTable ImagesCurrentDataTable
+        {
+            get { return imagesCurrentDataTable; }
+            set
+            {
+                SetProperty(ref imagesCurrentDataTable, value);
+            }
+        }
+
         private string removeIsEnable = "False";
         public string RemoveIsEnable
         {
@@ -119,6 +131,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             ADDPictureFilesCommand = new DelegateCommand(addpicturefiles);
             RemovePictureFileCommand = new DelegateCommand(removepicturefile);
             SelectFileCommand = new DelegateCommand(selectFile);
+            ImagesDataTable.Columns.Add("FileName");
+            ImagesDataTable.Columns.Add("FileSize");
+            ImagesDataTable.Columns.Add("FileState");
+            ImagesCurrentDataTable.Columns.Add("FileState");
 
         }
         #region 逻辑函数
@@ -161,7 +177,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                         continue;
                     }
                     FileInfo fileinfo = new FileInfo(filename);
-                    JpegInsertPage(ref topdfdoc, filename, fileinfo,img.Width, img.Height);
+                    JpegInsertPage(ref topdfdoc, filename, fileinfo,img.Width, img.Height, pageindex);
                     pageindex++;
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
@@ -209,7 +225,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 System.Diagnostics.Process.Start("Explorer", "/select," + topdfdoc.FilePath);
                 topdfdoc.Release();
             }
-            RequestClose.Invoke(new DialogResult(ButtonResult.OK));
+            PictureToPDFGridIsEnabled = "True";
+            fileNamesIndex=0;
         }
 
         /// <summary>
@@ -243,6 +260,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         /// </summary>
         private void addpicture()
         {
+            FileNameNumber = fileNames.Count;
             System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
             dlg.Multiselect = true;
             dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*.bmp;*.gif;*tiff;";
@@ -255,12 +273,21 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 updateListview("待确定");
             }
         }
-
+        public void addPicture(string filename)
+        {
+            FileNameNumber = fileNames.Count;
+            fileNames.Add(filename);
+            RemoveExcess(ref fileNames);
+            SetPictureToPDFGridIsEnabled = "True";
+            AddFileVisibility = Visibility.Collapsed;
+            updateListview("待确定");
+        }
         /// <summary>
         /// 添加图片文件夹
         /// </summary>
         private void addpicturefiles()
         {
+            FileNameNumber = fileNames.Count;
             FolderBrowserDialog dialog = new FolderBrowserDialog();
             dialog.Description = "请选择文件路径";
             if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
@@ -287,6 +314,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         /// 删除图片文件
         /// </summary>
         public void removepicturefile() {
+            FileNameNumber = fileNames.Count;
             Reverseorder(ref fileNamesView);
             foreach (int filenamesview in fileNamesView)
             {
@@ -300,12 +328,24 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             }
             updateListview("待确定");
         }
+        public void removepdffile(int index)
+        {
+            ImagesCurrentDataTable.Rows.RemoveAt(index);
+            fileNames.Remove(fileNames[index]);
+
+            if (fileNames.Count < 1)
+            {
+                SetPictureToPDFGridIsEnabled = "False";
+                AddFileVisibility = Visibility.Visible;
+            }
 
+            updateListview("待确定");
+        }
 
-            /// <summary>
-            /// 打开文件图片
-            /// </summary>
-            public void openfiledialog(){
+        /// <summary>
+        /// 打开文件图片
+        /// </summary>
+        public void openfiledialog(){
 
             foreach (int filenamesview in fileNamesView)
             {
@@ -343,19 +383,44 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         /// state 状态显示字符串
         /// </summary>
         public void updateListview( string state) {
+            updateCurrentListview();
             DataTable imagesdatatable = new DataTable();
             imagesdatatable.Columns.Add("FileName");
             imagesdatatable.Columns.Add("FileSize");
             imagesdatatable.Columns.Add("FileState");
+            int datatableindex = 0;
             foreach (var fileName in fileNames)
             {
                 string file_all = fileName;
                 FileInfo f = new FileInfo(file_all);
                 string file_size = (((float)f.Length)/1024).ToString()+" K";
-                imagesdatatable.Rows.Add(f.Name, file_size, state);
+                imagesdatatable.Rows.Add(f.Name, file_size, ImagesCurrentDataTable.Rows[datatableindex]["FileState"]);
+                datatableindex++;
             }
             ImagesDataTable = imagesdatatable;
+        }
 
+        /// <summary>
+        /// 更新Currentlistview显示
+        /// pagerangetext 自定义页面范围字符串  pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
+        /// </summary>
+        public void updateCurrentListview( string state = "待完成")
+        {
+            if (fileNames.Count >= FileNameNumber)
+            {
+                for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
+                {
+                    ImagesCurrentDataTable.Rows.Add( state);
+                }
+            }
+            else
+            {
+                Reverseorder(ref fileNamesView);
+                foreach (int filenamesview in fileNamesView)
+                {
+                    ImagesCurrentDataTable.Rows.RemoveAt(filenamesview);
+                }
+            }
         }
         #endregion
 
@@ -468,9 +533,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             if (filepath!=null)
             {
                 fileNames=filepath.ToList();
-                ImagesDataTable.Columns.Add("FileName");
-                ImagesDataTable.Columns.Add("FileSize");
-                ImagesDataTable.Columns.Add("FileState");
+                
                 updateListview("待确定");
             }
         }

+ 332 - 138
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDialogViewModel.cs

@@ -31,10 +31,12 @@ using System.Text.RegularExpressions;
 using System.Diagnostics;
 using PDF_Office.EventAggregators;
 using System.Collections.ObjectModel;
+using System.Windows.Forms;
+using ComboBox = System.Windows.Controls.ComboBox;
+using CheckBox = System.Windows.Controls.CheckBox;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
-
     public class HomePagePrinterDialogViewModel : BindableBase, IDialogAware
     {
         public IRegionManager printRegion;
@@ -109,6 +111,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set => SetProperty(ref _maxCopiesNumber, value);
         }
 
+        private Visibility _printPageBorderVisibility = Visibility.Collapsed;
+        public Visibility PrintPageBorderVisibility
+        {
+            get => _printPageBorderVisibility;
+            set => SetProperty(ref _printPageBorderVisibility, value);
+        }
+
         /// <summary>
         /// 打印机支持的颜色
         /// </summary>
@@ -172,16 +181,13 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set => _isBothSides = value;
         }
 
-        public enum EnumBothSidesStage
-        {
-            StatusFrontSide,
-            StatusBackSide
-        }
+        public int printCurrentPageIndex;
+        public bool isCurrentPage;
 
         /// <summary>
         /// 双面打印阶段:正面或背面
         /// </summary>
-        public EnumBothSidesStage BothSidesStage;
+        public EnumBothSidesStage BothSidesStage = EnumBothSidesStage.StatusNone;
 
         #endregion
 
@@ -257,12 +263,37 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             SetReversePageCommand = new DelegateCommand<object>(SetReversePage);
             SetPrintBorderCommand = new DelegateCommand<object>(SetPrintBorder);
             SetPrintOritationCommand = new DelegateCommand<object>(SetPrintOritation);
-           Unicode = Guid.NewGuid().ToString();
+            Unicode = Guid.NewGuid().ToString();
             InitComponent();
             InitDictionary();
             InitParams();
-
+            PageSetupDialog pageSetupDialog = new PageSetupDialog();
+            PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape = false;
+            pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+            if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
+            {
+                PrintOrientationIndex = 0;
+            }
+            else
+            {
+                PrintOrientationIndex = 1;
+            }
             printEvent.GetEvent<SendPrintSettingsModInfoEvent>().Subscribe(RecvPrintSettingsModInfo, e => e.Unicode == Unicode);
+            printEvent.GetEvent<SendDuplexPrintModEvent>().Subscribe(RecvDuplexPrintMod, e => e.Unicode == Unicode);
+
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+            if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
+            {
+                PrintOrientationIndex = 0;
+            }
+            else
+            {
+                PrintOrientationIndex = 1;
+            }
+            this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
         }
 
         private void InitComponent()
@@ -281,29 +312,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
             List<PageMediaSize> PageMediaSizeList = new List<PageMediaSize>();
-            foreach (PageMediaSize size in printQueue.GetPrintCapabilities().PageMediaSizeCapability)
-            {
-                if (size == null || size.PageMediaSizeName == null)
-                {
-                    continue;
-                }
-                if (size.PageMediaSizeName == PageMediaSizeName.ISOA4)
-                {
-                    PrintSettingsInfo.PageMediaSize = size;
-                }
-                PageMediaSizeList.Add(size);
-            }
-            if (PrintSettingsInfo.PageMediaSize == null)
-            {
-                PrintSettingsInfo.PageMediaSize = PageMediaSizeList[0];
-            }
+
         }
 
         private void InitPrinterNameList()
         {
             PrinterNameList = new List<string>();
-            PrintDocument printDocument = new PrintDocument();
-            string defaultPrinterName = printDocument.PrinterSettings.PrinterName;
             foreach (string printerListItem in PrinterSettings.InstalledPrinters)
             {
                 PrinterNameList.Add(printerListItem);
@@ -346,43 +360,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             GetPrintModNameFromRadioButton.Add("ModBookletRdo", HomePagePrinterModBookletName);
         }
 
-        public void AutoOritation()
-        {
-            //纸张长边为高
-            //if (PrintSettingsInfo.PageMediaSize.Height / PrintSettingsInfo.PageMediaSize.Width >= 1)
-            //{
-            //    //PDF长边为高
-            //    if (PDFViewer.Document.GetPageSize(0).Height / PDFViewer.Document.GetPageSize(0).Width >= 1)
-            //    {
-            //        PrintSettingsInfo.EnumPrintOrientation = EnumPrintOrientation.StatusPortrait;
-            //    }
-            //    //PDF长边为宽
-            //    else
-            //    {
-            //        PrintSettingsInfo.EnumPrintOrientation = EnumPrintOrientation.StatusLandscape;
-            //    }
-            //}
-            ////纸张短边为高
-            //else
-            //{
-            //    //PDF长边为高
-            //    if (PDFViewer.Document.GetPageSize(0).Height / PDFViewer.Document.GetPageSize(0).Width >= 1)
-            //    {
-            //        PrintSettingsInfo.EnumPrintOrientation = EnumPrintOrientation.StatusLandscape;
-            //    }
-            //    //PDF长边为宽
-            //    else
-            //    {
-            //        PrintSettingsInfo.EnumPrintOrientation = EnumPrintOrientation.StatusPortrait;
-            //    }
-            //}
-            //PrintOrientationIndex = (int)PrintSettingsInfo.EnumPrintOrientation;
-        }
-
-        public void InitParamsByPDFView()
-        {
-            AutoOritation();
-        }
         /// <summary>
         /// 选择打印机
         /// </summary>
@@ -398,32 +375,61 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         /// </summary>
         public void SetPaper()
         {
-            printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
-            LoadPrinterSettings();
-            DialogParameters value = new DialogParameters();
-            value.Add("Unicode", Unicode);
-            value.Add(ParameterNames.PrintQueue, printQueue);
-            printDialogs.ShowDialog(DialogNames.HomePagePrinterPaperSettingsDialog, value, e =>
+            if (true)
             {
-                if (e.Result == ButtonResult.OK)
+                PageSetupDialog pageSetupDialog = new PageSetupDialog();
+                PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
+                pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
+                if (pageSetupDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
-                    PrintSettingsInfo.PageMediaSize = e.Parameters.GetValue<PageMediaSize>("PageMediaSize");
-                    PrintSettingsInfo.Margin.Clear();
-                    PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginLeft"));
-                    PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginTop"));
-                    PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginRight"));
-                    PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginBottom"));
-                    AutoOritation();
-                    this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
-   
+                    PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+                    if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
+                    {
+                        PrintOrientationIndex = 0;
+                    }
+                    else
+                    {
+                        PrintOrientationIndex = 1;
+                    }
+                    this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode }); ;
                 }
-            });
+            }
+            else
+            {
+                printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
+                LoadPrinterSettings();
+                DialogParameters value = new DialogParameters();
+                value.Add("Unicode", Unicode);
+                value.Add(ParameterNames.PrintQueue, printQueue);
+                printDialogs.ShowDialog(DialogNames.HomePagePrinterPaperSettingsDialog, value, e =>
+                {
+                    if (e.Result == ButtonResult.OK)
+                    {
+                        PrintSettingsInfo.PageMediaSize = e.Parameters.GetValue<PageMediaSize>("PageMediaSize");
+                        PrintSettingsInfo.Margin.Clear();
+                        PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginLeft"));
+                        PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginTop"));
+                        PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginRight"));
+                        PrintSettingsInfo.Margin.Add(e.Parameters.GetValue<int>("MarginBottom"));
+                        this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
+                    }
+                });
+            }
+
         }
 
         public void ChangePrintMod(object e)
         {
-            var rdo = e as RadioButton;
+            var rdo = e as System.Windows.Controls.RadioButton;
             CurrentHomePagePrinterModName = GetPrintModNameFromRadioButton[rdo.Name];
+            if (CurrentHomePagePrinterModName == "HomePagePrinterModMultipleContent" || CurrentHomePagePrinterModName == "HomePagePrinterModBookletContent")
+            {
+                PrintPageBorderVisibility = Visibility.Visible;
+            }
+            else
+            {
+                PrintPageBorderVisibility = Visibility.Collapsed;
+            }
             NavigationParameters param = new NavigationParameters();
             param.Add("document", PDFViewer.Document);
             param.Add("Unicode", Unicode);
@@ -469,7 +475,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                 PrintSettingsInfo.IsGrayscale = false;
             }
             this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
-
         }
 
         /// <summary>
@@ -495,50 +500,106 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             var cmb = e as WritableComboBox;
             PrintSettingsInfo.PageRangeList.Clear();
-            PrintSettingsInfo.EnumPageRange = (EnumPageRange)int.Parse(cmb.SelectedIndex);
             if (int.Parse(cmb.SelectedIndex) < cmb.Items.Count - 1)
             {
-                PrintSettingsInfo.EnumPageRange = (EnumPageRange)int.Parse(cmb.SelectedIndex);
-                if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusAllRange)
+                if (!isCurrentPage)
                 {
-                    for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                    PrintSettingsInfo.EnumPageRange = int.Parse(cmb.SelectedIndex);
+                    if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusAllRange)
                     {
-                        PrintSettingsInfo.PageRangeList.Add(temp);
+                        for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                        {
+                            PrintSettingsInfo.PageRangeList.Add(temp);
+                        }
                     }
-                }
-                else if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusOddRange)
-                {
-                    for (int temp = 0; temp < PDFViewer.Document.PageCount; temp += 2)
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusOddRange)
+                    {
+                        for (int temp = 0; temp < PDFViewer.Document.PageCount; temp += 2)
+                        {
+                            PrintSettingsInfo.PageRangeList.Add(temp);
+                        }
+                    }
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusEvenRange)
                     {
-                        PrintSettingsInfo.PageRangeList.Add(temp);
+                        //TODO: 偶数页页数不够异常
+                        if (PDFViewer.Document.PageCount <= 1)
+                        {
+                            for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
+                        else
+                        {
+                            for (int temp = 1; temp < PDFViewer.Document.PageCount; temp += 2)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
                     }
                 }
-                else if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusEvenRange)
+                else
                 {
-                    //TODO: 偶数页页数不够异常
-                    if (PDFViewer.Document.PageCount <= 1)
+                    PrintSettingsInfo.EnumPageRange = int.Parse(cmb.SelectedIndex);
+                    if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusAllRange)
                     {
                         for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
                         {
                             PrintSettingsInfo.PageRangeList.Add(temp);
                         }
                     }
-                    else
+
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusCurrentPage)
                     {
-                        for (int temp = 1; temp < PDFViewer.Document.PageCount; temp += 2)
+                        PrintSettingsInfo.PageRangeList.Add(printCurrentPageIndex);
+                    }
+
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusOddRange)
+                    {
+                        for (int temp = 0; temp < PDFViewer.Document.PageCount; temp += 2)
                         {
                             PrintSettingsInfo.PageRangeList.Add(temp);
                         }
                     }
+                    else if (PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithCurrentPage.StatusEvenRange)
+                    {
+                        //TODO: 偶数页页数不够异常
+                        if (PDFViewer.Document.PageCount <= 1)
+                        {
+                            for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
+                        else
+                        {
+                            for (int temp = 1; temp < PDFViewer.Document.PageCount; temp += 2)
+                            {
+                                PrintSettingsInfo.PageRangeList.Add(temp);
+                            }
+                        }
+                    }
                 }
+
                 this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
+            }
+            else
+            {
+                if (!isCurrentPage)
+                {
+                    PrintSettingsInfo.EnumPageRange = (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange;
+                }
+                else
+                {
+                    PrintSettingsInfo.EnumPageRange = (int)EnumPageRangeWithCurrentPage.StatusCustomizedRange;
 
+                }
             }
         }
 
         public void SetCustomPageRange(object e)
         {
-            if (PrintSettingsInfo.EnumPageRange == EnumPageRange.StatusCustomizedRange)
+            if ((PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange&&!isCurrentPage)||(PrintSettingsInfo.EnumPageRange == (int)EnumPageRangeWithoutCurrentPage.StatusCustomizedRange && isCurrentPage))
             {
                 var cmb = e as WritableComboBox;
                 if (cmb == null)
@@ -551,17 +612,25 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
                     MessageBoxEx.Show("输入不对");
                     return;
                 }
-                PrintSettingsInfo.PageRangeList.Clear();
                 PrintSettingsInfo.PageRangeList = DocumentTargetPages;
+                this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
             }
         }
 
         public void SetPrintOritation(object e)
         {
             var cmb = e as ComboBox;
+            if ((EnumPrintOrientation)cmb.SelectedIndex == EnumPrintOrientation.StatusPortrait)
+            {
+                PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape = false;
+            }
+            else
+            {
+                PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape = true;
+            }
+
             PrintSettingsInfo.EnumPrintOrientation = (EnumPrintOrientation)cmb.SelectedIndex;
             this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
-
         }
 
         public void SetPrintContent(object e)
@@ -615,15 +684,19 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         {
             if (printModInfoWithUnicode.printModInfo.EnumPrintMod == currentHomePagePrinterMod)
             {
-                PrintSettingsInfo.printModInfo = printModInfoWithUnicode.printModInfo;
+                PrintSettingsInfo.PrintModInfo = printModInfoWithUnicode.printModInfo;
                 this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode });
             }
         }
 
+        public void RecvDuplexPrintMod(EnumDuplexPrintModWithUnicode enumDuplexPrintModWithUnicode)
+        {
+            PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod = enumDuplexPrintModWithUnicode.enumDuplexPrintMod;
+        }
         #endregion
         public void Cancel()
         {
-            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
+            RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
         }
 
         public void NavigateDocumentRegion()
@@ -633,6 +706,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             param.Add(ParameterNames.PrintSettingsInfo, PrintSettingsInfo);
             param.Add("Unicode", Unicode);
             printRegion.RequestNavigate(HomePagePrinterDocumentRegionName, HomePagePrinterDocumentName, param);
+            PageSetupDialog pageSetupDialog = new PageSetupDialog();
+            PrintSettingsInfo.PrintDocument.PrinterSettings.PrinterName = PrinterName;
+            pageSetupDialog.Document = PrintSettingsInfo.PrintDocument;
+
+            PrintSettingsInfo.PrintDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
+            if (!PrintSettingsInfo.PrintDocument.DefaultPageSettings.Landscape)
+            {
+                PrintOrientationIndex = 0;
+            }
+            else
+            {
+                PrintOrientationIndex = 1;
+            }
+            this.printEvent.GetEvent<SendPrintSettingsInfoEvent>().Publish(new PrintSettingsInfoWithUnicode { printSettingsInfo = this.PrintSettingsInfo, Unicode = this.Unicode }); 
         }
 
         public void NavigateModRegion()
@@ -640,35 +727,142 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add("Unicode", Unicode);
-            printRegion.RequestNavigate(HomePagePrinterModRegionName, HomePagePrinterModSizeName);
+            printRegion.RequestNavigate(HomePagePrinterModRegionName, HomePagePrinterModSizeName, param);
+        }
+
+        public bool IsBookletSinglePage(PrintModInfo printModInfo)
+        {
+            if (printModInfo.EnumPrintMod == EnumPrintMod.StatusBooklet)
+            {
+                var bookletInfo = (BookletInfo)printModInfo;
+                if (!(bookletInfo.EnumBookletSubset == EnumBookletSubset.StatusBothSides))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public bool IsBookletBothPage(PrintModInfo printModInfo)
+        {
+            if (printModInfo.EnumPrintMod == EnumPrintMod.StatusBooklet)
+            {
+                var bookletInfo = (BookletInfo)printModInfo;
+                if (bookletInfo.EnumBookletSubset == EnumBookletSubset.StatusBothSides)
+                {
+                    return true;
+                }
+            }
+            return false;
         }
 
         /// <summary>
-        /// 确认打印,单面或手动双面
+        /// 确认打印,单面,双面或手动双面
+        /// 大小模式支持单面,双面
+        /// 海报模式只支持单面
+        /// 多页模式支持单面,双面
+        /// 小册子模式双面打印:双面
+        /// 仅正面/背面:单面
+        /// 
+        /// 单面打印:正常传参
+        /// 
+        /// 双面打印:
+        /// 长边翻页,短边翻页
+        /// 
+        /// 自动双面打印
+        /// 传值给打印机就行
+        /// 
+        /// 手动双面打印
+        /// 长边翻页 先打印奇数页,进入二阶段,正向打印偶数页
+        /// 短边翻页 先打印奇数页,进入二阶段,反向打印偶数页
+        /// 
+        /// 异常退出是否要挂起打印机线程?
+        /// 
         /// </summary>
         public void ConfirmPrint()
         {
+
             printQueue = localDefaultPrintServer.GetPrintQueue(PrinterName);
             LoadPrinterSettings();
-            this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode {printQueue= this.printQueue ,Unicode = this.Unicode});
-            //Collection<Duplexing> list = new Collection<Duplexing>();
-
-            //if (printQueue.GetPrintCapabilities().DuplexingCapability.Count > 0)
-            //{
-            //    list.Clear();
-            //    for (int temp = 0; temp < printQueue.GetPrintCapabilities().DuplexingCapability.Count; temp++)
-            //    {
-            //        list.Add(printQueue.GetPrintCapabilities().DuplexingCapability[temp]);
-            //    }
-            //}
-            //if (!IsBothSides)
-            //{
-            //    RequestClose.Invoke(new DialogResult(ButtonResult.OK));
-            //}
-            //else if (IsBothSides)
-            //{
-            //    MessageBoxEx.Show("翻页");
-            //}
+
+
+            Collection<Duplexing> list = new Collection<Duplexing>();
+
+            if (printQueue.GetPrintCapabilities().DuplexingCapability.Count > 0)
+            {
+                list.Clear();
+                for (int temp = 0; temp < printQueue.GetPrintCapabilities().DuplexingCapability.Count; temp++)
+                {
+                    list.Add(printQueue.GetPrintCapabilities().DuplexingCapability[temp]);
+                }
+            }
+
+            ///单面打印的情况:直接执行
+            if (PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusNone && !IsBookletBothPage(PrintSettingsInfo.PrintModInfo))
+            {
+                this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
+            }
+            else if (IsBookletSinglePage(PrintSettingsInfo.PrintModInfo))
+            {
+                this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
+            }
+            ///双面打印的情况
+            else if ((int)PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod > 0 || IsBookletBothPage(PrintSettingsInfo.PrintModInfo))
+            {
+                ///支持自动双面
+                if (list.Count > 0)
+                {
+                    this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
+                    RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                }
+                ///手动翻面
+                ///手动翻面需要注意只有一页时和单面打印一致
+                ///那奇数页呢?
+                else
+                {
+                    if ((PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusSize && PrintSettingsInfo.PageRangeList.Count == 1) || (PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusBooklet && PrintSettingsInfo.PageRangeList.Count == 1))
+                    {
+                        this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
+                        RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                    }
+                    else if (PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusMultiple)
+                    {
+                        var multipleInfo = (MultipleInfo)PrintSettingsInfo.PrintModInfo;
+                        if (PrintSettingsInfo.PageRangeList.Count / (multipleInfo.HorizontalPageNumber * multipleInfo.VerticalPageNumber) == 0)
+                        {
+                            this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusNone, Unicode = this.Unicode });
+                            RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                        }
+                        else
+                        {
+                            ///z
+                            this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusFrontSide, Unicode = this.Unicode });
+                            if (MessageBoxEx.Show("Printing on the front side of the paper is complete. Please reverse the paper, click 'OK' to print the reverse side", "", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
+                            {
+                                this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusBackSide, Unicode = this.Unicode });
+                                RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                            }
+                            else
+                            {
+                                RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
+                            }
+                        }
+                    }
+                    else
+                    {
+                        this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusFrontSide, Unicode = this.Unicode });
+                        if (MessageBoxEx.Show("Printing on the front side of the paper is complete. Please reverse the paper, click 'OK' to print the reverse side", "", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
+                        {
+                            this.printEvent.GetEvent<SendPrintQueueEvent>().Publish(new PrintQueueWithUnicode { printQueue = this.printQueue, EnumBothSidesStage = EnumBothSidesStage.StatusBackSide, Unicode = this.Unicode });
+                            RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK));
+                        }
+                        else
+                        {
+                            RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
+                        }
+                    }
+                }
+            }
         }
 
         public event Action<IDialogResult> RequestClose;
@@ -686,23 +880,23 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         public void OnDialogOpened(IDialogParameters parameters)
         {
             parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if (PDFViewer != null)
+            if (PDFViewer != null && PDFViewer.Document != null)
             {
-                //文件损坏导致无法读取
-                try
+                for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
                 {
-                    for (int temp = 0; temp < PDFViewer.Document.PageCount; temp++)
-                    {
-                        PrintSettingsInfo.PageRangeList.Add(temp);
-                    }
-                    NavigationParameters param = new NavigationParameters();
-                    NavigateDocumentRegion();
-                    NavigateModRegion();
-                    InitParamsByPDFView();
-                }catch
+                    PrintSettingsInfo.PageRangeList.Add(temp);
+                }
+                if (parameters.TryGetValue<int>(ParameterNames.PrintCurrentPage, out printCurrentPageIndex))
+                {
+                    isCurrentPage = true;
+                }
+                else
                 {
-                    PDFViewer = null;
-                } 
+                    isCurrentPage = false;
+                }
+                NavigationParameters param = new NavigationParameters();
+                NavigateDocumentRegion();
+                NavigateModRegion();
             }
         }
     }

File diff suppressed because it is too large
+ 921 - 251
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterDocumentContentViewModel.cs


+ 8 - 0
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModBookletContentViewModel.cs

@@ -124,6 +124,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
         }
 
         public DelegateCommand<object> SetSheetCommand { get; set; }
+        public DelegateCommand SetAutoRotateCommand { get; set; }
 
         public HomePagePrinterModBookletContentViewModel(IEventAggregator eventAggregator)
         {
@@ -138,6 +139,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             BookletInfo.EnumPrintMod = EnumPrintMod.StatusBooklet;
 
             SetSheetCommand = new DelegateCommand<object>(SetSheet);
+            SetAutoRotateCommand = new DelegateCommand(SetAutoRotate);
         }
 
         private void InitSubsetList()
@@ -205,6 +207,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             } 
         }
 
+        public void SetAutoRotate()
+        {
+            BookletInfo.IsAutoRotate = IsAutoRotate;
+            SendBookletInfo();
+        }
+
         public void SendBookletInfo()
         {
             if (BookletInfo != null)

+ 61 - 7
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModMultipleContentViewModel.cs

@@ -7,6 +7,7 @@ using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 {
@@ -115,10 +116,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _multipleInfo = value; }
         }
 
+        private bool _isDuplexModLongEdge = true;
+        public bool IsDuplexModLongEdge
+        {
+            get { return _isDuplexModLongEdge; }
+            set { _isDuplexModLongEdge = value; }
+        }
+
+        private bool _isDuplexModShortEdge = false;
+        public bool IsDuplexModShortEdge
+        {
+            get { return _isDuplexModShortEdge; }
+            set { _isDuplexModShortEdge = value; }
+        }
+
         public DelegateCommand<object> SetPageMatrixCommand { get; set; }
         public DelegateCommand<object> SetCustomMatrixCommand { get; set; }
         public DelegateCommand SetPageOrderCommand { get; set; }
-        public DelegateCommand<object> SetAutoRotateCommand { get; set; }
+        public DelegateCommand SetAutoRotateCommand { get; set; }
+        public DelegateCommand<object> UnlockDuplexCommand { get; set; }
+        public DelegateCommand<object> ChangeDuplexModCommand { get; set; }
 
         public HomePagePrinterModMultipleContentViewModel(IEventAggregator eventAggregator)
         {
@@ -134,8 +151,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             SetPageMatrixCommand = new DelegateCommand<object>(SetPageMatrix);
             SetCustomMatrixCommand = new DelegateCommand<object>(SetCustomMatrix);
             SetPageOrderCommand = new DelegateCommand(SetPageOrder);
-            SetAutoRotateCommand = new DelegateCommand<object>(SetAutoRotate);
-
+            SetAutoRotateCommand = new DelegateCommand(SetAutoRotate);
+            UnlockDuplexCommand = new DelegateCommand<object>(UnlockDuplex);
+            ChangeDuplexModCommand = new DelegateCommand<object>(ChangeDuplexMod);
             MultipleInfo = new MultipleInfo();
             MultipleInfo.EnumPrintMod = EnumPrintMod.StatusMultiple;
         }
@@ -158,7 +176,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             SendMultipleInfo();
         }
 
-        public void SetAutoRotate(object e)
+        public void SetAutoRotate()
         {
             SetMultipleInfo();
             SendMultipleInfo();
@@ -172,6 +190,44 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
             }
         }
+        public void UnlockDuplex(object e)
+        {
+            var chk = e as CheckBox;
+            if (chk != null)
+            {
+                if (chk.IsChecked == false)
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusNone, Unicode = this.Unicode });
+                }
+                else
+                {
+                    if (IsDuplexModLongEdge)
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                    }
+                    else
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                    }
+                }
+            }
+        }
+
+        public void ChangeDuplexMod(object e)
+        {
+            var rdo = e as RadioButton;
+            if (rdo != null)
+            {
+                if (rdo.Name == "DuplexModLongEdgeRdo")
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                }
+                else
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                }
+            }
+        }
 
         private void InitPageMatrixList()
         {
@@ -245,9 +301,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
 
                     break;
             }
-        }
-
-
+        } 
 
         private void SetMultipleInfo()
         {

+ 12 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModPosterContentViewModel.cs

@@ -33,6 +33,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _defaultLabel = value; }
         }
 
+        private string _labelString;
+        public string LabelString
+        {
+            get { return _labelString; }
+            set { 
+                _labelString = value;
+                eventAggregator.GetEvent<SendLabelEvent>().Publish(new LabelWithUnicode { Label = this.LabelString, Unicode = this.Unicode});
+            }
+        }
+
         public Visibility PageRangeSettingVisibility
         {
             get => _pageRangeSettingVisibility;
@@ -126,11 +136,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             {
                 if (value > 5.08)
                 {
-                    value = 5.08;
+                    SetProperty(ref _overlapNumber, 5.08);
                 }
                 else if (value < 0)
                 {
-                    value = 0;
+                    SetProperty(ref _overlapNumber, 0);
                 }
                 SetProperty(ref _overlapNumber, value);
             }

+ 60 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePrinter/HomePagePrinterModSizeContentViewModel.cs

@@ -32,11 +32,26 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             set { _sizeInfo = value; }
         }
 
-        public DelegateCommand<object> SetModSizeStatusCommand { get; set; }
+        private bool _isDuplexModLongEdge = true;
+        public bool IsDuplexModLongEdge
+        {
+            get { return _isDuplexModLongEdge;}
+            set { _isDuplexModLongEdge = value; }
+        }
+
+        private bool _isDuplexModShortEdge = false;
+        public bool IsDuplexModShortEdge
+        {
+            get { return _isDuplexModShortEdge;}
+            set { _isDuplexModShortEdge = value;}
+        }
+
+    public DelegateCommand<object> SetModSizeStatusCommand { get; set; }
         public DelegateCommand SetDisplayRatioCommand { get; set; }
+        public DelegateCommand<object> UnlockDuplexCommand { get; set; }
+        public DelegateCommand<object> ChangeDuplexModCommand { get; set; }
 
-        //public DelegateCommand sendSizeInfoCommand;
-        //public DelegateCommand SendSizeInfoCommand => this.SendSizeInfoCommand ?? (this.sendSizeInfoCommand = new DelegateCommand(() => this.eventAggregator.GetEvent<ModInfoSendEvent>().Publish(PrintMod)));
+ 
 
         public DelegateCommand SendSizeInfoCommand { get; set; }
 
@@ -45,9 +60,50 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
             this.eventAggregator = eventAggregator;
             SizeInfo = new SizeInfo();
             SizeInfo.EnumPrintMod = EnumPrintMod.StatusSize;
-            SetModSizeStatusCommand = new DelegateCommand<object>(SetModSizeStatus);
 
+            SetModSizeStatusCommand = new DelegateCommand<object>(SetModSizeStatus);
             SetDisplayRatioCommand = new DelegateCommand(SetDisplayRatio);
+            UnlockDuplexCommand = new DelegateCommand<object>(UnlockDuplex);   
+            ChangeDuplexModCommand = new DelegateCommand<object>(ChangeDuplexMod);
+        }
+
+        public void UnlockDuplex(object e)
+        {
+            var chk = e as CheckBox;
+            if (chk != null)
+            {
+                if (chk.IsChecked == false)
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusNone, Unicode = this.Unicode });
+                }
+                else
+                {
+                    if (IsDuplexModLongEdge)
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                    }
+                    else
+                    {
+                        this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                    }
+                }
+            }
+        }
+
+        public void ChangeDuplexMod(object e)
+        {
+            var rdo = e as RadioButton;
+            if (rdo != null)
+            {
+                if (rdo.Name == "DuplexModLongEdgeRdo")
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
+                }
+                else
+                {
+                    this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
+                }
+            }
         }
 
         public void SendSizeInfo()

+ 2 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageSplitDialogViewModel.cs

@@ -101,6 +101,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             get { return filePathName; }
             set
             {
+                value = value+".pdf";
                 SetProperty(ref filePathName, value);
             }
         }
@@ -521,7 +522,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             currentViewer = viewer;
             document = viewer.Document;
             savefilename = currentViewer.Document.FileName;
-            FilePathName = savefilename + "-" + "part" + ".pdf";
+            FilePathName = savefilename + "-" + "part" ;
             savefilepath = filepath.Replace(savefilename + ".pdf", "");
         }
     }

+ 223 - 3
PDF Office/ViewModels/Dialog/Redaction/MarkSettingDialogViewModel.cs

@@ -1,4 +1,7 @@
-using Prism.Commands;
+using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.Model;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
@@ -6,6 +9,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.Dialog.Redaction
 {
@@ -15,16 +20,190 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public event Action<IDialogResult> RequestClose;
 
+        private RedactionAnnotArgs annotArgs;
         public DelegateCommand OkCommand { get; set; }
 
         public DelegateCommand CancelCommand { get; set; }
 
+        public DelegateCommand<string> AlignCommand { get; set; }
+
+
+        private Color lineColor;
+
+        public Color LineColor
+        {
+            get { return lineColor; }
+            set
+            {
+                SetProperty(ref lineColor, value);
+            }
+        }
+
+        private Color bgColor;
+
+        public Color BgColor
+        {
+            get { return bgColor; }
+            set
+            {
+                SetProperty(ref bgColor, value);
+            }
+        }
+
+        private Color fontColor;
+
+        public Color FontColor
+        {
+            get { return fontColor; }
+            set
+            {
+                SetProperty(ref fontColor, value);
+            }
+        }
+
+
+        private bool isUserText;
+
+        public bool IsUseText
+        {
+            get { return isUserText; }
+            set
+            {
+                SetProperty(ref isUserText, value);
+            }
+        }
+
+        private bool leftChecked = true;
+
+        public bool LeftChecked
+        {
+            get { return leftChecked; }
+            set
+            {
+                SetProperty(ref leftChecked, value);
+            }
+        }
+
+        private bool centerChecked;
+
+        public bool CenterChecked
+        {
+            get { return centerChecked; }
+            set
+            {
+                SetProperty(ref centerChecked, value);
+            }
+        }
+
+
+        private bool rightChecked;
+
+        public bool RightChecked
+        {
+            get { return rightChecked; }
+            set
+            {
+                SetProperty(ref rightChecked, value);
+            }
+        }
+
+        private bool strechChecked;
+
+        public bool StrechChecked
+        {
+            get { return strechChecked; }
+            set
+            {
+                SetProperty(ref strechChecked, value);
+            }
+        }
+
+
+        private string overText;
+
+        public string OvertText
+        {
+            get { return overText; }
+            set
+            {
+                SetProperty(ref overText, value);
+            }
+        }
+
+        private int fontFamilySelectedIndex;
+
+        public int FontFamilySelectedIndex
+        {
+            get { return fontFamilySelectedIndex; }
+            set
+            {
+                SetProperty(ref fontFamilySelectedIndex, value);
+            }
+        }
+
+        private string fontFamily = "";
+
+        private int fontWeightSelectedIndex;
+
+        public int FontWeightSelectedIndex
+        {
+            get { return fontWeightSelectedIndex; }
+            set
+            {
+                SetProperty(ref fontWeightSelectedIndex, value);
+            }
+        }
+
+        private FontWeight fontWeight = FontWeights.Regular;
+
+        private int fontSizeSelectedIndex;
+
+        public int FontSizeSelectedIndex
+        {
+            get { return fontSizeSelectedIndex; }
+            set
+            {
+                SetProperty(ref fontSizeSelectedIndex, value);
+            }
+        }
+
+        public List<string> FontFamilys { get; set; }
+
+        public List<string> FontWeight { get; set; }
+
+        public List<string> FontSizes { get; set; }
+
 
 
         public MarkSettingDialogViewModel()
         {
             OkCommand = new DelegateCommand(ok);
             CancelCommand = new DelegateCommand(cancel);
+            AlignCommand = new DelegateCommand<string>(align);
+
+            InitFontFamily();
+            InitFontWeight();
+            InitFontSize();
+        }
+
+        private void InitFontFamily()
+        {
+            FontFamilys.Add("Courier New");
+            FontFamilys.Add("Arial");
+            FontFamilys.Add("Times New Roman");
+        }
+
+        private void InitFontWeight()
+        {
+            FontWeight.Add("Regular");
+            FontWeight.Add("Bold");
+            FontWeight.Add("Italic");
+            FontWeight.Add("Bold Italic");
+        }
+
+        private void InitFontSize()
+        {
+            FontSizes.Add("Auto");
         }
 
         private void cancel()
@@ -34,7 +213,26 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         private void ok()
         {
-            
+            //annotArgs.UpdateAttrib(AnnotAttrib.FillColor, frm.SaveredactionArgs.BgColor);
+            //annotArgs.UpdateAttrib(AnnotAttrib.NoteText, frm.SaveredactionArgs.Content);
+            //annotArgs.UpdateAttrib(AnnotAttrib.FontColor, frm.SaveredactionArgs.FontColor);
+
+            //annotArgs.UpdateAttrib(AnnotAttrib.Color, frm.SaveredactionArgs.LineColor);
+
+            //annotArgs.UpdateAttrib(AnnotAttrib.FontSize, frm.SaveredactionArgs.FontSize);
+
+            //annotArgs.UpdateAttrib(AnnotAttrib.TextAlign, frm.SaveredactionArgs.Align);
+            //if (IsUseText)
+            //{
+            //    annotArgs.UpdateAttrib(AnnotAttrib.NoteText, string.Empty);
+            //}
+            //annotArgs.UpdateAnnot();
+            RequestClose.Invoke(new DialogResult(ButtonResult.OK));
+        }
+
+        private void align(string tag)
+        {
+
         }
 
         public bool CanCloseDialog()
@@ -49,7 +247,29 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public void OnDialogOpened(IDialogParameters parameters)
         {
-           
+            annotArgs = parameters.GetValue<RedactionAnnotArgs>(ParameterNames.DataModel);
+
+            BgColor = annotArgs.BgColor;
+            LineColor = annotArgs.LineColor;
+            FontColor = annotArgs.FontColor;
+
+            OvertText = annotArgs.Content;
+            switch (annotArgs.FontFamily.ToString())
+            {
+                case "":
+                    FontFamilySelectedIndex = 0;
+                    break;
+                case "1":
+                    FontFamilySelectedIndex = 1;
+                    break;
+                case "2":
+                    FontFamilySelectedIndex = 2;
+                    break;
+                default:
+                    break;
+            }
+
+
         }
     }
 }

+ 96 - 3
PDF Office/ViewModels/Dialog/Redaction/RepeatMarkDialogViewModel.cs

@@ -1,4 +1,7 @@
-using Prism.Commands;
+using PDF_Office.CustomControl;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
@@ -19,15 +22,105 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public DelegateCommand CancelCommand { get; set; }
 
+        public DelegateCommand<string> CheckedCommand { get; set; }
+
+        private int pageCount;
+        /// <summary>
+        /// 最大页码
+        /// </summary>
+        public int PageCount
+        {
+            get { return pageCount; }
+            set
+            {
+                SetProperty(ref pageCount, value);
+            }
+        }
+
+        private string inputString;
+
+        public string InputString
+        {
+            get { return inputString; }
+            set
+            {
+                SetProperty(ref inputString, value);
+                if (!string.IsNullOrEmpty(value))
+                {
+                    CheckCustomPage();
+                }
+            }
+        }
+
+        public List<int> PageList = new List<int>();
+
         public RepeatMarkDialogViewModel()
         {
             OkCommand = new DelegateCommand(ok);
             CancelCommand = new DelegateCommand(cancel);
+            CheckedCommand = new DelegateCommand<string>(check);
         }
 
-        private void ok()
+        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(InputString))
+                    {
+                        CheckCustomPage();
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
 
+        private void CheckCustomPage()
+        {
+            var result = CommonHelper.GetPagesInRange(ref PageList, InputString, pageCount, new char[] { ',' }, new char[] { '-' });
+            if (!result)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("", "页码错误", "ok");
+                InputString = "";
+                return;
+            }
+        }
+
+
+        private void ok()
+        {
+            DialogParameters valuePairs = new DialogParameters();
+            valuePairs.Add(ParameterNames.PageList,PageList);
+            RequestClose.Invoke(new DialogResult(ButtonResult.OK,valuePairs));
         }
 
         private void cancel()
@@ -47,7 +140,7 @@ namespace PDF_Office.ViewModels.Dialog.Redaction
 
         public void OnDialogOpened(IDialogParameters parameters)
         {
-           
+           PageCount = parameters.GetValue<int>(ParameterNames.PageCount);
         }
     }
 }

+ 9 - 5
PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressDialogViewModel.cs

@@ -10,7 +10,9 @@ using System.Windows.Forms;
 using System.Windows;
 using DialogResult = Prism.Services.Dialogs.DialogResult;
 using MessageBox = System.Windows.Forms.MessageBox;
-
+using PDF_Office.Helper;
+using ComPDFKitViewer.PdfViewer;
+
 namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
 {
     public class CompressDialogViewModel : BindableBase, IDialogAware
@@ -19,6 +21,7 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
         private CompressDialogModel compressDialogModel;
         private IntPtr compressingIntpr = IntPtr.Zero;
         private CPDFDocument document;
+        private CPDFViewer pdfviewer;
         private Visibility _compressLargeStyle = Visibility.Hidden;
         public IDialogService dialogs;
 
@@ -146,6 +149,7 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
              *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
              **/
             sfd.FileName = document.FileName + "_CompressFile.pdf";
+
             if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 /*
@@ -155,6 +159,7 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
                 Trace.WriteLine("compressDialogModel.CompressQuality:  " + compressDialogModel.CompressQuality);
                 DialogParameters value = new DialogParameters();
                 value.Add(ParameterNames.PDFDocument, document);
+                value.Add(ParameterNames.PassWord, pdfviewer.Tag);
                 value.Add(ParameterNames.FilePath, sfd.FileName);
                 value.Add("compressDialogModel.CompressQuality", (int)compressDialogModel.CompressQuality);
                 RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
@@ -186,12 +191,11 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
 
         public void OnDialogOpened(IDialogParameters parameters)
         {
-            CPDFDocument doc = null;
-            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
-            if (doc != null)
+            parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfviewer);
+            if (pdfviewer != null)
             {
                 CompressDialogModel compressdialogmodel = new CompressDialogModel();
-                document = doc;
+                document = pdfviewer.Document;
                 compressDialogModel = compressdialogmodel;
                 compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusDefault;
             }

+ 4 - 1
PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressProgressBarDialogViewModel.cs

@@ -73,14 +73,17 @@ namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
         {
             CPDFDocument doc = null;
             string filepath = "";
+            string password = "";
             int compressquality = 45;
             parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
             parameters.TryGetValue<string>(ParameterNames.FilePath, out filepath);
+            parameters.TryGetValue<string>(ParameterNames.PassWord, out password);
             parameters.TryGetValue<int>("compressDialogModel.CompressQuality", out compressquality);
             if (doc != null)
             {
                 PageNumber = doc.PageCount.ToString();
-                CPDFDocument document = CPDFDocument.InitWithFilePath(doc.FilePath);
+                CPDFDocument document = CPDFDocument.InitWithFilePath(doc.FilePath);
+                document.UnlockWithPassword(password);
                 indexDelegate += GetIndex;
                 compressingIntpr = document.CompressFile_Init(compressquality, indexDelegate);
                 //GC.KeepAlive(indexDelegate);

+ 2 - 38
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterDocumentContentViewModel.cs

@@ -93,43 +93,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             eventAggregator.GetEvent<DeleteHeaderFooterEvent>().Subscribe(DeleteHeaderFooter, e => e.Unicode == Unicode);
 
         }
-        public string ReverseDate(string str)
-        {
-            string yyyy = DateTime.Now.ToString("yyyy");
-            string yy = DateTime.Now.ToString("yy");
-            string mm = DateTime.Now.ToString("MM");
-            string m = DateTime.Now.ToString("%M");
-            string dd = DateTime.Now.ToString("dd");
-            string d = DateTime.Now.ToString("%d");
-            str = str.Replace("<<m/d>>", m + "/" + d)
-            .Replace("<<m/d/yy>>", m + "/" + d + "/" + yy)
-            .Replace("<<m/d/yyyy>>", m + "/" + d + "/" + yyyy)
-            .Replace("<<mm/dd/yy>>", mm + "/" + dd + "/" + yy)
-            .Replace("<<mm/dd/yyyy>>", mm + "/" + dd + "/" + yyyy)
-            .Replace("<<d/m/yy>>", d + "/" + m + "/" + yy)
-            .Replace("<<d/m/yyyy>>", d + "/" + m + "/" + yyyy)
-            .Replace("<<dd/mm/yy>>", dd + "/" + mm + "/" + yy)
-            .Replace("<<dd/mm/yyyy>>", dd + "/" + mm + "/" + yyyy)
-            .Replace("<<mm/yy>>", mm + "/" + yy)
-            .Replace("<<mm/yyyy>>", mm + "/" + yyyy)
-            .Replace("<<m.d.yy>>", m + "." + d + "." + yy)
-            .Replace("<<m.d.yyyy>>", m + "." + d + "." + yyyy)
-            .Replace("<<mm.dd.yy>>", mm + "." + dd + "." + yy)
-            .Replace("<<mm.dd.yyyy>>", mm + "." + dd + "." + yyyy)
-            .Replace("<<mm.yy>>", mm + "." + yy)
-            .Replace("<<mm.yyyy>>", mm + "." + yyyy)
-            .Replace("<<d.m.yy>>", d + "." + m + "." + yy)
-            .Replace("<<d.m.yyyy>>", d + "." + m + "." + yyyy)
-            .Replace("<<dd.mm.yy>>", dd + "." + mm + "." + yy)
-            .Replace("<<dd.mm.yyyy>>", dd + "." + mm + "." + yyyy)
-            .Replace("<<yy-mm-dd>>", yy + "-" + mm + "-" + dd)
-            .Replace("<<yyyy-mm-dd>>", yyyy + "-" + mm + "-" + dd)
-            .Replace("<<1 of n>>", "<<1>>" + " of " + Document.PageCount)
-            .Replace("<<1/n>>", "<<1>>" + "/" + Document.PageCount)
-            .Replace("<<Page 1>>", "Page" + "<<1>>")
-            .Replace("<<Page 1 of n>>", "Page " + "<<1>>" + " of " + Document.PageCount);
-            return str;
-        }
+        
 
         public void ShowInputIndexBox(object obj)
         {
@@ -205,7 +169,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
                 headerFooter = document.GetHeaderFooter();
                 for (int i = 0; i < 6; i++)
                 {
-                    headerFooter.SetText(i, ReverseDate(headerFooterInfo.TextData[i].text));
+                    headerFooter.SetText(i, HomePageEditHelper.ReverseDate(headerFooterInfo.TextData[i].text, document));
 
                     headerFooter.SetFontName(i, headerFooterInfo.TextData[i].fontName);
                     headerFooter.SetFontSize(i, headerFooterInfo.TextData[i].fontSize);

+ 9 - 1
PDF Office/ViewModels/EditTools/Redaction/RedactionContentViewModel.cs

@@ -145,8 +145,11 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
         /// <param name="args"></param>
         private void SetDefualtProperty(RedactionCommandEventArgs args)
         {
+            var annoteargs = args.args.AnnotEventArgsList[0] as RedactionAnnotArgs;
             DialogParameters keyValues = new DialogParameters();
             keyValues.Add(ParameterNames.DataModel,args.args.AnnotEventArgsList[0] as RedactionAnnotArgs);
+
+            Settings.Default.RedactionsSettings.SetDefualtValue(annoteargs.Content, annoteargs.LineColor,annoteargs.BgColor,annoteargs.FontColor, (int)annoteargs.FontSize,string.IsNullOrEmpty(annoteargs.Content) ? false : true, annoteargs.Align, annoteargs.FontFamily.ToString(),FontWeights.Regular);
         }
 
         /// <summary>
@@ -168,7 +171,12 @@ namespace PDF_Office.ViewModels.EditTools.Redaction
         {
             DialogParameters keyValues = new DialogParameters();
             keyValues.Add(ParameterNames.PageCount,PDFViewer.Document.PageCount);
-            dialogs.ShowDialog(DialogNames.RepeatMarkDialog, keyValues, null);
+            dialogs.ShowDialog(DialogNames.RepeatMarkDialog, keyValues, e=> {
+                if (e.Result == ButtonResult.OK)
+                {
+                    PDFViewer.AddRedaction(e.Parameters.GetValue<List<int>>(ParameterNames.PageList), args.args);
+                }
+            });
         }
         /// <summary>
         /// 应用

+ 1 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkCreateFileContentViewModel.cs

@@ -455,6 +455,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, PDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
         }

+ 1 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs

@@ -273,6 +273,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, CurrentPDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
         }

+ 1 - 0
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListTextContentViewModel.cs

@@ -240,6 +240,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 watermarkInfo.HorizOffset = watermarkItem.horizOffset;
                 watermarkInfo.VerticalSpacing = watermarkItem.verticalSpacing;
                 watermarkInfo.HorizontalSpacing = watermarkItem.horizontalSpacing;
+                watermarkInfo.PageRangeIndex = watermarkItem.pageRangeIndex;
                 EditToolsHelper.GetPageRange(watermarkItem.pageRangeIndex, CurrentPDFViewer.Document, ref WatermarkInfo.PageRange, watermarkItem.pageRange);
             }
 

+ 29 - 6
PDF Office/ViewModels/Form/ButtonPropertyViewModel.cs

@@ -1,4 +1,5 @@
 using ComPDFKit.PDFAnnotation;
+using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl.CompositeControl;
@@ -62,13 +63,13 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitAllResetColor()
         {
-            ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorOne = InitResetColor(Color.FromArgb(0xFF, 0x18, 0xA0, 0xFB), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0xff, 0xff));
 
-            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorTwo = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xB9, 0xB9, 0xB9));
 
-            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+             ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), Color.FromArgb(0xFF, 0x00, 0x00, 0x00));
 
-            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
+            ResetColorForth = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x38, 0xAC, 0xFF));
         }
 
         private void InitFontFamilyComboBox()
@@ -78,7 +79,7 @@ namespace PDF_Office.ViewModels.Form
             FontFamilyItems.Add(item);
             item = new ComboDataItem("Helvetica", "Helvetica");
             FontFamilyItems.Add(item);
-            item = new ComboDataItem("Times Roman", "Times New Roman");
+            item = new ComboDataItem("Times-Roman", "Times New Roman");
             FontFamilyItems.Add(item);
         }
 
@@ -283,6 +284,7 @@ namespace PDF_Office.ViewModels.Form
             pushButtonArgs = null;
             isCreateWidget = false;
             IsCurrentWidget = false;
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -290,11 +292,30 @@ namespace PDF_Office.ViewModels.Form
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<WidgetPushButtonArgs>("WidgetArgs", out pushButtonArgs);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
 
             GetWidgeText();
             UpdataSelectResetColorBtn();
         }
 
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+
+                var widgeArgs = e[e.Count - 1].EditAnnotArgs as WidgetArgs;
+                if (widgeArgs != null)
+                {
+                    AnnotEditEvent editEvent = e[e.Count - 1];
+                    if (editEvent.EditAction == ActionType.Modify)
+                    {
+                        SetSizeNoUpdateValue(widgeArgs.Width, widgeArgs.Height);
+                    }
+                }
+            }
+        }
+
         private void GetWidgeText()
         {
            
@@ -307,7 +328,9 @@ namespace PDF_Office.ViewModels.Form
                 pushButtonArgs.FontSize = 12;
                 pushButtonArgs.FontColor = Colors.Black;
                 pushButtonArgs.LineColor = Colors.Black;
-                pushButtonArgs.LineWidth = 1;
+                pushButtonArgs.LineWidth = 2;
+                pushButtonArgs.Width = 72;
+                pushButtonArgs.Height = 20;
                 var action = new Dictionary<ComPDFKit.PDFDocument.Action.C_ACTION_TYPE, string>();
                 action.Add(ComPDFKit.PDFDocument.Action.C_ACTION_TYPE.ACTION_TYPE_URI, "");
                 pushButtonArgs.ActionDict = action;

+ 34 - 5
PDF Office/ViewModels/Form/CheckBoxPropertyViewModel.cs

@@ -1,5 +1,6 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKit.PDFAnnotation.Form;
+using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Helper;
@@ -57,13 +58,13 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitAllResetColor()
         {
-            ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorOne = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
 
-            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xFF, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
+            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
         }
 
         private void InitCommand()
@@ -241,6 +242,7 @@ namespace PDF_Office.ViewModels.Form
             checkBoxArgs = null;
             isCreateWidget = false;
             IsCurrentWidget = false;
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -248,11 +250,30 @@ namespace PDF_Office.ViewModels.Form
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
             navigationContext.Parameters.TryGetValue<WidgetCheckBoxArgs>("WidgetArgs", out checkBoxArgs);
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
 
             GetWidgeText();
             UpdataSelectResetColorBtn();
         }
 
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+
+                var widgeArgs = e[e.Count - 1].EditAnnotArgs as WidgetArgs;
+                if (widgeArgs != null)
+                {
+                    AnnotEditEvent editEvent = e[e.Count - 1];
+                    if (editEvent.EditAction == ActionType.Modify)
+                    {
+                        SetSizeNoUpdateValue(widgeArgs.Width, widgeArgs.Height);
+                    }
+                }
+            }
+        }
+
         private void GetWidgeText()
         {
 
@@ -265,7 +286,10 @@ namespace PDF_Office.ViewModels.Form
                 args.BorderStyle = C_BORDER_STYLE.BS_SOLID;
                 args.LineColor = Colors.Black;
                 args.BgColor = Colors.LightGreen;
-                args.LineWidth = 1;
+                args.LineWidth = 2;
+                args.Height = 18;
+                args.Width = 18;
+                args.ExportValue = "Yes";
                 checkBoxArgs = args;
                 PDFViewer.SetToolParam(checkBoxArgs);
                 isCreateWidget = true;
@@ -304,6 +328,11 @@ namespace PDF_Office.ViewModels.Form
                     IsSolid = false;
      
                 IsDefaultCheckBox = checkBoxArgs.IsChecked;
+                if (isCreateWidget == false)
+                {
+                    HeightSize = checkBoxArgs.Height;
+                    WidthSize = checkBoxArgs.Width;
+                }
             }
         }
 

+ 35 - 7
PDF Office/ViewModels/Form/ComboxPropertyViewModel.cs

@@ -90,13 +90,13 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitAllResetColor()
         {
-            ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorOne = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0xFE, 0xAD, 0x4A), Color.FromArgb(0xFF, 0xF7, 0x58, 0x50), Color.FromArgb(0xFF, 0xff, 0xff, 0xff));
 
-            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0xB6, 0x44, 0xF7), Color.FromArgb(0xFF, 0x53, 0x71, 0xF5), Color.FromArgb(0xFF, 0xff, 0xff, 0xff));
 
-            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
+            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xF7, 0x58, 0x50), Color.FromArgb(0xFF, 0x7F, 0xCB, 0x3A), Colors.Transparent);
         }
 
         private void InitFontFamilyComboBox()
@@ -106,7 +106,7 @@ namespace PDF_Office.ViewModels.Form
             FontFamilyItems.Add(item);
             item = new ComboDataItem("Helvetica", "Helvetica");
             FontFamilyItems.Add(item);
-            item = new ComboDataItem("Times", "Times New Roman");
+            item = new ComboDataItem("Times-Roman", "Times New Roman");
             FontFamilyItems.Add(item);
         }
 
@@ -453,18 +453,40 @@ namespace PDF_Office.ViewModels.Form
         {
             comboBoxArgs = null;
             ClearVMData();
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
         }
 
+ 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<WidgetComboBoxArgs>("WidgetArgs", out comboBoxArgs);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
+
             OptionsList = new Dictionary<string, string>();
             GetWidgeText();
             UpdataSelectResetColorBtn();
         }
 
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+
+                var widgeArgs = e[e.Count - 1].EditAnnotArgs as WidgetArgs;
+                if (widgeArgs != null)
+                {
+                    AnnotEditEvent editEvent = e[e.Count - 1];
+                    if (editEvent.EditAction == ActionType.Modify)
+                    {
+                        SetSizeNoUpdateValue(widgeArgs.Width, widgeArgs.Height);
+                    }
+                }
+            }
+        }
+
         private void GetWidgeText()
         {
             
@@ -477,8 +499,10 @@ namespace PDF_Office.ViewModels.Form
                 comboBoxArgs.FontSize = 12;
                 comboBoxArgs.FontColor = Colors.Black;
                 comboBoxArgs.LineColor = Colors.Black;
-                comboBoxArgs.LineWidth = 1;
+                comboBoxArgs.LineWidth = 2;
                 comboBoxArgs.FieldName = "ComBox";
+                comboBoxArgs.Width = 72;
+                comboBoxArgs.Height = 20;
                 PDFViewer.SetToolParam(comboBoxArgs);
                 isCreateWidget = true;
             }
@@ -547,7 +571,11 @@ namespace PDF_Office.ViewModels.Form
                     var item = new ComboDataItem(OptionsList[key], key);
                     OptionItems.Add(item);
                 }
-                
+                if (isCreateWidget == false)
+                {
+                    HeightSize = comboBoxArgs.Height;
+                    WidthSize = comboBoxArgs.Width;
+                }
             }
         }
         #endregion

+ 10 - 3
PDF Office/ViewModels/Form/FormBaseVM.cs

@@ -238,7 +238,7 @@ namespace PDF_Office.ViewModels.Form
         public double WidthSize
         {
             get { return _widthSize; }
-            set { SetProperty(ref _widthSize, value); ChangeValue(AnnotAttrib.Width, value); }
+            set { SetProperty(ref _widthSize, value); if (isNoUpdateValue == false) ChangeValue(AnnotAttrib.Width, value); }
         }
 
         //高大小
@@ -246,9 +246,16 @@ namespace PDF_Office.ViewModels.Form
         public double HeightSize
         {
             get { return _heightSize; }
-            set { SetProperty(ref _heightSize, value); ChangeValue(AnnotAttrib.Height, value); }
+            set { SetProperty(ref _heightSize, value);if (isNoUpdateValue == false) ChangeValue(AnnotAttrib.Height, value); }
+        }
+        private bool isNoUpdateValue = false;
+        public void SetSizeNoUpdateValue(double width, double height)
+        {
+            isNoUpdateValue = true;
+            WidthSize = width;
+            HeightSize = height;
+            isNoUpdateValue = false;
         }
-
 
 
         #endregion

+ 2 - 43
PDF Office/ViewModels/Form/FormsToolContentViewModel.cs

@@ -96,7 +96,6 @@ namespace PDF_Office.ViewModels.Form
             AddToPropertyPanel(type);
         }
 
-        //
         private void ClickEvent(string obj)
         {
 
@@ -150,45 +149,6 @@ namespace PDF_Office.ViewModels.Form
 
         #endregion
 
-        #region 获取Form
-
-        private void GetTextField()
-        {
-            
-        }
-
-        private void GetButton()
-        {
-
-        }
-
-        private void GeCheckBox()
-        {
-
-        }
-
-        private void GetCombox()
-        {
-
-        }
-
-        private void GetListBox()
-        {
-
-        }
-
-        private void GetRadioButton()
-        {
-
-        }
-
-        private void GetSign()
-        {
-
-        }
-
-
-        #endregion
 
         #region 表单内部触发的事件(比如选中表单行为等)
         private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
@@ -231,7 +191,7 @@ namespace PDF_Office.ViewModels.Form
         }
 
         public WidgetArgs CurrentWidgetArgs;
-        //新增
+        //新增  
         private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
         {
            if(e != null && e.Count > 0)
@@ -248,8 +208,7 @@ namespace PDF_Office.ViewModels.Form
                 {
                     PDFViewer.SelectAnnotation(editEvent.PageIndex, editEvent.AnnotIndex);
                 }
-               
-
+              
             }
         }
 

+ 35 - 6
PDF Office/ViewModels/Form/ListBoxPropertyViewModel.cs

@@ -92,13 +92,13 @@ namespace PDF_Office.ViewModels.Form
 
         private void InitAllResetColor()
         {
-            ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorOne = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0xC2, 0xC2, 0xC2), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
 
-            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0xff, 0xff, 0xff), Color.FromArgb(0xFF, 0xFB, 0x18, 0x18), Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
 
-            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
+            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0xff, 0xff), Color.FromArgb(0xFF, 0x18, 0xA0, 0xFB), Color.FromArgb(0xFF, 0xff, 0xff, 0xff));
         }
 
         private void InitFontFamilyComboBox()
@@ -108,7 +108,7 @@ namespace PDF_Office.ViewModels.Form
             FontFamilyItems.Add(item);
             item = new ComboDataItem("Helvetica", "Helvetica");
             FontFamilyItems.Add(item);
-            item = new ComboDataItem("Times Roman", "Times New Roman");
+            item = new ComboDataItem("Times-Roman", "Times New Roman");
             FontFamilyItems.Add(item);
         }
 
@@ -456,6 +456,7 @@ namespace PDF_Office.ViewModels.Form
         {
             listBoxArgs = null;
             ClearVMData();
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -463,12 +464,32 @@ namespace PDF_Office.ViewModels.Form
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<WidgetListBoxArgs>("WidgetArgs", out listBoxArgs);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
+
             OptionsList = new Dictionary<string, string>();
 
             GetWidgeText();
             UpdataSelectResetColorBtn();
         }
 
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+
+                var widgeArgs = e[e.Count - 1].EditAnnotArgs as WidgetArgs;
+                if (widgeArgs != null)
+                {
+                    AnnotEditEvent editEvent = e[e.Count - 1];
+                    if (editEvent.EditAction == ActionType.Modify)
+                    {
+                        SetSizeNoUpdateValue(widgeArgs.Width, widgeArgs.Height);
+                    }
+                }
+            }
+        }
+
         private void GetWidgeText()
         {
          
@@ -481,7 +502,9 @@ namespace PDF_Office.ViewModels.Form
                 listBoxArgs.FontSize = 12;
                 listBoxArgs.FontColor = Colors.Black;
                 listBoxArgs.LineColor = Colors.Black;
-                listBoxArgs.LineWidth = 1;
+                listBoxArgs.LineWidth = 2;
+                listBoxArgs.Width = 100;
+                listBoxArgs.Height = 72;
 
                 PDFViewer.SetToolParam(listBoxArgs);
                 isCreateWidget = true;
@@ -551,6 +574,12 @@ namespace PDF_Office.ViewModels.Form
                     OptionItems.Add(item);
                 }
 
+                if (isCreateWidget == false)
+                {
+                    HeightSize = listBoxArgs.Height;
+                    WidthSize = listBoxArgs.Width;
+                }
+
             }
         }
         #endregion

+ 35 - 5
PDF Office/ViewModels/Form/RadioButtonPropertyViewModel.cs

@@ -1,4 +1,5 @@
 using ComPDFKit.PDFAnnotation;
+using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Helper;
@@ -56,13 +57,13 @@ namespace PDF_Office.ViewModels.Form
         }
         private void InitAllResetColor()
         {
-            ResetColorOne = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorOne = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xFF, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x18, 0xA0, 0xFB), Colors.Transparent);
 
-            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
+            ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x10, 0xCB, 0x39), Colors.Transparent);
         }
 
         private void InitCommand()
@@ -241,6 +242,24 @@ namespace PDF_Office.ViewModels.Form
             radioButtonArgs = null;
             isCreateWidget = false;
             IsCurrentWidget = false;
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+        }
+
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+
+                var widgeArgs = e[e.Count - 1].EditAnnotArgs as WidgetArgs;
+                if (widgeArgs != null)
+                {
+                    AnnotEditEvent editEvent = e[e.Count - 1];
+                    if (editEvent.EditAction == ActionType.Modify)
+                    {
+                        SetSizeNoUpdateValue(widgeArgs.Width, widgeArgs.Height);
+                    }
+                }
+            }
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -248,6 +267,8 @@ namespace PDF_Office.ViewModels.Form
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
             navigationContext.Parameters.TryGetValue<WidgetRadioButtonArgs>("WidgetArgs", out radioButtonArgs);
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
 
             GetWidgeText();
             UpdataSelectResetColorBtn();
@@ -263,7 +284,10 @@ namespace PDF_Office.ViewModels.Form
                 radioButtonArgs.BgColor =  Colors.Transparent;
                 radioButtonArgs.FontColor = Colors.Black;
                 radioButtonArgs.LineColor = Colors.Black;
-                radioButtonArgs.LineWidth = 1;
+                radioButtonArgs.LineWidth = 2;
+                radioButtonArgs.Width = 18;
+                radioButtonArgs.Height = 18;
+                radioButtonArgs.RadioMemberName = "Option1";
                 PDFViewer.SetToolParam(radioButtonArgs);
                 isCreateWidget = true;
             }
@@ -302,6 +326,12 @@ namespace PDF_Office.ViewModels.Form
                     IsSolid = false;
 
                 IsDefaultRadioBox = radioButtonArgs.IsChecked;
+
+                if (isCreateWidget == false)
+                {
+                    HeightSize = radioButtonArgs.Height;
+                    WidthSize = radioButtonArgs.Width;
+                }
             }
         }
 

+ 32 - 3
PDF Office/ViewModels/Form/TextFieldPropertyViewModel.cs

@@ -71,7 +71,7 @@ namespace PDF_Office.ViewModels.Form
 
             ResetColorTwo = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
 
-            ResetColorThree = InitResetColor(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Colors.Transparent);
+            ResetColorThree = InitResetColor(Colors.Transparent, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), Color.FromArgb(0xFF, 0xBD, 0xDF, 0xFD));
 
             ResetColorForth = InitResetColor(Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Color.FromArgb(0xFF, 0xff, 0x00, 0x00), Colors.Transparent);
         }
@@ -83,7 +83,7 @@ namespace PDF_Office.ViewModels.Form
             FontFamilyItems.Add(item);
             item = new ComboDataItem("Helvetica", "Helvetica");
             FontFamilyItems.Add(item);
-            item = new ComboDataItem("Times Roman", "Times New Roman");
+            item = new ComboDataItem("Times-Roman", "Times New Roman");
             FontFamilyItems.Add(item);
         }
 
@@ -289,6 +289,7 @@ namespace PDF_Office.ViewModels.Form
             isCreateWidget = false;
             IsCurrentWidget = false;
             textBoxArgs = null;
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -296,10 +297,29 @@ namespace PDF_Office.ViewModels.Form
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
             navigationContext.Parameters.TryGetValue<WidgetTextBoxArgs>("WidgetArgs", out textBoxArgs);
+            PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
             GetWidgeText();
             UpdataSelectResetColorBtn();
         }
-        
+
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+
+                var widgeArgs = e[e.Count - 1].EditAnnotArgs as WidgetArgs;
+                if (widgeArgs != null)
+                {
+                    AnnotEditEvent editEvent = e[e.Count - 1];
+                    if (editEvent.EditAction == ActionType.Modify)
+                    {
+                        SetSizeNoUpdateValue(widgeArgs.Width, widgeArgs.Height);
+                    }
+                }
+            }
+        }
+
         private void GetWidgeText()
         {
             //新建的form表单
@@ -308,7 +328,16 @@ namespace PDF_Office.ViewModels.Form
                 PDFViewer.SetMouseMode(MouseModes.FormEditTool);
                 WidgetTextBoxArgs textArgs = new WidgetTextBoxArgs();
                 textArgs.BgColor = Colors.LightGray;
+                textArgs.Width = 150;
+                textArgs.Height = 22;
                 textBoxArgs = textArgs;
+                textArgs.FontSize = 12;
+                textArgs.FontFamily = "Helvatica";
+                textArgs.LineWidth = 2;
+                textArgs.FontColor = Colors.Black;
+                textArgs.LineColor = Colors.Black;
+          
+               // textArgs.
                 PDFViewer.SetToolParam(textBoxArgs);
                 isCreateWidget = true;
             }

+ 2 - 6
PDF Office/ViewModels/HomeContentViewModel.cs

@@ -151,21 +151,17 @@ namespace PDF_Office.ViewModels
         /// <summary>
         /// 从网页创建PDF文件
         /// </summary>
-        private async void createFormHtml()
+        private void createFormHtml()
         {
-
-            IsLoading = Visibility.Visible;
-            await Task.Delay(20);
-
             dialog.ShowDialog(DialogNames.CreateFromHtmlDialog, async e =>{ 
                 if(e.Result== ButtonResult.OK)
                 {
+                    IsLoading = Visibility.Visible;
                     var model = e.Parameters.GetValue<Model.Dialog.HomePageToolsDialogs.HtmlModel>(ParameterNames.DataModel);
                     await mainContentViewModel.CreateFileFromOffice(model.FilePath,model.PageSize,model.Margin);
                     IsLoading = Visibility.Collapsed;
                 }
             });
-   
         }
 
         /// <summary>

+ 45 - 1
PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs

@@ -188,7 +188,7 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
                         break;
                     case PDFFnType.HeaderFooter:
                         DialogParameters headerFooterpdf = new DialogParameters();
-                        headerFooterpdf.Add(ParameterNames.BatchProcessing_Name, "6");
+                        headerFooterpdf.Add(ParameterNames.BatchProcessing_Name, "5");
                         HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
                         HomePageBatchProcessingDialogModel.BatchProcessingIndex = 5;
                         headerFooterpdf.Add(ParameterNames.FilePath, dlg.FileNames);
@@ -218,6 +218,50 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
                         watermarkpdf.Add(ParameterNames.FilePath, dlg.FileNames);
                         dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, watermarkpdf, e => { });
                         break;
+                    case PDFFnType.PDFToImage:
+                        DialogParameters convertpdftoimage = new DialogParameters();
+                        convertpdftoimage.Add(ParameterNames.BatchProcessing_Name, "0");
+                        convertpdftoimage.Add("ConverterTypeIndex", 7);
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
+                        convertpdftoimage.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, convertpdftoimage, e => { });
+                        break;
+                    case PDFFnType.PDFToExcel:
+                        DialogParameters convertpdftoexcel = new DialogParameters();
+                        convertpdftoexcel.Add(ParameterNames.BatchProcessing_Name, "0");
+                        convertpdftoexcel.Add("ConverterTypeIndex", 1);
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
+                        convertpdftoexcel.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, convertpdftoexcel, e => { });
+                        break;
+                    case PDFFnType.PDFToPPT:
+                        DialogParameters convertpdftoppt = new DialogParameters();
+                        convertpdftoppt.Add(ParameterNames.BatchProcessing_Name, "0");
+                        convertpdftoppt.Add("ConverterTypeIndex", 2);
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
+                        convertpdftoppt.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, convertpdftoppt, e => { });
+                        break;
+                    case PDFFnType.PDFToWord:
+                        DialogParameters convertpdftoword = new DialogParameters();
+                        convertpdftoword.Add(ParameterNames.BatchProcessing_Name, "0");
+                        convertpdftoword.Add("ConverterTypeIndex", 0);
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
+                        convertpdftoword.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, convertpdftoword, e => { });
+                        break;
+                    case PDFFnType.Batch:
+                        DialogParameters batcpdf = new DialogParameters();
+                        batcpdf.Add(ParameterNames.BatchProcessing_Name, "0");
+                        HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
+                        HomePageBatchProcessingDialogModel.BatchProcessingIndex = 0;
+                        batcpdf.Add(ParameterNames.FilePath, dlg.FileNames);
+                        dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, batcpdf, e => { });
+                        break;
                 }
 
             }

+ 15 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SignatureAnnotPropertyViewModel.cs

@@ -28,6 +28,18 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         private IDialogService dialogs;
         public DelegateCommand ShowDialogCommand { get; set; }
 
+
+        private int currentListboxIndex = -1;
+
+        public int CurrentListboxIndex
+        {
+            get { return currentListboxIndex; }
+            set
+            {
+                SetProperty(ref currentListboxIndex, value);
+            }
+        }
+
         public ObservableCollection<Signature> SignatureList { get; set; }
         public SignatureAnnotPropertyViewModel(IDialogService dialogService)
         {
@@ -171,6 +183,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             signature.Type = (PDFSettings.SignatureType)Signature.Type;
             stamps.Add(signature);
             Settings.Default.Save();
+
+            SetSignature(Signature);
+            CurrentListboxIndex = SignatureList.Count - 1;
         }
 
         /// <summary>

+ 6 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/SignatureCreateDialogViewModel.cs

@@ -84,6 +84,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+
         private Visibility showImageButton = Visibility.Visible;
 
         public Visibility ShowImageButton
@@ -439,6 +440,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 case 0:
                     {
+                        if (string.IsNullOrEmpty(InputText))
+                        {
+                            Cancel();
+                            return;
+                        }
                         System.Drawing.Color fontcolor = System.Drawing.Color.Black;
                         switch (RadioButtonIndex)
                         {

+ 32 - 2
PDF Office/ViewModels/PropertyPanel/Scan/ScanPropertyPanelViewModel.cs

@@ -1,5 +1,8 @@
 using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
 using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
@@ -23,9 +26,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.Scan
             }
         }
 
-        private string setPageRange;
+        private List<int> setPageRange;
 
-        public string SetPageRange
+        public List<int> SetPageRange
         {
             get { return setPageRange; }
             set
@@ -36,6 +39,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.Scan
 
 
         private CPDFViewer PDFViewer;
+
+        public IEventAggregator events;
+
+        public DelegateCommand OCRCommand { get; set; }
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -58,5 +65,28 @@ namespace PDF_Office.ViewModels.PropertyPanel.Scan
                 PageCount = PDFViewer.Document.PageCount;
             }
         }
+        public ScanPropertyPanelViewModel(IEventAggregator eventAggregator)
+        {
+            setPageRange = new List<int>();
+            events = eventAggregator;
+            OCRCommand = new DelegateCommand(OCR);
+        }
+        private void OCR()
+        {
+            try
+            {
+                events.GetEvent<ScanEvent>().Publish(new ScanEventArgs()
+                {
+                    Unicode = App.mainWindowViewModel.SelectedItem.Unicode,
+                    PageRange = SetPageRange,
+                    Mode = ScanMode.OCR,
+                    ScanLanguage = ScanLanguageMode.ChineseS
+                }
+                );
+            }
+            catch (Exception e)
+            {
+            }
+        }
     }
 }

+ 222 - 0
PDF Office/ViewModels/Scan/ScanViwerViewModel.cs

@@ -0,0 +1,222 @@
+using ComDocumentAIKit;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Helper;
+using PDF_Office.Model;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace PDF_Office.ViewModels.Scan
+{
+    class ScanViwerViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer PDFViewer;
+
+        private WriteableBitmap bgImage;
+
+        public WriteableBitmap BgImage
+        {
+            get { return bgImage; }
+            set
+            {
+                SetProperty(ref bgImage, value);
+            }
+        }
+
+        private List<KeyValuePair<Rect, string>> textRectList;
+
+        public List<KeyValuePair<Rect, string>> TextRectList
+        {
+            get { return textRectList; }
+            set
+            {
+                SetProperty(ref textRectList, value);
+            }
+        }
+
+        private Dictionary<int, List<KeyValuePair<Rect, string>>> cacahe;
+
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            return;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer == null)
+            {
+                return;
+            }
+            else
+            {
+                PDFViewer.InfoChanged += PDFViewer_InfoChanged;
+
+                PDFViewer.ChangeViewMode(ViewMode.Single);
+                //第一次进入获取当前预览显示内容
+                CPDFPage pdfPage = PDFViewer.Document.PageAtIndex(PDFViewer.CurrentIndex);
+                float zoom = (float)(DpiHelpers.Dpi / 72D);
+                int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
+                int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
+                byte[] renderData = new byte[renderWidth * renderHeight * 4];
+                pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
+                BgImage = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                BgImage.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, BgImage.BackBufferStride, 0);
+            }
+        }
+
+        private void PDFViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
+        {
+            if (e.Key == "PageNum")
+            {
+                RenderData renderData = e.Value as RenderData;
+                if (renderData != null)
+                {
+                    CPDFPage pdfPage = PDFViewer.Document.PageAtIndex(renderData.PageIndex - 1);
+                    float zoom = (float)(DpiHelpers.Dpi / 72D);
+                    int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
+                    int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
+                    byte[] Data = new byte[renderWidth * renderHeight * 4];
+                    pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, Data, 0);
+                    BgImage = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                    BgImage.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), Data, BgImage.BackBufferStride, 0);
+
+                    if (cacahe.Count > 0)
+                    {
+                        if (cacahe.ContainsKey(renderData.PageIndex - 1))
+                        {
+                            TextRectList = cacahe[renderData.PageIndex - 1];
+                        }
+                        else
+                        {
+                            TextRectList = null;
+                        }
+                    }
+                }
+            }
+        }
+
+        public ScanViwerViewModel(IEventAggregator eventAggregator)
+        {
+            eventAggregator.GetEvent<ScanEvent>().Subscribe(ChangeScanMode, e => e.Unicode == App.mainWindowViewModel.SelectedItem.Unicode);
+            cacahe = new Dictionary<int, List<KeyValuePair<Rect, string>>>();
+        }
+        /// <summary>
+        /// 根据Vm事件通知处理OCR与区域识别事件
+        /// </summary>
+        /// <param name="e"></param>
+        private void ChangeScanMode(ScanEventArgs e)
+        {
+            switch (e.Mode)
+            {
+                case ScanMode.Unknown:
+                    break;
+                case ScanMode.OCR:
+                    OCRProcess(e);
+                    break;
+                case ScanMode.Area:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void OCRProcess(ScanEventArgs args)
+        {
+            COCREngine imEngine = new COCREngine(App.modelFolderPath);
+            //CIMEngine imEngine = new CIMEngine(App.modelFolderPath);
+
+            string path = App.CachePath.MergeFilePath;
+            string name = Guid.NewGuid().ToString();
+            path = Path.Combine(path, name);
+            string EnhancePath = Path.Combine(path, "Enhance");
+
+            Directory.CreateDirectory(path);
+            Directory.CreateDirectory(EnhancePath);
+
+            CPDFDocument CurrentDoc = PDFViewer.Document;
+
+            CErrorCode error = imEngine.SetModel((COCRLanguage)args.ScanLanguage);
+
+            cacahe.Clear();
+
+            for (int i = 0; i < args.PageRange.Count; i++)
+            {
+                string pageImagePath = Path.Combine(path, args.PageRange[i].ToString());
+                string pageEnhancePath = Path.Combine(EnhancePath, args.PageRange[i].ToString() + ".png");
+
+                CPDFPage pdfPage = CurrentDoc.PageAtIndex(args.PageRange[i]);
+                float zoom = (float)(DpiHelpers.Dpi / 72D);
+                int renderWidth = (int)(pdfPage.PageSize.Width * zoom);
+                int renderHeight = (int)(pdfPage.PageSize.Height * zoom);
+                byte[] renderData = new byte[renderWidth * renderHeight * 4];
+                pdfPage.RenderPageBitmapWithMatrix(zoom, new Rect(0, 0, renderWidth, renderHeight), 0xFFFFFFFF, renderData, 0);
+                WriteableBitmap bitmap = new WriteableBitmap(renderWidth, renderHeight, DpiHelpers.Dpi, DpiHelpers.Dpi, PixelFormats.Bgra32, null);
+                bitmap.WritePixels(new Int32Rect(0, 0, renderWidth, renderHeight), renderData, bitmap.BackBufferStride, 0);
+                BitmapEncoder encoder = new PngBitmapEncoder();
+                encoder.Frames.Add(BitmapFrame.Create(bitmap));
+
+                using (FileStream imageStream = File.Create(pageImagePath))
+                {
+                    encoder.Save(imageStream);
+                    imageStream.Flush();
+                }
+
+                //File.Create(pageEnhancePath);
+                //error = imEngine.Process(pageImagePath, pageEnhancePath);
+                error = imEngine.Process(pageImagePath);
+
+                if (imEngine.OCRResultList == null)
+                    return;
+
+                List<KeyValuePair<Rect, string>> RectList = new List<KeyValuePair<Rect, string>>();
+                foreach (COCRResult ocrResult in imEngine.OCRResultList)
+                {
+                    List<Point> rectPoints = new List<Point>();
+                    for (int j = 0; j < ocrResult.position.Length; j += 2)
+                    {
+                        rectPoints.Add(new Point(ocrResult.position[j], ocrResult.position[j + 1]));
+                    }
+                    int left = (int)rectPoints.AsEnumerable().Min(x => x.X);
+                    int right = (int)rectPoints.AsEnumerable().Max(x => x.X);
+                    int top = (int)rectPoints.AsEnumerable().Min(x => x.Y);
+                    int bottom = (int)rectPoints.AsEnumerable().Max(x => x.Y);
+
+                    RectList.Add(new KeyValuePair<Rect, string>(new Rect(left, top, right - left, bottom - top), ocrResult.text));
+                }
+                cacahe.Add(args.PageRange[i], RectList);
+            }
+            if (cacahe.Count > 0)
+            {
+                if (cacahe.ContainsKey(PDFViewer.CurrentIndex))
+                {
+                    TextRectList = cacahe[PDFViewer.CurrentIndex];
+                }
+                else
+                {
+                    TextRectList = null;
+                }
+            }
+            imEngine.Release();
+        }
+    }
+}

+ 1 - 8
PDF Office/ViewModels/Tools/ScanContentViewModel.cs

@@ -184,6 +184,7 @@ namespace PDF_Office.ViewModels.Tools
                         textRectList.Add(new KeyValuePair<Rect, string>(new Rect(left, top, right - left, bottom - top), ocrResult.text));
                     }
 
+                    //写入数据
                     CPDFEditPage editPage = pdfPage.GetEditPage();
 
                     editPage.BeginEdit(CPDFEditType.EditText);
@@ -216,16 +217,8 @@ namespace PDF_Office.ViewModels.Tools
                     throw;
                 }
             }
-            //error = imEngine.Process("C:/test/9.png", "C:/test/9IM.png");
             imEngine.Release();
-            PDFViewer.InvalidChildVisual(true);
             return;
-
-            //更新预览
-            //int PageIndex = PDFViewer.CurrentIndex;
-            //PDFViewer.InitDocument(EnhanceDoc);
-            //PDFViewer.GoToPage(PageIndex);
-
         }
 
     }

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

@@ -69,7 +69,7 @@ namespace PDF_Office.ViewModels.Tools
         private void OpenCompressDialog()
         {
             DialogParameters value = new DialogParameters();
-            value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
+            value.Add(ParameterNames.PDFViewer, PDFViewer);
             dialogs.ShowDialog(DialogNames.CompressDialog, value, e => {  });
         }
         private void MergeDialog()

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

@@ -47,6 +47,11 @@ namespace PDF_Office.ViewModels
         /// </summary>
         public string SplitViewerRegionName { get; set; }
 
+        /// <summary>
+        /// OCR视图名称
+        /// </summary>
+        public string OCRViewerRegionName { get; set; }
+
         public string BOTARegionName { get; set; }
 
         public string PropertyRegionName { get; set; }
@@ -181,6 +186,18 @@ namespace PDF_Office.ViewModels
 
         private Visibility isLoading = Visibility.Collapsed;
 
+        private Visibility ocrContentVisible = Visibility.Collapsed;
+
+        public Visibility OCRContentVisible
+        {
+            get { return ocrContentVisible; }
+            set
+            {
+                SetProperty(ref ocrContentVisible, value);
+            }
+        }
+
+
         /// <summary>
         /// 是否正在加载中
         /// </summary>
@@ -423,6 +440,8 @@ namespace PDF_Office.ViewModels
         public DelegateCommand RedoCommand { get; set; }
         public DelegateCommand<object> MenuEnterReadMode { get; set; }
 
+        public DelegateCommand PrintCommand { get; set; }
+
         #endregion 命令
 
         public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
@@ -448,9 +467,13 @@ namespace PDF_Office.ViewModels
             ReadModeRegionName = RegionNames.ReadModeRegionName;
             MenuEnterReadMode = new DelegateCommand<object>(MenuEnterReadModeEvent);
 
+            PrintCommand = new DelegateCommand(ShowPrintDialog);
+
             //未显示时无法注册上Region名称
             ToolContentVisible = Visibility.Visible;
             ToolsBarContentVisible = Visibility.Visible;
+            OCRContentVisible = Visibility.Visible;
+            OCRViewerRegionName = RegionNames.OCRViewerRegionName;
             ToolContentRegionName = Guid.NewGuid().ToString();
             ToolsBarContentRegionName = Guid.NewGuid().ToString();
             ConverterBarContentRegionName = Guid.NewGuid().ToString();
@@ -458,6 +481,7 @@ namespace PDF_Office.ViewModels
 
             ToolContentVisible = Visibility.Collapsed;
             ToolsBarContentVisible = Visibility.Collapsed;
+            OCRContentVisible = Visibility.Collapsed;
             regionNameByTabItem = new Dictionary<string, string>();
             barContentByTabItem = new Dictionary<string, string>();
             InitialregionNameByTabItem(ref regionNameByTabItem);
@@ -474,6 +498,15 @@ namespace PDF_Office.ViewModels
         {
         }
 
+        public void ShowPrintDialog()
+        {
+            DialogParameters printValue = new DialogParameters();
+            printValue.Add(ParameterNames.PDFViewer, PDFViewer);
+            printValue.Add(ParameterNames.FilePath, PDFViewer.Document.FileName);
+            printValue.Add(ParameterNames.PrintCurrentPage, PDFViewer.CurrentIndex);
+            dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printValue, e => { });
+        }
+
         private void InitialregionNameByTabItem(ref Dictionary<string, string> dictionary)
         {
             dictionary.Add("TabItemPageEdit", ToolContentRegionName);
@@ -505,16 +538,21 @@ namespace PDF_Office.ViewModels
             ToolsBarContentVisible = Visibility.Collapsed;
             ConverterBarContentVisible = Visibility.Collapsed;
             TextEditToolContentVisible = Visibility.Collapsed;
+            OCRContentVisible = Visibility.Collapsed;
 
             switch (currentBar)
             {
                 case "TabItemAnnotation":
-                case "TabItemScan":
+
                 case "TabItemTool":
                 case "TabItemForm":
                 case "TabItemFill":
                     ToolsBarContentVisible = Visibility.Visible;
                     break;
+                case "TabItemScan":
+                    ToolsBarContentVisible = Visibility.Visible;
+                    OCRContentVisible = Visibility.Visible;
+                    break;
 
                 case "TabItemEdit":
                     TextEditToolContentVisible = Visibility.Visible;
@@ -1166,6 +1204,10 @@ namespace PDF_Office.ViewModels
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             param.Add(ParameterNames.ViewContentViewModel, this);
             region.RequestNavigate(regionNameByTabItem[currentBar], barContentByTabItem[currentBar], param);
+            if (currentBar=="TabItemScan")
+            {
+                region.RequestNavigate(RegionNames.OCRViewerRegionName, "ScanViwer", param);
+            }
             ShowContent(currentBar);
         }
 

+ 6 - 0
PDF Office/Views/BOTA/OutLineControl.xaml

@@ -76,7 +76,13 @@
         <Grid Grid.Row="1"
                DragOver="Grid_DragOver"
               DragLeave="Grid_DragLeave">
+            <StackPanel VerticalAlignment="Center" x:Name="NoOutlineStackPanel" Visibility="{Binding Outlinelist.Count, Converter={StaticResource ListCountToVisible}}">
+                <Image Source="pack://application:,,,/PDF Office;component/Resources/BOTA/no_outline.png" />
+                <TextBlock Text="No outline found" FontSize="14" FontFamily="Segoe UI" Height="22" HorizontalAlignment="Center"/>
+                <TextBlock Text="Please right-click on the selected page and select Add Outline, or click the Add button on the upper right to create a outline." Width="168" FontSize="12" FontFamily="Segoe UI" TextWrapping="Wrap" Foreground="#94989C" HorizontalAlignment="Center"/>
+            </StackPanel>
             <TreeView x:Name="OutlineView" Grid.Row="1" ItemsSource="{Binding Outlinelist}" 
+                Visibility="{Binding ElementName=NoOutlineStackPanel,Path=Visibility,Converter={StaticResource UnVisivleConvert}}"
                 BorderThickness="0" AllowDrop="True"
                 VirtualizingPanel.ScrollUnit="Pixel"
                 Drop="OutlineView_Drop"

+ 1 - 1
PDF Office/Views/BOTA/OutLineControl.xaml.cs

@@ -284,7 +284,7 @@ namespace PDF_Office.Views.BOTA
             }
             //开始绘制
             DrawingContext drawDc = imageControl.OpenDraw();
-            WriteableBitmap imageData = (DataContext as OutLineControlViewModel).LoadPreview(outline);
+            WriteableBitmap imageData = (DataContext as OutLineControlViewModel).LoadPreview(outline, (int)imageControl.Width, (int)imageControl.Height);
             if (imageData == null)
             {
                 imageControl.CloseDraw();

File diff suppressed because it is too large
+ 174 - 413
PDF Office/Views/Dialog/CustomCreateDialog.xaml


+ 6 - 0
PDF Office/Views/Dialog/CustomCreateDialog.xaml.cs

@@ -37,5 +37,11 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             (DataContext as CustomCreateDialogViewModel).StampText = (e.OriginalSource as TextBox).Text;
             (DataContext as CustomCreateDialogViewModel).UpDataStamp();
         }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            InPutTextBox.Focus();
+            InPutTextBox.SelectAll();
+        }
     }
 }

+ 71 - 63
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateBaseContent.xaml

@@ -1,65 +1,73 @@
 <UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundCreateBaseContent"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/"             
-             prism:ViewModelLocator.AutoWireViewModel="True"
-              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateBaseContentViewModel}"
-             mc:Ignorable="d"
-             d:DesignHeight="720"
-             d:DesignWidth="260" >
-    <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="40"></RowDefinition>
-            <RowDefinition Height="48"></RowDefinition>
-            <RowDefinition></RowDefinition>
-        </Grid.RowDefinitions>
-        <Grid Grid.Row="0" Visibility="{Binding CreateBaseVisible, Mode=TwoWay}">
-            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
-                <StackPanel Orientation="Horizontal">
-                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
-                    <TextBlock Text="创建背景" FontSize="16"></TextBlock>
-                </StackPanel>
-            </Button>
-            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToTemplateListCommand}">
-                <StackPanel>
-                    <TextBlock Text="保存至模板"  Foreground="#18A0FB"></TextBlock>
-                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
-                </StackPanel>
-            </Button>
-        </Grid>
-        <Grid Grid.Row="0" Visibility="{Binding EditBaseVisible, Mode=TwoWay}">
-            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
-                <StackPanel Orientation="Horizontal">
-                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
-                    <TextBlock Text="编辑模板" FontSize="16"></TextBlock>
-                </StackPanel>
-            </Button>
-            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToCurrentTemplateListCommand}">
-                <StackPanel>
-                    <TextBlock Text="保存"  Foreground="#18A0FB"></TextBlock>
-                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
-                </StackPanel>
-            </Button>
-        </Grid>
-        <Grid Grid.Row="1" Margin="16,0,16,0">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition></ColumnDefinition>
-                <ColumnDefinition></ColumnDefinition>
-            </Grid.ColumnDefinitions>
-            <Button Name="HomePageBackgroundCreateColorContent" Grid.Column="0" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundCreateColorContent}">
-                <StackPanel Orientation="Vertical"  >
-                    <TextBlock Text="颜色" FontSize="18"></TextBlock>
-                </StackPanel>
-            </Button>
-            <Button Name="HomePageBackgroundCreateFileContent" Grid.Column="1" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundCreateFileContent}">
-                <StackPanel Orientation="Vertical"  >
-                    <TextBlock Text="文件" FontSize="18" VerticalAlignment="Center"></TextBlock>
-                </StackPanel>
-            </Button>
-        </Grid>
-        <Grid Grid.Row="2">
-            <ContentControl prism:RegionManager.RegionName="{Binding BackgroundCreateRegionName}" Visibility="{Binding BackgroundCreateVisible}"></ContentControl>
-        </Grid>
-    </Grid>
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateBaseContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="50"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Visibility="{Binding CreateBaseVisible, Mode=TwoWay}">
+            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
+                    <TextBlock Text="创建背景" FontSize="16"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToTemplateListCommand}">
+                <StackPanel>
+                    <TextBlock Text="保存至模板"  Foreground="#18A0FB"></TextBlock>
+                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
+                </StackPanel>
+            </Button>
+        </Grid>
+        
+        <Grid Grid.Row="0" Visibility="{Binding EditBaseVisible, Mode=TwoWay}">
+            <Button  Height="24" Width="90" HorizontalAlignment="Left" Margin="16,0,0,0"  Command="{Binding EnterTemplateListCommand}">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="&lt;" Margin="0,0,9,0" FontSize="16"></TextBlock>
+                    <TextBlock Text="编辑模板" FontSize="16"></TextBlock>
+                </StackPanel>
+            </Button>
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToCurrentTemplateListCommand}">
+                <StackPanel>
+                    <TextBlock Text="保存"  Foreground="#18A0FB"></TextBlock>
+                    <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
+                </StackPanel>
+            </Button>
+        </Grid>
+        <ScrollViewer Grid.Row="1">
+            <Grid Grid.Row="1">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="32"></RowDefinition>
+                    <RowDefinition></RowDefinition>
+                </Grid.RowDefinitions>
+                <Grid Grid.Row="0" Margin="16,0,16,0">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition></ColumnDefinition>
+                        <ColumnDefinition></ColumnDefinition>
+                    </Grid.ColumnDefinitions>
+                    <Button Name="HomePageBackgroundCreateColorContent" Grid.Column="0" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundCreateColorContent}">
+                        <StackPanel Orientation="Vertical"  >
+                            <TextBlock Text="颜色" FontSize="18"></TextBlock>
+                        </StackPanel>
+                    </Button>
+                    <Button Name="HomePageBackgroundCreateFileContent" Grid.Column="1" Command="{Binding ChangeCreateModCommand}" CommandParameter="{Binding ElementName=HomePageBackgroundCreateFileContent}">
+                        <StackPanel Orientation="Vertical"  >
+                            <TextBlock Text="文件" FontSize="18" VerticalAlignment="Center"></TextBlock>
+                        </StackPanel>
+                    </Button>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <ContentControl prism:RegionManager.RegionName="{Binding BackgroundCreateRegionName}" Visibility="{Binding BackgroundCreateVisible}"></ContentControl>
+                </Grid>
+            </Grid>
+        </ScrollViewer>
+    </Grid>
 </UserControl>

+ 136 - 136
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateColorContent.xaml

@@ -1,137 +1,137 @@
 <UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundCreateColorContent"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/"             
-             prism:ViewModelLocator.AutoWireViewModel="True"
-               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateColorContentViewModel}"
-             mc:Ignorable="d"
-             d:DesignHeight="632"
-             d:DesignWidth="260">
-    <UserControl.Resources>
-        <ResourceDictionary>
-            <ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
-            </ResourceDictionary.MergedDictionaries>
-        </ResourceDictionary>
-    </UserControl.Resources>
-    <Grid Margin="16,0,0,0">
-        <Grid.RowDefinitions>
-            <RowDefinition Height="76"></RowDefinition>
-            <RowDefinition Height="156"></RowDefinition>
-            <RowDefinition Height="118"></RowDefinition>
-            <RowDefinition Height="76"></RowDefinition>
-            <RowDefinition></RowDefinition>
-        </Grid.RowDefinitions>
-        <Grid Grid.Row="0" >
-            <StackPanel Orientation="Vertical">
-                <TextBlock Text="背景颜色" Height="20" Width="48" HorizontalAlignment="Left" Margin="0,16,16,8" Foreground="#666666"></TextBlock>
-                <!--<StackPanel Orientation="Horizontal">
-                    <Button Name="RedColorBtn" Height="32" Width="32" Margin="0,0,8,0" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=RedColorBtn}">
-                        <Rectangle Height="22" Width="22" Fill="Red" RadiusX="20" RadiusY="20"></Rectangle>
-                    </Button>
-                    <Button Name="GreenColorBtn" Height="32" Width="32" Margin="0,0,8,0"  Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=GreenColorBtn}">
-                        <Rectangle Height="22" Width="22" Fill="#008000" RadiusX="20" RadiusY="20"></Rectangle>
-
-                    </Button>
-                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
-                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
-                    <Button Height="32" Width="66">
-                        <Grid Height="32" Width="66" HorizontalAlignment="Center" VerticalAlignment="Center">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition></ColumnDefinition>
-                                <ColumnDefinition></ColumnDefinition>
-                            </Grid.ColumnDefinitions>
-                            <Grid Grid.Column="0" Height="22" Width="22">
-                                <Rectangle Fill="{Binding StringColor, Mode=TwoWay}" RadiusX="20" RadiusY="20"></Rectangle>
-                            </Grid>
-                        </Grid>
-                    </Button>
-                </StackPanel>-->
-                <CompositeControl:ColorContent Grid.Row="1" Margin="0,-2,0,0"  x:Name="cusColor"/>
-            </StackPanel>
-        </Grid>
-        <Grid Grid.Row="1">
-            <StackPanel Orientation="Vertical">
-                <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
-                <StackPanel Orientation="Horizontal">
-                    <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0"   Minimum="-360" Maximum="360"  TypeSouce="{Binding RotationList,Mode=TwoWay}" Value="{Binding RotationValue, Mode=TwoWay}" Text="{Binding RotationText,Mode=TwoWay}" ></cus:CommonWritableComboBox>
-
-                    <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" TypeSouce="{Binding OpacityList,Mode=TwoWay}" Value="{Binding OpacityValue,Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}" Loaded="CommonWritableComboBox_Loaded"></cus:CommonWritableComboBox>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal"></StackPanel>
-                <Grid Margin="0,19,0,0">
-
-                    <CheckBox Name="RelativeScaleCheckBox"  Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"  IsChecked="{Binding IsRelativeScaleValue}"></CheckBox>
-                </Grid>
-                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,0,0" TypeSouce="{Binding RelativeRatioList,Mode=TwoWay}" Value="{Binding RelativeRatioValue,Mode=TwoWay}" Text="{Binding RelativeScaleText,Mode=TwoWay}"  IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}" ></cus:CommonWritableComboBox>
-
-
-            </StackPanel>
-
-        </Grid>
-        <Grid  Grid.Row="2" Margin="0,16,0,0">
-            <StackPanel>
-                <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                    <Grid Width="74" Height="74">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition></ColumnDefinition>
-                            <ColumnDefinition></ColumnDefinition>
-                            <ColumnDefinition></ColumnDefinition>
-                        </Grid.ColumnDefinitions>
-                        <Grid.RowDefinitions>
-                            <RowDefinition></RowDefinition>
-                            <RowDefinition></RowDefinition>
-                            <RowDefinition></RowDefinition>
-                        </Grid.RowDefinitions>
-                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
-                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
-                        <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
-                    </Grid>
-                    <StackPanel Orientation="Vertical" Margin="70,0,0,0">
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
-                            <cus:NumericUpDown  Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}" ></cus:NumericUpDown>
-
-                        </StackPanel>
-                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                            <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
-                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
-                        </StackPanel>
-                    </StackPanel>
-
-                </StackPanel>
-                <CheckBox Margin="0,24,0,0" >
-                    <TextBlock Text="平铺" Width="144" Height="22" FontSize="14"/>
-                </CheckBox>
-                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                    <StackPanel Orientation="Horizontal">
-                        <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
-                        <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
-                    </StackPanel>
-                    <StackPanel Orientation="Horizontal" >
-                        <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
-                        <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
-                    </StackPanel>
-                </StackPanel>
-            </StackPanel>
-        </Grid>
-        <Grid Grid.Row="3" Margin="0,16,0,0">
-            <StackPanel Orientation="Vertical">
-                <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
-                <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
-            </StackPanel>
-        </Grid>
-        <Grid Grid.Row="4">
-        </Grid>
-    </Grid>
-</UserControl>
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateColorContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid Margin="16,0,0,0">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="76"></RowDefinition>
+            <RowDefinition Height="156"></RowDefinition>
+            <RowDefinition Height="118"></RowDefinition>
+            <RowDefinition Height="76"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" >
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="背景颜色" Height="20" Width="48" HorizontalAlignment="Left" Margin="0,16,16,8" Foreground="#666666"></TextBlock>
+                <!--<StackPanel Orientation="Horizontal">
+                    <Button Name="RedColorBtn" Height="32" Width="32" Margin="0,0,8,0" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=RedColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="Red" RadiusX="20" RadiusY="20"></Rectangle>
+                    </Button>
+                    <Button Name="GreenColorBtn" Height="32" Width="32" Margin="0,0,8,0"  Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=GreenColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="#008000" RadiusX="20" RadiusY="20"></Rectangle>
+
+                    </Button>
+                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
+                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
+                    <Button Height="32" Width="66">
+                        <Grid Height="32" Width="66" HorizontalAlignment="Center" VerticalAlignment="Center">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid Grid.Column="0" Height="22" Width="22">
+                                <Rectangle Fill="{Binding StringColor, Mode=TwoWay}" RadiusX="20" RadiusY="20"></Rectangle>
+                            </Grid>
+                        </Grid>
+                    </Button>
+                </StackPanel>-->
+                <CompositeControl:ColorContent Grid.Row="1" Margin="0,-2,0,0"  x:Name="cusColor"/>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1">
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0"   Minimum="-360" Maximum="360"  TypeSouce="{Binding RotationList,Mode=TwoWay}" Value="{Binding RotationValue, Mode=TwoWay}" Text="{Binding RotationText,Mode=TwoWay}" ></cus:CommonWritableComboBox>
+
+                    <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" TypeSouce="{Binding OpacityList,Mode=TwoWay}" Value="{Binding OpacityValue,Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}" Loaded="CommonWritableComboBox_Loaded"></cus:CommonWritableComboBox>
+                </StackPanel>
+                <StackPanel Orientation="Horizontal"></StackPanel>
+                <Grid Margin="0,19,0,0">
+
+                    <CheckBox Name="RelativeScaleCheckBox"  Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"  IsChecked="{Binding IsRelativeScaleValue}"></CheckBox>
+                </Grid>
+                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,0,0" TypeSouce="{Binding RelativeRatioList,Mode=TwoWay}" Value="{Binding RelativeRatioValue,Mode=TwoWay}" Text="{Binding RelativeScaleText,Mode=TwoWay}"  IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}" ></cus:CommonWritableComboBox>
+
+
+            </StackPanel>
+
+        </Grid>
+        <Grid  Grid.Row="2" Margin="0,16,0,0">
+            <StackPanel>
+                <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <Grid Width="74" Height="74">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition></ColumnDefinition>
+                            <ColumnDefinition></ColumnDefinition>
+                            <ColumnDefinition></ColumnDefinition>
+                        </Grid.ColumnDefinitions>
+                        <Grid.RowDefinitions>
+                            <RowDefinition></RowDefinition>
+                            <RowDefinition></RowDefinition>
+                            <RowDefinition></RowDefinition>
+                        </Grid.RowDefinitions>
+                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
+                    </Grid>
+                    <StackPanel Orientation="Vertical" Margin="70,0,0,0">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown  Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}" ></cus:NumericUpDown>
+
+                        </StackPanel>
+                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                            <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
+                        </StackPanel>
+                    </StackPanel>
+
+                </StackPanel>
+                <CheckBox Margin="0,24,0,0" >
+                    <TextBlock Text="平铺" Width="144" Height="22" FontSize="14"/>
+                </CheckBox>
+                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                        <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                        <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                    </StackPanel>
+                </StackPanel>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="3" Margin="0,16,0,0">
+            <StackPanel Orientation="Vertical">
+                <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="4">
+        </Grid>
+    </Grid>
+</UserControl>

+ 106 - 106
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundCreateFileContent.xaml

@@ -1,107 +1,107 @@
 <UserControl x:Class="PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground.HomePageBackgroundCreateFileContent"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/"             
-             prism:ViewModelLocator.AutoWireViewModel="True"
-              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateFileContentViewModel}"
-             mc:Ignorable="d"
-             d:DesignHeight="632"
-             d:DesignWidth="260">
-    <UserControl.Resources>
-        <ResourceDictionary>
-            <ResourceDictionary.MergedDictionaries>
-                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
-            </ResourceDictionary.MergedDictionaries>
-        </ResourceDictionary>
-    </UserControl.Resources>
-    <Grid Margin="16,0,0,0">
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="58*"/>
-            <ColumnDefinition Width="3*"/>
-        </Grid.ColumnDefinitions>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="48"></RowDefinition>
-            <RowDefinition Height="423"></RowDefinition>
-            <RowDefinition></RowDefinition>
-        </Grid.RowDefinitions>
-        <Grid Grid.Row="0" Grid.ColumnSpan="2">
-            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
-                <TextBox Height="32" Width="189" Margin="0,0,7,0" IsReadOnly="True"  Text="{Binding FileNameText}" FontSize="14" VerticalAlignment="Center"></TextBox>
-                <Button Height="32" Width="32" Command="{Binding OpenFileCommand}"></Button>
-            </StackPanel>
-        </Grid>
-        <Grid Grid.Row="1" Visibility="{Binding CreateModFileVisible}" Grid.ColumnSpan="2">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="157"></RowDefinition>
-                <RowDefinition Height="163"></RowDefinition>
-                <RowDefinition Height="103"></RowDefinition>
-                <RowDefinition></RowDefinition>
-            </Grid.RowDefinitions>
-            <Grid Grid.Row="0">
-                <StackPanel Orientation="Vertical">
-                    <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
-                    <StackPanel Orientation="Horizontal">
-                        <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
-                        <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Text="{Binding RotationText,Mode=TwoWay}" Value="{Binding RotationValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
-                        <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
-                        <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding OpacityList, Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}"  Value="{Binding OpacityValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
-                    </StackPanel>
-                    <StackPanel Orientation="Horizontal"></StackPanel>
-                    <Grid Margin="0,19,0,0">
-                        <CheckBox Name="RelativeScaleCheckBox"  Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"  IsChecked="{Binding IsRelativeScaleValue}"></CheckBox>
-                    </Grid>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RelativeRatioList, Mode=TwoWay}" Value="{Binding RelativeRatioValue,Mode=TwoWay}"   Text="{Binding RelativeScaleText,Mode=TwoWay}"  IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}"></cus:CommonWritableComboBox>
-                </StackPanel>
-            </Grid>
-            <Grid  Grid.Row="1" Margin="0,16,0,0" VerticalAlignment="Bottom">
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="3*"/>
-                    <ColumnDefinition Width="241*"/>
-                </Grid.ColumnDefinitions>
-                <StackPanel Grid.ColumnSpan="2">
-                    <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                        <Grid Width="74" Height="74">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition></ColumnDefinition>
-                                <ColumnDefinition></ColumnDefinition>
-                                <ColumnDefinition></ColumnDefinition>
-                            </Grid.ColumnDefinitions>
-                            <Grid.RowDefinitions>
-                                <RowDefinition></RowDefinition>
-                                <RowDefinition></RowDefinition>
-                                <RowDefinition></RowDefinition>
-                            </Grid.RowDefinitions>
-                            <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
-                            <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
-                            <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
-                        </Grid>
-                        <StackPanel Orientation="Vertical" Margin="70,0,0,0">
-                            <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
-                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
-                            </StackPanel>
-                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                                <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
-                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
-                            </StackPanel>
-                        </StackPanel>
-                    </StackPanel>
-                </StackPanel>
-            </Grid>
-            <Grid Grid.Row="2" Margin="0,16,0,0" VerticalAlignment="Bottom">
-                <StackPanel Orientation="Vertical">
-                    <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
-                    <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
-                </StackPanel>
-            </Grid>
-        </Grid>
-    </Grid>
-</UserControl>
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundCreateFileContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../../../Styles/CheckBoxStyle.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid Margin="16,0,0,0">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="58*"/>
+            <ColumnDefinition Width="3*"/>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="48"></RowDefinition>
+            <RowDefinition Height="423"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="0" Grid.ColumnSpan="2">
+            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
+                <TextBox Height="32" Width="189" Margin="0,0,7,0" IsReadOnly="True"  Text="{Binding FileNameText}" FontSize="14" VerticalAlignment="Center"></TextBox>
+                <Button Height="32" Width="32" Command="{Binding OpenFileCommand}"></Button>
+            </StackPanel>
+        </Grid>
+        <Grid Grid.Row="1" Visibility="{Binding CreateModFileVisible}" Grid.ColumnSpan="2">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="157"></RowDefinition>
+                <RowDefinition Height="163"></RowDefinition>
+                <RowDefinition Height="103"></RowDefinition>
+                <RowDefinition></RowDefinition>
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
+                        <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Text="{Binding RotationText,Mode=TwoWay}" Value="{Binding RotationValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                        <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
+                        <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding OpacityList, Mode=TwoWay}" Text="{Binding OpacityText,Mode=TwoWay}"  Value="{Binding OpacityValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal"></StackPanel>
+                    <Grid Margin="0,19,0,0">
+                        <CheckBox Name="RelativeScaleCheckBox"  Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"  IsChecked="{Binding IsRelativeScaleValue}"></CheckBox>
+                    </Grid>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RelativeRatioList, Mode=TwoWay}" Value="{Binding RelativeRatioValue,Mode=TwoWay}"   Text="{Binding RelativeScaleText,Mode=TwoWay}"  IsEnabled="{Binding ElementName=RelativeScaleCheckBox,Path=IsChecked}"></cus:CommonWritableComboBox>
+                </StackPanel>
+            </Grid>
+            <Grid  Grid.Row="1" Margin="0,16,0,0" VerticalAlignment="Bottom">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="3*"/>
+                    <ColumnDefinition Width="241*"/>
+                </Grid.ColumnDefinitions>
+                <StackPanel Grid.ColumnSpan="2">
+                    <TextBlock Text="位置" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
+                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                        <Grid Width="74" Height="74">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                                <ColumnDefinition></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition></RowDefinition>
+                                <RowDefinition></RowDefinition>
+                                <RowDefinition></RowDefinition>
+                            </Grid.RowDefinitions>
+                            <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                            <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
+                        </Grid>
+                        <StackPanel Orientation="Vertical" Margin="70,0,0,0">
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
+                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
+                            </StackPanel>
+                        </StackPanel>
+                    </StackPanel>
+                </StackPanel>
+            </Grid>
+            <Grid Grid.Row="2" Margin="0,16,0,0" VerticalAlignment="Bottom">
+                <StackPanel Orientation="Vertical">
+                    <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                    <cus:WritableComboBox  Height="32" Width="228" Margin="0,8,0,0" HorizontalAlignment="Left" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+                </StackPanel>
+            </Grid>
+        </Grid>
+    </Grid>
+</UserControl>

+ 24 - 11
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml

@@ -19,7 +19,7 @@
     <Grid IsEnabled="{Binding BackgroundGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
-            <ColumnDefinition Width="260*"/>
+            <ColumnDefinition Width="260*" MaxWidth="260"/>
         </Grid.ColumnDefinitions>
         <Grid Grid.Column="0">
             <Grid.RowDefinitions>
@@ -44,19 +44,31 @@
                     </ListView.ContextMenu>
                     <ListView.View>
                         <GridView>
-                            <GridViewColumn  Header="文档名"  Width="400" DisplayMemberBinding="{Binding FileName}"/>
-                            <GridViewColumn Header="页面范围" Width="170" >
+                            <GridViewColumn  Header="文档名"  Width="234" DisplayMemberBinding="{Binding FileName}"/>
+                            <GridViewColumn Header="页面范围" Width="156" >
                                 <GridViewColumn.CellTemplate>
                                     <DataTemplate>
-                                        <cus:WritableComboBox Height="24" Width="140" Margin="0,8,0,0" Text="{Binding FilePageRangeText,Mode=TwoWay}" SelectedIndex="{Binding FilePageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+                                        <cus:WritableComboBox Height="24" Width="140" Margin="0,8,0,0" Text="{Binding FilePageRangeText,Mode=TwoWay}" SelectedIndex="{Binding FilePageRangeSelectIndex,Mode=TwoWay}" EvenPageIsEnabled="{Binding IsEvenPageIsEnabled,Mode=TwoWay}" LostFocus="PageRangeWritableComboBox_LostFocus"></cus:WritableComboBox>
                                     </DataTemplate>
                                 </GridViewColumn.CellTemplate>
                             </GridViewColumn>
-                            <GridViewColumn Header="大小" Width="100" DisplayMemberBinding="{Binding FileSize}"/>
+                            <GridViewColumn Header="大小" Width="68" DisplayMemberBinding="{Binding FileSize}"/>
                             <GridViewColumn Header="状态" Width="80" >
                                 <GridViewColumn.CellTemplate>
                                     <DataTemplate>
-                                        <TextBlock Text="{Binding FileState}" TextDecorations="Underline" Foreground="Black"/>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="{Binding FileState}" Width="14" Height="14" TextDecorations="Underline" Foreground="Black"/>
+                                            <Button Name="DeleteTemplateBtn" Width="14" Height="14" Content="X" Foreground="Red" FontSize="8" VerticalAlignment="Center" Margin="38,0,0,0" Click="DeleteTemplateBtn_Click">
+                                            </Button>
+                                        </StackPanel>
+                                        <DataTemplate.Triggers>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="True">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                                            </DataTrigger>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="False">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Hidden"/>
+                                            </DataTrigger>
+                                        </DataTemplate.Triggers>
                                     </DataTemplate>
                                 </GridViewColumn.CellTemplate>
                             </GridViewColumn>
@@ -123,14 +135,15 @@
         </Grid>
         <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetBackgroundGridIsEnabled}">
             <Grid.RowDefinitions>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="72"/>
+
+                <RowDefinition Height="536"/>
+                <RowDefinition Height="64"/>
             </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Background="#F3F3F3">
+            <Grid Grid.Row="0" Grid.RowSpan="{Binding CreateGridSpan}" Background="#F3F3F3" >
                 <ContentControl prism:RegionManager.RegionName="{Binding BackgroundSettingsRegionName}" Visibility="{Binding BackgroundSettingsVisible}"></ContentControl>
             </Grid>
-            <Grid Grid.Row="1">
-                <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
+            <Grid Grid.Row="1" Visibility="{Binding CreateGridSpanVisibility}">
+                <Button Height="32" Width="228" Background="Black" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>
             </Grid>

+ 46 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialog.xaml.cs

@@ -1,9 +1,15 @@
-using PDF_Office.Helper;
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
 using Prism.Ioc;
 using Prism.Regions;
 using System;
 using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Interop;
@@ -145,5 +151,44 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
             }
 
         }
+
+        private void PageRangeWritableComboBox_LostFocus(object sender, RoutedEventArgs e)
+        {
+            WritableComboBox writableComboBox = sender as WritableComboBox;
+            var ls = writableComboBox.DataContext as DataRowView;
+            if (ls != null)
+            {
+                List<int> PageIndexLists = new List<int>();
+                var index = viewModel.PDFDataTable.Rows.IndexOf(ls.Row);
+                viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeSelectIndex"] = writableComboBox.SelectedIndex.ToString();
+                //viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"] = writableComboBox.Text;
+                if (viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, viewModel.PDFDataTable.Rows[index]["FilePageRangeText"].ToString().ToString(), CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[index]).PageCount, new char[] { ',' }, new char[] { '-' }, true))
+                {
+                    viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeSelectIndex"] = "0";
+                    if (viewModel.PDFDataTable.Rows[index]["FilePageRangeText"].ToString() != "")
+                    {
+                        if (viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"].ToString() != viewModel.PDFDataTable.Rows[index]["FilePageRangeText"].ToString())
+                        {
+                            viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"] = writableComboBox.SelectedIndex.ToString();
+                            viewModel.updateListview("待确定");
+                        }
+                    }
+
+
+                }
+                viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"] = writableComboBox.Text;
+            }
+            //viewModel.updateListview("待确定");
+        }
+        private void DeleteTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            Button deletetemplatebtn = sender as Button;
+            var ls = deletetemplatebtn.DataContext as DataRowView;
+            if (ls != null)
+            {
+                viewModel.removepdffile(viewModel.PDFDataTable.Rows.IndexOf(ls.Row));
+            }
+        }
     }
 }
+

+ 1 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListColorContent.xaml

@@ -27,6 +27,7 @@
 
     <Grid Background="#F3F3F3">
         <ListBox           Width="240" 
+                           
                                 BorderThickness="0"
                                 ScrollViewer.CanContentScroll="True"
                                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"

+ 1 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundTemplateListFileContent.xaml

@@ -28,6 +28,7 @@
     <Grid Background="#F3F3F3">
         <ListBox
                                 Width="240" 
+            
                                 BorderThickness="0"
                                 ScrollViewer.CanContentScroll="True"
                                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"

+ 117 - 111
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesCreateContent.xaml

@@ -9,7 +9,7 @@
              xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
              xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
              mc:Ignorable="d"
-             d:DesignHeight="720"
+             d:DesignHeight="751"
              d:DesignWidth="260" >
     <UserControl.Resources>
         <ResourceDictionary >
@@ -20,7 +20,7 @@
     </UserControl.Resources>
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="50"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
         <Grid Grid.Row="0" Visibility="{Binding CreateBaseVisible, Mode=TwoWay}">
@@ -51,132 +51,138 @@
                 </StackPanel>
             </Button>
         </Grid>
-        <Grid Grid.Row="1">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="116"></RowDefinition>
-                <RowDefinition Height="116"></RowDefinition>
-                <RowDefinition Height="189"></RowDefinition>
-                <RowDefinition Height="172"></RowDefinition>
-                <RowDefinition></RowDefinition>
-            </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Margin="0,16,0,0" Width="228">
-                <StackPanel>
-                    <TextBlock Text="外观" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                        <ComboBox Width="154" Height="32"  ItemsSource="{Binding FontNameList}" SelectedIndex="{Binding FontNameSelectedIndex}"></ComboBox>
-                        <ComboBox Width="66" Height="32" Margin="8,0,0,0" ItemsSource="{Binding FontSizeList}" SelectedIndex="{Binding FontSizeSelectedIndex}"></ComboBox>
+        <ScrollViewer  Grid.Row="1" >
+            <Grid Grid.Row="1">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="104"></RowDefinition>
+                    <RowDefinition Height="120"></RowDefinition>
+                    <RowDefinition Height="200"></RowDefinition>
+                    <RowDefinition Height="173"></RowDefinition>
+                    <RowDefinition ></RowDefinition>
+                </Grid.RowDefinitions>
+                <Grid Grid.Row="0"  Width="228">
+                    <StackPanel>
+                        <TextBlock Text="外观" FontFamily="Segoe UI" FontStyle="Normal" FontSize="12" Height="20" Width="228" HorizontalAlignment="Left" Foreground="#616469"></TextBlock>
+                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                            <ComboBox Width="228" Height="32"  ItemsSource="{Binding FontNameList}" SelectedIndex="{Binding FontNameSelectedIndex}"></ComboBox>
+
+                        </StackPanel>
+                        <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                            <ComboBox Width="164" Height="32" HorizontalAlignment="Left" ItemsSource="{Binding FontSizeList}" SelectedIndex="{Binding FontSizeSelectedIndex}"></ComboBox>
+                            <CompositeControl:ColorContent x:Name="cusColor" Height="32" Width="56"  Margin="8,0,0,0"  HorizontalAlignment="Left">
+                            </CompositeControl:ColorContent>
+                        </StackPanel>
                     </StackPanel>
-                    <CompositeControl:ColorContent x:Name="cusColor" Height="32" Width="66"  Margin="0,8,0,0"  HorizontalAlignment="Left">
-                    </CompositeControl:ColorContent>
-                </StackPanel>
-            </Grid>
-            <Grid Grid.Row="1" Margin="0,16,0,0" Width="228">
-                <StackPanel>
-                    <TextBlock Text="页边距" FontSize="12" Foreground="#666666" Height="20" Width="36" HorizontalAlignment="Left"></TextBlock>
-                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                        <StackPanel Orientation="Vertical" Margin="0,0,0,0">
-                            <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="上"  Width="14" Height="20" VerticalAlignment="Center"/>
-                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0" Text="{Binding MarginTopValue,Mode=TwoWay}"></cus:NumericUpDown>
+                </Grid>
+                <Grid Grid.Row="1" Margin="0,18,0,0" Width="228">
+                    <StackPanel>
+                        <TextBlock Text="页边距" FontFamily="Segoe UI" FontStyle="Normal" FontSize="12" Height="20" Width="228" HorizontalAlignment="Left" Foreground="#616469"></TextBlock>
+                        <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
+                            <StackPanel Orientation="Vertical" Margin="0,0,0,0">
+                                <StackPanel Orientation="Horizontal">
+                                    <TextBlock Text="上"  Width="14" Height="20" VerticalAlignment="Center"/>
+                                    <cus:NumericUpDown Width="90" Height="32" Margin="4,0,0,0" Text="{Binding MarginTopValue,Mode=TwoWay}"></cus:NumericUpDown>
+                                </StackPanel>
+                                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                    <TextBlock Text="左" Width="14" Height="20" VerticalAlignment="Center"/>
+                                    <cus:NumericUpDown Width="90" Height="32" Margin="4,0,0,0"  Text="{Binding MarginLeftValue,Mode=TwoWay}"></cus:NumericUpDown>
+                                </StackPanel>
                             </StackPanel>
-                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                                <TextBlock Text="左" Width="14" Height="20" VerticalAlignment="Center"/>
-                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginLeftValue,Mode=TwoWay}"></cus:NumericUpDown>
+                            <StackPanel Orientation="Vertical" Margin="8,0,0,0">
+                                <StackPanel Orientation="Horizontal">
+                                    <TextBlock Text="下"  Width="14" Height="20" VerticalAlignment="Center"/>
+                                    <cus:NumericUpDown Width="90" Height="32" Margin="4,0,0,0"  Text="{Binding MarginDownValue,Mode=TwoWay}"></cus:NumericUpDown>
+                                </StackPanel>
+                                <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
+                                    <TextBlock Text="右" Width="14" Height="20" VerticalAlignment="Center"/>
+                                    <cus:NumericUpDown Width="90" Height="32" Margin="4,0,0,0"  Text="{Binding MarginRightValue,Mode=TwoWay}"></cus:NumericUpDown>
+                                </StackPanel>
                             </StackPanel>
                         </StackPanel>
-                        <StackPanel Orientation="Vertical" Margin="51,0,0,0">
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2" Margin="0,18,0,0" Width="228">
+                    <StackPanel>
+                        <TextBlock Text="Page Number &amp; Date Format" Height="20" Width="228" FontFamily="Segoe UI" FontStyle="Normal" FontSize="12" Foreground="#616469"></TextBlock>
+                        <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
+                            <TextBlock Text="前缀" FontSize="12" Foreground="#666666" Height="22" Width="38" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
+                            <TextBox Name="PrefixTextValueTextBox" Height="32" Width="180" Margin="10,0,0,0">
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="TextChanged">
+                                        <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=PrefixTextValueTextBox}" />
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </TextBox>
+                        </StackPanel>
+                        <StackPanel Margin="0,8,0,0" Orientation="Horizontal">
+                            <TextBlock Text="后缀" FontSize="12" Foreground="#666666" Height="22" Width="38" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
+                            <TextBox Name="SuffixTextValueTextBox" Width="180" Height="32" Margin="10,0,0,0">
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="TextChanged">
+                                        <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=SuffixTextValueTextBox}" />
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </TextBox>
+                        </StackPanel>
+                        <StackPanel Orientation="Vertical" Margin="0,8,0,0">
                             <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="下"  Width="14" Height="20" VerticalAlignment="Center"/>
-                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginDownValue,Mode=TwoWay}"></cus:NumericUpDown>
+                                <TextBlock Text="位数" FontSize="12" Foreground="#666666" Height="22" Width="116" HorizontalAlignment="Left"></TextBlock>
+                                <cus:NumericUpDown Height="32" Width="102" Margin="10,0,0,0" Text="{Binding DigitNumberValue,Mode=TwoWay}"></cus:NumericUpDown>
                             </StackPanel>
-                            <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                                <TextBlock Text="右" Width="14" Height="20" VerticalAlignment="Center"/>
-                                <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding MarginRightValue,Mode=TwoWay}"></cus:NumericUpDown>
+                            <StackPanel Margin="0,8,0,0" Orientation="Horizontal">
+                                <TextBlock Text="起始页" FontSize="12" Foreground="#666666" Height="22" Width="66" HorizontalAlignment="Left"></TextBlock>
+                                <ComboBox Height="32" Width="152" Margin="10,0,0,0" ItemsSource="{Binding StarPagetNumberList}" SelectedIndex="{Binding StarPagetNumberIndex}"></ComboBox>
                             </StackPanel>
                         </StackPanel>
                     </StackPanel>
-                </StackPanel>
-            </Grid>
-            <Grid Grid.Row="2" Margin="0,16,0,0" Width="228">
-                <StackPanel>
+                </Grid>
+                <Grid Grid.Row="3" Margin="0,18,0,0" Width="228">
                     <StackPanel>
-                        <TextBlock Text="前缀" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                        <TextBox Name="PrefixTextValueTextBox" Height="32">
-                            <i:Interaction.Triggers>
-                                <i:EventTrigger EventName="TextChanged">
-                                    <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=PrefixTextValueTextBox}" />
-                                </i:EventTrigger>
-                            </i:Interaction.Triggers>
-                        </TextBox>
-                    </StackPanel>
-                    <StackPanel Margin="0,8,0,0">
-                        <TextBlock Text="后缀" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                        <TextBox Name="SuffixTextValueTextBox" Height="32">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="布局&amp;内容"  FontFamily="Segoe UI" FontStyle="Normal" FontSize="12" Height="20" Width="198" Foreground="#616469"></TextBlock>
+                            <Button Width="22" Height="22" Margin="8,0,0,0" Click="Button_Click" >
+                                <TextBlock Text="+" FontSize="19" HorizontalAlignment="Center" VerticalAlignment="Center"  Block.TextAlignment="Center" ></TextBlock>
+                                <Button.ContextMenu>
+                                    <ContextMenu Name="contextMenu">
+                                        <MenuItem Name="ADDPages" Header="插入Bates" Click="ADDBates_Click" >
+                                        </MenuItem>
+                                    </ContextMenu>
+                                </Button.ContextMenu>
+                            </Button>
+                        </StackPanel>
+                        <Grid Width="228" Height="46" Margin="0,6,0,0">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="76"></ColumnDefinition>
+                                <ColumnDefinition Width="76"></ColumnDefinition>
+                                <ColumnDefinition Width="76"></ColumnDefinition>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="23"></RowDefinition>
+                                <RowDefinition Height="23"></RowDefinition>
+                            </Grid.RowDefinitions>
+                            <RadioButton Grid.Column="0" Grid.Row="0" Tag="0" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                            <RadioButton Grid.Column="1" Grid.Row="0" Tag="1" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                            <RadioButton Grid.Column="2" Grid.Row="0" Tag="2" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
+                            <RadioButton Grid.Column="0" Grid.Row="1" Tag="3" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
+                            <RadioButton Grid.Column="1" Grid.Row="1" Tag="4" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  ></RadioButton>
+                            <RadioButton Grid.Column="2" Grid.Row="1" Tag="5" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
+                        </Grid>
+                        <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0" Text="{Binding TextValue}"  Foreground="{Binding SolidColorBrush}" FontSize="14"  AcceptsReturn="True" FontFamily="Segoe UI">
                             <i:Interaction.Triggers>
                                 <i:EventTrigger EventName="TextChanged">
-                                    <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=SuffixTextValueTextBox}" />
+                                    <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=TextValueTextBox}" />
                                 </i:EventTrigger>
                             </i:Interaction.Triggers>
                         </TextBox>
                     </StackPanel>
-                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
-                        <StackPanel>
-                            <TextBlock Text="位数" FontSize="12" Foreground="#666666" Height="20" Width="24" HorizontalAlignment="Left"></TextBlock>
-                            <cus:NumericUpDown Height="32" Width="110" Text="{Binding DigitNumberValue,Mode=TwoWay}"></cus:NumericUpDown>
-                        </StackPanel>
-                        <StackPanel Margin="8,0,0,0">
-                            <TextBlock Text="起始页" FontSize="12" Foreground="#666666" Height="20" Width="36" HorizontalAlignment="Left"></TextBlock>
-                            <ComboBox Height="32" Width="110" ItemsSource="{Binding StarPagetNumberList}" SelectedIndex="{Binding StarPagetNumberIndex}"></ComboBox>
-                        </StackPanel>
-                    </StackPanel>
-                </StackPanel>
-            </Grid>
-            <Grid Grid.Row="3" Margin="0,16,0,0" Width="228">
-                <StackPanel>
-                    <StackPanel Orientation="Horizontal">
-                        <TextBlock Text="布局&amp;内容" FontSize="12" Foreground="#666666" Height="20" Width="60"></TextBlock>
-                        <Button Width="22" Height="22" Margin="146,0,0,0" Click="Button_Click" >
-                            <TextBlock Text="+" FontSize="19" HorizontalAlignment="Center" VerticalAlignment="Center"  Block.TextAlignment="Center" ></TextBlock>
-                            <Button.ContextMenu>
-                                <ContextMenu Name="contextMenu">
-                                    <MenuItem Name="ADDPages" Header="插入Bates" Click="ADDBates_Click" >
-                                    </MenuItem>
-                                </ContextMenu>
-                            </Button.ContextMenu>
-                        </Button>
+                </Grid>
+                <Grid Grid.Row="4" Margin="0,16,0,0" Width="228">
+                    <StackPanel>
+                        <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
+                        <cus:WritableComboBox Height="32" Margin="0,8,0,0" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
                     </StackPanel>
-                    <Grid Width="228" Height="46" Margin="0,6,0,0">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="76"></ColumnDefinition>
-                            <ColumnDefinition Width="76"></ColumnDefinition>
-                            <ColumnDefinition Width="76"></ColumnDefinition>
-                        </Grid.ColumnDefinitions>
-                        <Grid.RowDefinitions>
-                            <RowDefinition Height="23"></RowDefinition>
-                            <RowDefinition Height="23"></RowDefinition>
-                        </Grid.RowDefinitions>
-                        <RadioButton Grid.Column="0" Grid.Row="0" Tag="0" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
-                        <RadioButton Grid.Column="1" Grid.Row="0" Tag="1" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
-                        <RadioButton Grid.Column="2" Grid.Row="0" Tag="2" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" ></RadioButton>
-                        <RadioButton Grid.Column="0" Grid.Row="1" Tag="3" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
-                        <RadioButton Grid.Column="1" Grid.Row="1" Tag="4" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  ></RadioButton>
-                        <RadioButton Grid.Column="2" Grid.Row="1" Tag="5" GroupName="TextLocation" Height="23" Width="76" BorderThickness="1" BorderBrush="Black" Style="{StaticResource LocationRadioBtnStyle}" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"></RadioButton>
-                    </Grid>
-                    <TextBox Name="TextValueTextBox" Height="72" Margin="0,8,0,0" Text="{Binding TextValue}"  Foreground="{Binding SolidColorBrush}" FontSize="14"  AcceptsReturn="True">
-                        <i:Interaction.Triggers>
-                            <i:EventTrigger EventName="TextChanged">
-                                <i:InvokeCommandAction Command="{Binding TextValueChangedCommand}" CommandParameter="{Binding ElementName=TextValueTextBox}" />
-                            </i:EventTrigger>
-                        </i:Interaction.Triggers>
-                    </TextBox>
-                </StackPanel>
+                </Grid>
             </Grid>
-            <Grid Grid.Row="4" Margin="0,16,0,0" Width="228">
-                <StackPanel>
-                    <TextBlock Text="页面范围" FontSize="12" Foreground="#666666" Height="20" Width="48" HorizontalAlignment="Left"></TextBlock>
-                    <cus:WritableComboBox Height="32" Margin="0,8,0,0" Text="{Binding PageRangeText,Mode=TwoWay}" SelectedIndex="{Binding PageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
-                </StackPanel>
-            </Grid>
-        </Grid>
+        </ScrollViewer>
     </Grid>
 </UserControl>

+ 29 - 14
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml

@@ -19,12 +19,12 @@
     <Grid IsEnabled="{Binding BatesGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
-            <ColumnDefinition Width="260*"/>
+            <ColumnDefinition Width="260*" MaxWidth="260"/>
         </Grid.ColumnDefinitions>
-        <Grid Grid.Column="0">
+        <Grid Grid.Column="0" >
             <Grid.RowDefinitions>
                 <RowDefinition Height="556*"/>
-                <RowDefinition Height="64*"/>
+                <RowDefinition Height="64*" />
             </Grid.RowDefinitions>
             <Grid  Grid.Row="0" AllowDrop="True"
                   Drop="Grid_Drop"
@@ -44,19 +44,31 @@
                     </ListView.ContextMenu>
                     <ListView.View>
                         <GridView>
-                            <GridViewColumn  Header="文档名"  Width="230" DisplayMemberBinding="{Binding FileName}"/>
-                            <GridViewColumn Header="页面范围" Width="170" >
+                            <GridViewColumn  Header="文档名"  Width="234" DisplayMemberBinding="{Binding FileName}"/>
+                            <GridViewColumn Header="页面范围" Width="156" >
                                 <GridViewColumn.CellTemplate>
                                     <DataTemplate>
-                                        <cus:WritableComboBox Height="24" Width="140" Margin="0,8,0,0" Text="{Binding FilePageRangeText,Mode=TwoWay}" SelectedIndex="{Binding FilePageRangeSelectIndex,Mode=TwoWay}"></cus:WritableComboBox>
+                                        <cus:WritableComboBox x:Name="PageRangeWritableComboBox" Height="24" Width="140" Margin="0,8,0,0" Text="{Binding FilePageRangeText,Mode=TwoWay}" SelectedIndex="{Binding FilePageRangeSelectIndex,Mode=TwoWay}"  EvenPageIsEnabled="{Binding IsEvenPageIsEnabled,Mode=TwoWay}" LostFocus="PageRangeWritableComboBox_LostFocus"></cus:WritableComboBox>
                                     </DataTemplate>
                                 </GridViewColumn.CellTemplate>
                             </GridViewColumn>
-                            <GridViewColumn Header="大小" Width="100" DisplayMemberBinding="{Binding FileSize}"/>
+                            <GridViewColumn Header="大小" Width="68" DisplayMemberBinding="{Binding FileSize}"/>
                             <GridViewColumn Header="状态" Width="80" >
                                 <GridViewColumn.CellTemplate>
                                     <DataTemplate>
-                                        <TextBlock Text="{Binding FileState}" TextDecorations="Underline" Foreground="Black"/>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="{Binding FileState}" Width="14" Height="14" TextDecorations="Underline" Foreground="Black"/>
+                                            <Button Name="DeleteTemplateBtn" Width="14" Height="14" Content="X" Foreground="Red" FontSize="8" VerticalAlignment="Center" Margin="38,0,0,0" Click="DeleteTemplateBtn_Click">
+                                            </Button>
+                                        </StackPanel>
+                                        <DataTemplate.Triggers>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="True">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                                            </DataTrigger>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="False">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Hidden"/>
+                                            </DataTrigger>
+                                        </DataTemplate.Triggers>
                                     </DataTemplate>
                                 </GridViewColumn.CellTemplate>
                             </GridViewColumn>
@@ -123,14 +135,17 @@
         </Grid>
         <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetBatesGridIsEnabled}">
             <Grid.RowDefinitions>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="72"/>
+                <RowDefinition Height="536"/>
+                <RowDefinition Height="64"/>
             </Grid.RowDefinitions>
-            <Grid Grid.Row="0" Background="#F3F3F3">
-                <ContentControl prism:RegionManager.RegionName="{Binding BatesSettingsRegionName}" Visibility="{Binding BatesSettingsVisible}"></ContentControl>
+
+            <Grid Grid.Row="0" Grid.RowSpan="{Binding CreateGridSpan}" Background="#F3F3F3">
+
+                <ContentControl prism:RegionManager.RegionName="{Binding BatesSettingsRegionName}" Visibility="{Binding BatesSettingsVisible}" ></ContentControl>
+
             </Grid>
-            <Grid Grid.Row="1">
-                <Button Height="40" Width="228" Background="Black" Command="{Binding CreateCommand}">
+            <Grid Grid.Row="1" Visibility="{Binding CreateGridSpanVisibility}">
+                <Button Height="32" Width="228" Background="#1770F4" Command="{Binding CreateCommand}">
                     <TextBlock Text="Apply" FontSize="18" Foreground="White"/>
                 </Button>
             </Grid>

+ 52 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialog.xaml.cs

@@ -1,12 +1,19 @@
-using PDF_Office.Helper;
+using ComPDFKit.PDFDocument;
+using PDF_Office.CustomControl;
+using PDF_Office.Helper;
+using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
 using Prism.Ioc;
 using Prism.Regions;
 using System;
 using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Interop;
+using System.Windows.Media;
 
 namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
@@ -32,16 +39,21 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
             menuPop1.IsOpen = true;
         }
 
+
+
         private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             IList list = listView.SelectedItems;
+
             var lists = listView.Items;
             System.Data.DataRowView a;
             viewModel.fileNamesView.Clear();
             foreach (var item in list)
             {
+
                 a = (System.Data.DataRowView)item;
                 viewModel.fileNamesView.Add(lists.IndexOf(a));
+
             }
             if (viewModel.fileNamesView.Count > 0)
             {
@@ -145,5 +157,44 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.H
             }
 
         }
+
+        private void PageRangeWritableComboBox_LostFocus(object sender, RoutedEventArgs e)
+        {
+            WritableComboBox writableComboBox = sender as WritableComboBox;
+            var ls = writableComboBox.DataContext as DataRowView;
+            if (ls != null)
+            {
+                List<int> PageIndexLists = new List<int>();
+                var index = viewModel.PDFDataTable.Rows.IndexOf(ls.Row);
+                viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeSelectIndex"] = writableComboBox.SelectedIndex.ToString();
+                //viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"] = writableComboBox.Text;
+                if (viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, viewModel.PDFDataTable.Rows[index]["FilePageRangeText"].ToString().ToString(), CPDFDocument.InitWithFilePath(HomePageBatchProcessingDialogModel.FilePaths[index]).PageCount, new char[] { ',' }, new char[] { '-' }, true))
+                {
+                    viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeSelectIndex"] = "0";
+                    if (viewModel.PDFDataTable.Rows[index]["FilePageRangeText"].ToString() != "")
+                    {
+                        if (viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"].ToString() != viewModel.PDFDataTable.Rows[index]["FilePageRangeText"].ToString())
+                        {
+                            viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"] = writableComboBox.Text;
+                            viewModel.updateListview("待确定");
+                        }
+                    }
+
+
+                }
+                viewModel.PDFCurrentDataTable.Rows[index]["FilePageRangeText"] = writableComboBox.Text;
+            }
+            //viewModel.updateListview("待确定");
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            Button deletetemplatebtn = sender as Button;
+            var ls = deletetemplatebtn.DataContext as DataRowView;
+            if (ls != null)
+            {
+                viewModel.removepdffile(viewModel.PDFDataTable.Rows.IndexOf(ls.Row));
+            }
+        }
     }
 }

+ 2 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesTemplateListContent.xaml

@@ -26,7 +26,7 @@
     </UserControl.Resources>
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="50"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
         <Grid Grid.Row="0">
@@ -39,6 +39,7 @@
         <Grid Background="#F3F3F3" Grid.Row="1">
             <ListBox
                                 Width="260" 
+                
                                 BorderThickness="0"
                                 ScrollViewer.CanContentScroll="True"
                                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"

+ 20 - 7
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml

@@ -18,7 +18,7 @@
     <Grid IsEnabled="{Binding CompressGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
-            <ColumnDefinition Width="260*"/>
+            <ColumnDefinition Width="260*" MaxWidth="260"/>
         </Grid.ColumnDefinitions>
         <Grid Grid.Column="0">
             <Grid.RowDefinitions>
@@ -43,15 +43,28 @@
                     </ListView.ContextMenu>
                     <ListView.View>
                         <GridView>
-                            <GridViewColumn  Header="文档名"  Width="400" DisplayMemberBinding="{Binding FileName}"/>
-                            <GridViewColumn Header="大小" Width="100" DisplayMemberBinding="{Binding FileSize}"/>
+                            <GridViewColumn  Header="文档名"  Width="390" DisplayMemberBinding="{Binding FileName}"/>
+                            <GridViewColumn Header="大小" Width="68" DisplayMemberBinding="{Binding FileSize}"/>
                             <GridViewColumn Header="状态" Width="80" >
                                 <GridViewColumn.CellTemplate>
                                     <DataTemplate>
-                                        <TextBlock Text="{Binding FileState}" TextDecorations="Underline" Foreground="Black"/>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="{Binding FileState}" Width="14" Height="14" TextDecorations="Underline" Foreground="Black"/>
+                                            <Button Name="DeleteTemplateBtn" Width="14" Height="14" Content="X" Foreground="Red" FontSize="8" VerticalAlignment="Center" Margin="38,0,0,0" Click="DeleteTemplateBtn_Click">
+                                            </Button>
+                                        </StackPanel>
+                                        <DataTemplate.Triggers>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="True">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                                            </DataTrigger>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="False">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Hidden"/>
+                                            </DataTrigger>
+                                        </DataTemplate.Triggers>
                                     </DataTemplate>
                                 </GridViewColumn.CellTemplate>
                             </GridViewColumn>
+                            
                         </GridView>
                     </ListView.View>
                     <ListView.ItemContainerStyle>
@@ -115,8 +128,8 @@
         </Grid>
         <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetCompressGridIsEnabled}">
             <Grid.RowDefinitions>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="72"/>
+                <RowDefinition Height="536*"/>
+                <RowDefinition Height="64*" MaxHeight="64"/>
             </Grid.RowDefinitions>
             <StackPanel Orientation="Vertical" Margin="16,14,0,0" Grid.Row="0">
                 <TextBlock Text="优化选项" FontSize="14" Width="228" Height=" 22" FontFamily="Segoe UI" TextBlock.Foreground="#252629"  HorizontalAlignment="Left"/>
@@ -135,7 +148,7 @@
                 </RadioButton>
             </StackPanel>
             <Grid Grid.Row="2">
-                <Button Height="40" Width="228" Background="Black" Command="{Binding CompressCommand}">
+                <Button Height="32" Width="228" Background="Black" Command="{Binding CompressCommand}">
                     <TextBlock Text="压缩" FontSize="18" Foreground="White"/>
                 </Button>
             </Grid>

+ 10 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml.cs

@@ -3,6 +3,7 @@ using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs;
 using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using System;
 using System.Collections;
+using System.Data;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Interop;
@@ -137,6 +138,15 @@ namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
             }
 
         }
+        private void DeleteTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            Button deletetemplatebtn = sender as Button;
+            var ls = deletetemplatebtn.DataContext as DataRowView;
+            if (ls != null)
+            {
+                viewModel.removepdffile(viewModel.PDFDataTable.Rows.IndexOf(ls.Row));
+            }
+        }
 
     }
 }

+ 28 - 8
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialog.xaml

@@ -2,6 +2,7 @@
             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:cus="clr-namespace:PDF_Office.CustomControl"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:prism="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
@@ -18,7 +19,7 @@
     <Grid IsEnabled="{Binding ConverterGridIsEnabled}">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="558*"/>
-            <ColumnDefinition Width="260*"/>
+            <ColumnDefinition Width="260*" MaxWidth="260"/>
         </Grid.ColumnDefinitions>
         <Grid Grid.Column="0">
             <Grid.RowDefinitions>
@@ -43,12 +44,31 @@
                     </ListView.ContextMenu>
                     <ListView.View>
                         <GridView>
-                            <GridViewColumn  Header="文档名"  Width="400" DisplayMemberBinding="{Binding FileName}"/>
-                            <GridViewColumn Header="大小" Width="100" DisplayMemberBinding="{Binding FileSize}"/>
+                            <GridViewColumn  Header="文档名"  Width="234" DisplayMemberBinding="{Binding FileName}"/>
+                            <GridViewColumn Header="页面范围" Width="156" >
+                                <GridViewColumn.CellTemplate>
+                                    <DataTemplate>
+                                        <cus:WritableComboBox Height="24" Width="140" Margin="0,8,0,0" Text="{Binding FilePageRangeText,Mode=TwoWay}" SelectedIndex="{Binding FilePageRangeSelectIndex,Mode=TwoWay}" EvenPageIsEnabled="{Binding IsEvenPageIsEnabled,Mode=TwoWay}" LostFocus="PageRangeWritableComboBox_LostFocus"></cus:WritableComboBox>
+                                    </DataTemplate>
+                                </GridViewColumn.CellTemplate>
+                            </GridViewColumn>
+                            <GridViewColumn Header="大小" Width="68" DisplayMemberBinding="{Binding FileSize}"/>
                             <GridViewColumn Header="状态" Width="80" >
                                 <GridViewColumn.CellTemplate>
                                     <DataTemplate>
-                                        <TextBlock Text="{Binding FileState}" TextDecorations="Underline" Foreground="Black"/>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="{Binding FileState}" Width="14" Height="14" TextDecorations="Underline" Foreground="Black"/>
+                                            <Button Name="DeleteTemplateBtn" Width="14" Height="14" Content="X" Foreground="Red" FontSize="8" VerticalAlignment="Center" Margin="38,0,0,0" Click="DeleteTemplateBtn_Click">
+                                            </Button>
+                                        </StackPanel>
+                                        <DataTemplate.Triggers>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="True">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                                            </DataTrigger>
+                                            <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="False">
+                                                <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Hidden"/>
+                                            </DataTrigger>
+                                        </DataTemplate.Triggers>
                                     </DataTemplate>
                                 </GridViewColumn.CellTemplate>
                             </GridViewColumn>
@@ -115,13 +135,13 @@
         </Grid>
         <Grid Grid.Column="1" Background="WhiteSmoke" IsEnabled="{Binding SetConverterGridIsEnabled}">
             <Grid.RowDefinitions>
-                <RowDefinition Height="*"/>
-                <RowDefinition Height="72"/>
+                <RowDefinition Height="536*"/>
+                <RowDefinition Height="64*"  MaxHeight="64"/>
             </Grid.RowDefinitions>
             <StackPanel Orientation="Vertical" Margin="15,16,0,0" Grid.Row="0">
                 <StackPanel Orientation="Vertical">
                     <TextBlock Text="转档格式"/>
-                    <ComboBox Name="ConverterTypeComboBox"  Margin="0,6,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" ItemsSource="{Binding ConverterTypeFamily}" SelectedIndex="0"  SelectionChanged="ConverterTypeComboBox_SelectionChanged">
+                    <ComboBox Name="ConverterTypeComboBox"  Margin="0,6,0,0" Width="228" Height="28.55" HorizontalAlignment="Left" ItemsSource="{Binding ConverterTypeFamily}" SelectedIndex="{Binding ConverterTypeIndex}"  SelectionChanged="ConverterTypeComboBox_SelectionChanged">
                     </ComboBox>
                 </StackPanel>
                 <ContentControl Margin="0,18,0,0" x:Name="PrintMod" prism:RegionManager.RegionName="{Binding ConverterRegionName}"   Visibility="{Binding ConverterVisible}"/>
@@ -135,7 +155,7 @@
                 </StackPanel>
             </StackPanel>
             <Grid Grid.Row="2">
-                <Button Height="40" Width="228" Background="Black" Command="{Binding ConvertCommand}">
+                <Button Height="32" Width="228" Background="Black" Command="{Binding ConvertCommand}">
                     <TextBlock Text="转档" FontSize="18" Foreground="White"/>
                 </Button>
             </Grid>

+ 0 - 0
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialog.xaml.cs


Some files were not shown because too many files changed in this diff