liyijie 2 yıl önce
ebeveyn
işleme
585793c12c

+ 67 - 1
PDF Office/ViewModels/EditTools/Bates/BatesCreateContentViewModel.cs

@@ -1,16 +1,71 @@
-using Prism.Commands;
+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;
 using System.Collections.Generic;
 using System.Linq;
+using System.Windows;
+using PDFSettings;
 
 namespace PDF_Office.ViewModels.EditTools.Bates
 {
     public class BatesCreateContentViewModel : BindableBase, INavigationAware
     {
+        private CPDFViewer PDFViewer;
+
+        public BatesHeaderFooterItem BatesItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        private EnumCreateOrEdit _createOrEdit;
+        public EnumCreateOrEdit CreateOrEdit
+        {
+            get { return _createOrEdit; }
+            set
+            {
+                _createOrEdit = value;
+                if (value == EnumCreateOrEdit.StatusEdit)
+                {
+                    EditBaseVisible = Visibility.Visible;
+                    CreateBaseVisible = Visibility.Collapsed;
+                }
+                else if (value == EnumCreateOrEdit.StatusCreate)
+                {
+                    CreateBaseVisible = Visibility.Visible;
+                    EditBaseVisible = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private Visibility _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
         public IEventAggregator eventAggregator;
+
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+
         public string Unicode = null;
 
         public BatesCreateContentViewModel(IEventAggregator eventAggregator)
@@ -30,6 +85,17 @@ namespace PDF_Office.ViewModels.EditTools.Bates
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("BatesItem", out BatesItem))
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+            }
+            else
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
         }
+
+
     }
 }

+ 1 - 1
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterContentViewModel.cs

@@ -134,7 +134,7 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
             BatesHeaderFooterItem headerfooterItem = headerfooterItemunicode.Status;
             NavigationParameters param = new NavigationParameters();
             param.Add(ParameterNames.PDFViewer, PDFViewer);
-            param.Add("BatesItem", headerfooterItem);
+            param.Add("HeaderFooterItem", headerfooterItem);
             headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
             HeaderFooterSettingsVisible = Visibility.Visible;
         }

+ 85 - 1
PDF Office/ViewModels/EditTools/HeaderFooter/HeaderFooterCreateContentViewModel.cs

@@ -1,22 +1,97 @@
-using Prism.Commands;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.EventAggregators;
+using PDF_Office.Model;
+using PDFSettings;
+using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Windows;
 
 namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 {
     public class HeaderFooterCreateContentViewModel : BindableBase, INavigationAware
     {
+
+        private CPDFViewer PDFViewer;
+
+        public BatesHeaderFooterItem HeaderFooterItem;
+
+        public enum EnumCreateOrEdit
+        {
+            None,
+            StatusCreate,
+            StatusEdit
+        }
+
+        private EnumCreateOrEdit _createOrEdit;
+        public EnumCreateOrEdit CreateOrEdit
+        {
+            get { return _createOrEdit; }
+            set
+            {
+                _createOrEdit = value;
+                if (value == EnumCreateOrEdit.StatusEdit)
+                {
+                    EditBaseVisible = Visibility.Visible;
+                    CreateBaseVisible = Visibility.Collapsed;
+                }
+                else if (value == EnumCreateOrEdit.StatusCreate)
+                {
+                    CreateBaseVisible = Visibility.Visible;
+                    EditBaseVisible = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private Visibility _createBaseVisible;
+        public Visibility CreateBaseVisible
+        {
+            get => _createBaseVisible;
+            set => SetProperty(ref _createBaseVisible, value);
+        }
+
+        private Visibility _editBaseVisible;
+        public Visibility EditBaseVisible
+        {
+            get => _editBaseVisible;
+            set => SetProperty(ref _editBaseVisible, value);
+        }
+
         public IEventAggregator eventAggregator;
+
+        public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
+
         public string Unicode = null;
         public HeaderFooterCreateContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
+            EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
         }
+
+        public void EnterTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
+        public void SaveToCurrentTemplateList()
+        {
+            this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -28,6 +103,15 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out HeaderFooterItem))
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusEdit;
+            }
+            else
+            {
+                CreateOrEdit = EnumCreateOrEdit.StatusCreate;
+            }
         }
     }
 }

+ 3 - 3
PDF Office/ViewModels/EditTools/Watermark/WatermarkDocumentContentViewModel.cs

@@ -146,12 +146,13 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                     }
                 }
             }
+
             viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
         }
 
         public void DeleteWatermark(EnumDeleteUnicode enumDeleteunicode)
         {
-            if (EnumDelete == EnumDelete.StatusDeleteAll)
+            if (enumDeleteunicode.Status == EnumDelete.StatusDeleteAll || enumDeleteunicode.Status == EnumDelete.StatusDeleteInitial)
             {
                 EnumDelete enumDelete = enumDeleteunicode.Status;
                 EnumDelete = enumDelete;
@@ -165,8 +166,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         {
             WatermarkInfo watermarkInfo = watermarkInfounicode.Status;
             this.watermarkInfo = watermarkInfo;
-            EnumDelete = EnumDelete.StatusCreate;
-            //CreateWatermark(viewContentViewModel.PDFViewer.Document);
+            CreateWatermark(viewContentViewModel.PDFViewer.Document);
             // PDFViewer.Document.PdfToImage("0-1", "C:\\Users\\kdanmobile\\Desktop\\888\\");
             //viewContentViewModel.PDFViewer.Document.WriteToFilePath("C:\\Users\\kdanmobile\\Desktop\\888\\sb22222_.pdf");
             PDFViewer.InvalidChildVisual(false);

+ 50 - 50
PDF Office/Views/EditTools/Bates/BatesCreateContent.xaml

@@ -1,56 +1,56 @@
 <UserControl x:Class="PDF_Office.Views.EditTools.Bates.BatesCreateContent"
-              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:i="http://schemas.microsoft.com/xaml/behaviors"
-             xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
-             mc:Ignorable="d"
-             d:DesignHeight="720"
-             d:DesignWidth="260" >
-    <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="40"></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="创建Bates" 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>
+              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:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             mc:Ignorable="d"
+             d:DesignHeight="720"
+             d:DesignWidth="260" >
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></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="创建Bates" 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">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="116"></RowDefinition>
-                <RowDefinition Height="116"></RowDefinition>
-                <RowDefinition Height="189"></RowDefinition>
-                <RowDefinition Height="172"></RowDefinition>
-                <RowDefinition></RowDefinition>
+            <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>