liyijie 2 년 전
부모
커밋
fdf74df7d8

+ 7 - 4
PDF Office/App.config

@@ -17,10 +17,13 @@
     </assemblyBinding>
   </runtime>
   <userSettings>
-    <PDF_Office.Properties.Settings>
-      <setting name="BackgroundIndex" serializeAs="String">
-        <value>0</value>
-      </setting>
+    <PDF_Office.Properties.Settings>
+        <setting name="BackgroundIndex" serializeAs="String">
+            <value>0</value>
+        </setting>
+        <setting name="WatermarkIndex" serializeAs="String">
+            <value>0</value>
+        </setting>
     </PDF_Office.Properties.Settings>
   </userSettings>
 </configuration>

+ 127 - 104
PDF Office/Properties/Settings.Designer.cs

@@ -1,104 +1,127 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     此代码由工具生成。
-//     运行时版本:4.0.30319.42000
-//
-//     对此文件的更改可能会导致不正确的行为,并且如果
-//     重新生成代码,这些更改将会丢失。
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace PDF_Office.Properties {
-    
-    
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
-        
-        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-        
-        public static Settings Default {
-            get {
-                return defaultInstance;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        public global::PDFSettings.Settings.RecentOpenFiles RecentOpenFiles {
-            get {
-                return ((global::PDFSettings.Settings.RecentOpenFiles)(this["RecentOpenFiles"]));
-            }
-            set {
-                this["RecentOpenFiles"] = value;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        public global::PDFSettings.DefaultAnnotProperties DefautAnnotProperties {
-            get {
-                return ((global::PDFSettings.DefaultAnnotProperties)(this["DefautAnnotProperties"]));
-            }
-            set {
-                this["DefautAnnotProperties"] = value;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        public global::PDFSettings.APPSettingProperties AppProperties {
-            get {
-                return ((global::PDFSettings.APPSettingProperties)(this["AppProperties"]));
-            }
-            set {
-                this["AppProperties"] = value;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        public global::PDFSettings.AllPDFToolsList AllPDFToolsList {
-            get {
-                return ((global::PDFSettings.AllPDFToolsList)(this["AllPDFToolsList"]));
-            }
-            set {
-                this["AllPDFToolsList"] = value;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        public global::PDFSettings.QuickPDFToolsList QuickPDFToolsList {
-            get {
-                return ((global::PDFSettings.QuickPDFToolsList)(this["QuickPDFToolsList"]));
-            }
-            set {
-                this["QuickPDFToolsList"] = value;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        public global::PDFSettings.BackgroundTemplateList BackgroundTemplateList {
-            get {
-                return ((global::PDFSettings.BackgroundTemplateList)(this["BackgroundTemplateList"]));
-            }
-            set {
-                this["BackgroundTemplateList"] = value;
-            }
-        }
-        
-        [global::System.Configuration.UserScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("0")]
-        public int BackgroundIndex {
-            get {
-                return ((int)(this["BackgroundIndex"]));
-            }
-            set {
-                this["BackgroundIndex"] = value;
-            }
-        }
-    }
-}
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace PDF_Office.Properties {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+        
+        public static Settings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.Settings.RecentOpenFiles RecentOpenFiles {
+            get {
+                return ((global::PDFSettings.Settings.RecentOpenFiles)(this["RecentOpenFiles"]));
+            }
+            set {
+                this["RecentOpenFiles"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.DefaultAnnotProperties DefautAnnotProperties {
+            get {
+                return ((global::PDFSettings.DefaultAnnotProperties)(this["DefautAnnotProperties"]));
+            }
+            set {
+                this["DefautAnnotProperties"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.APPSettingProperties AppProperties {
+            get {
+                return ((global::PDFSettings.APPSettingProperties)(this["AppProperties"]));
+            }
+            set {
+                this["AppProperties"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.AllPDFToolsList AllPDFToolsList {
+            get {
+                return ((global::PDFSettings.AllPDFToolsList)(this["AllPDFToolsList"]));
+            }
+            set {
+                this["AllPDFToolsList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.QuickPDFToolsList QuickPDFToolsList {
+            get {
+                return ((global::PDFSettings.QuickPDFToolsList)(this["QuickPDFToolsList"]));
+            }
+            set {
+                this["QuickPDFToolsList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.BackgroundTemplateList BackgroundTemplateList {
+            get {
+                return ((global::PDFSettings.BackgroundTemplateList)(this["BackgroundTemplateList"]));
+            }
+            set {
+                this["BackgroundTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int BackgroundIndex {
+            get {
+                return ((int)(this["BackgroundIndex"]));
+            }
+            set {
+                this["BackgroundIndex"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::PDFSettings.WatermarkTemplateList WatermarkTemplateList {
+            get {
+                return ((global::PDFSettings.WatermarkTemplateList)(this["WatermarkTemplateList"]));
+            }
+            set {
+                this["WatermarkTemplateList"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public int WatermarkIndex {
+            get {
+                return ((int)(this["WatermarkIndex"]));
+            }
+            set {
+                this["WatermarkIndex"] = value;
+            }
+        }
+    }
+}

+ 32 - 26
PDF Office/Properties/Settings.settings

@@ -1,27 +1,33 @@
-<?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PDF_Office.Properties" GeneratedClassName="Settings">
-  <Profiles />
-  <Settings>
-    <Setting Name="RecentOpenFiles" Type="PDFSettings.Settings.RecentOpenFiles" Scope="User">
-      <Value Profile="(Default)" />
-    </Setting>
-    <Setting Name="DefautAnnotProperties" Type="PDFSettings.DefaultAnnotProperties" Scope="User">
-      <Value Profile="(Default)" />
-    </Setting>
-    <Setting Name="AppProperties" Type="PDFSettings.APPSettingProperties" Scope="User">
-      <Value Profile="(Default)" />
-    </Setting>
-    <Setting Name="AllPDFToolsList" Type="PDFSettings.AllPDFToolsList" Scope="User">
-      <Value Profile="(Default)" />
-    </Setting>
-    <Setting Name="QuickPDFToolsList" Type="PDFSettings.QuickPDFToolsList" Scope="User">
-      <Value Profile="(Default)" />
-    </Setting>
-    <Setting Name="BackgroundTemplateList" Type="PDFSettings.BackgroundTemplateList" Scope="User">
-      <Value Profile="(Default)" />
-    </Setting>
-    <Setting Name="BackgroundIndex" Type="System.Int32" Scope="User">
-      <Value Profile="(Default)">0</Value>
-    </Setting>
-  </Settings>
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PDF_Office.Properties" GeneratedClassName="Settings">
+  <Profiles />
+  <Settings>
+    <Setting Name="RecentOpenFiles" Type="PDFSettings.Settings.RecentOpenFiles" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="DefautAnnotProperties" Type="PDFSettings.DefaultAnnotProperties" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="AppProperties" Type="PDFSettings.APPSettingProperties" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="AllPDFToolsList" Type="PDFSettings.AllPDFToolsList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="QuickPDFToolsList" Type="PDFSettings.QuickPDFToolsList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="BackgroundTemplateList" Type="PDFSettings.BackgroundTemplateList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="BackgroundIndex" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
+    <Setting Name="WatermarkTemplateList" Type="PDFSettings.WatermarkTemplateList" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="WatermarkIndex" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
+  </Settings>
 </SettingsFile>

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

@@ -39,7 +39,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
 
         public bool firstin = true;
 
-        public string ViwerRegionName { get; set; }
+        public string ViewerRegionName { get; set; }
 
         private ImageSource _imageSource = null;
         public ImageSource ImageSource
@@ -56,7 +56,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             this.regionManager = regionManager;
             this.eventAggregator = eventAggregator;
             eventAggregator.GetEvent<SetWatermarkEvent>().Subscribe(SetWatermark);
-            ViwerRegionName = RegionNames.WatermarkViwerRegionName;
+            ViewerRegionName = RegionNames.WatermarkViwerRegionName;
 
         }
 
@@ -188,14 +188,14 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
             if (pdfViewer != null)
             {
-                if (!regionManager.Regions[ViwerRegionName].Views.Contains(PDFViewer))
+                if (!regionManager.Regions[ViewerRegionName].Views.Contains(PDFViewer))
                 {
                     PDFViewer = new CPDFViewer();
                     PDFViewer.InitDocument(pdfViewer.Document.FilePath);
                     Document = PDFViewer.Document;
                     PDFViewer.CustomDrawHandler += CurrentViewer_CustomDrawHandler;
                     PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
-                    regionManager.AddToRegion(ViwerRegionName, PDFViewer);
+                    regionManager.AddToRegion(ViewerRegionName, PDFViewer);
                     PDFViewer.SetAnnotInteraction(!PDFViewer.GetAnnotInteraction());
                     PDFViewer.Load();
                     PDFViewer.ChangeViewMode(ViewMode.Single);

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

@@ -1,18 +1,133 @@
-using Prism.Commands;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
+using System.Windows;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
     public class WatermarkTemplateListFileContentViewModel : BindableBase, INavigationAware
     {
+       
+        public ObservableCollection<WatermarkItem> watermarkModFileCollection = new ObservableCollection<WatermarkItem>();
+        public ObservableCollection<WatermarkItem> WatermarkModFileCollection
+        {
+            get { return watermarkModFileCollection; }
+            set
+            {
+                watermarkModFileCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+
         public WatermarkTemplateListFileContentViewModel()
         {
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+        }
+
+        private void CheckTemplateListIsEmpty(List<WatermarkItem> watermarkTemplateList)
+        {
+            if (watermarkTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetWatermarkSource()
+        {
+            List<WatermarkItem> watermarkModTextTemplateList = new List<WatermarkItem>();
+            for (int temp = 0; temp < Settings.Default.WatermarkTemplateList.Count; temp++)
+            {
+                if (Settings.Default.WatermarkTemplateList[temp].type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+
+
+                    watermarkModTextTemplateList.Add(Settings.Default.WatermarkTemplateList[temp]);
+                }
+            }
+            WatermarkModFileCollection = new ObservableCollection<WatermarkItem>(watermarkModTextTemplateList);
+            CheckTemplateListIsEmpty(watermarkModTextTemplateList);
+        }
+
+
+
+        private void InitWatermarkTemplateList()
+        {
+            if (Settings.Default.WatermarkTemplateList == null)
+            {
+                Settings.Default.WatermarkTemplateList = new WatermarkTemplateList();
+            }
+            GetWatermarkSource();
+        }
+
+        private void UpdateWatermarkSources()
+        {
+            List<WatermarkItem> watermarkModTextTemplateList = new List<WatermarkItem>();
+            for (int temp = 0; temp < Settings.Default.WatermarkTemplateList.Count; temp++)
+            {
+                if (Settings.Default.WatermarkTemplateList[temp].type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG)
+                {
+                    watermarkModTextTemplateList.Add(Settings.Default.WatermarkTemplateList[temp]);
+                }
+            }
+            WatermarkModFileCollection = new ObservableCollection<WatermarkItem>(watermarkModTextTemplateList);
+            CheckTemplateListIsEmpty(watermarkModTextTemplateList);
+        }
+
+        public void AddTemplate()
+        {
+            var watermarkItem = new WatermarkItem();
+            watermarkItem.pageRange = "0";
+            watermarkItem.type = ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_IMG;
+            watermarkItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            Settings.Default.WatermarkTemplateList.Add(watermarkItem);
+            Settings.Default.Save();
+            UpdateWatermarkSources();
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            var template = btn.DataContext as WatermarkItem;
+            if (template == null)
+            {
+                return;
+            }
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.previeImagePath);
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.imagepath);
+
+            Settings.Default.WatermarkTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            WatermarkModFileCollection.Remove(template);
+            UpdateWatermarkSources();
 
         }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;

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

@@ -1,18 +1,132 @@
-using Prism.Commands;
+using PDFSettings;
+using Prism.Commands;
 using Prism.Mvvm;
 using Prism.Regions;
+using System.Windows;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
+using PDF_Office.Properties;
 
 namespace PDF_Office.ViewModels.EditTools.Watermark
 {
     public class WatermarkTemplateListTextContentViewModel : BindableBase, INavigationAware
     {
+        public ObservableCollection<WatermarkItem> watermarkModTextCollection = new ObservableCollection<WatermarkItem>();
+        public ObservableCollection<WatermarkItem> WatermarkModTextCollection
+        {
+            get { return watermarkModTextCollection; }
+            set
+            {
+                watermarkModTextCollection = value;
+                RaisePropertyChanged();
+            }
+        }
+
+        private Visibility _createTemplateVisible;
+        public Visibility CreateTemplateVisible
+        {
+            get { return _createTemplateVisible; }
+            set { SetProperty(ref _createTemplateVisible, value); }
+        }
+
+        public DelegateCommand AddTemplateCommand { get; set; }
+        public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+
         public WatermarkTemplateListTextContentViewModel()
         {
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+        }
+
+        private void CheckTemplateListIsEmpty(List<WatermarkItem>watermarkTemplateList)
+        {
+            if (watermarkTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetWatermarkSource()
+        {
+            List<WatermarkItem>watermarkModTextTemplateList = new List<WatermarkItem>();
+            for (int temp = 0; temp < Settings.Default.WatermarkTemplateList.Count; temp++)
+            {
+                if (Settings.Default.WatermarkTemplateList[temp].type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                   
 
+                   watermarkModTextTemplateList.Add(Settings.Default.WatermarkTemplateList[temp]);
+                }
+            }
+           WatermarkModTextCollection = new ObservableCollection<WatermarkItem>(watermarkModTextTemplateList);
+            CheckTemplateListIsEmpty(watermarkModTextTemplateList);
         }
+
+
+
+        private void InitWatermarkTemplateList()
+        {
+            if (Settings.Default.WatermarkTemplateList == null)
+            {
+                Settings.Default.WatermarkTemplateList = new WatermarkTemplateList();
+            }
+            GetWatermarkSource();
+        }
+
+        private void UpdateWatermarkSources()
+        {
+            List<WatermarkItem>watermarkModTextTemplateList = new List<WatermarkItem>();
+            for (int temp = 0; temp < Settings.Default.WatermarkTemplateList.Count; temp++)
+            {
+                if (Settings.Default.WatermarkTemplateList[temp].type == ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_TEXT)
+                {
+                   watermarkModTextTemplateList.Add(Settings.Default.WatermarkTemplateList[temp]);
+                }
+            }
+           WatermarkModTextCollection = new ObservableCollection<WatermarkItem>(watermarkModTextTemplateList);
+            CheckTemplateListIsEmpty(watermarkModTextTemplateList);
+        }
+
+        public void AddTemplate()
+        {
+            var watermarkItem = new WatermarkItem();
+            watermarkItem.pageRange = "0";
+            watermarkItem.type = ComPDFKit.PDFWatermark.C_Watermark_Type.WATERMARK_TYPE_TEXT;
+            watermarkItem.templateName += Settings.Default.WatermarkIndex.ToString();
+            Settings.Default.WatermarkTemplateList.Add(watermarkItem);
+            Settings.Default.Save();
+            UpdateWatermarkSources();
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            var template = btn.DataContext as WatermarkItem;
+            if (template == null)
+            {
+                return;
+            }
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.previeImagePath);
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.imagepath);
+
+            Settings.Default.WatermarkTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            WatermarkModTextCollection.Remove(template);
+            UpdateWatermarkSources();
+
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -24,6 +138,7 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
+            InitWatermarkTemplateList();
         }
     }
 }

+ 1 - 1
PDF Office/Views/EditTools/Watermark/WatermarkDocumentContent.xaml

@@ -12,7 +12,7 @@
         <ContentControl
                 x:Name="PDFViewerContent"
                 HorizontalAlignment="Stretch"
-                prism:RegionManager.RegionName="{Binding ViwerRegionName}" />
+                prism:RegionManager.RegionName="{Binding ViewerRegionName}" />
         <Border  Height="64" Width="293" HorizontalAlignment="Center"  VerticalAlignment="Bottom"  Panel.ZIndex="1" Margin="9" Background="#323232" CornerRadius="4">
             <Grid>
                 <StackPanel Orientation="Horizontal"  VerticalAlignment="Center">

+ 65 - 13
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListFileContent.xaml

@@ -1,14 +1,66 @@
 <UserControl x:Class="PDF_Office.Views.EditTools.Watermark.WatermarkTemplateListFileContent"
-             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" 
-             mc:Ignorable="d"
-             d:DesignHeight="632"
-             d:DesignWidth="260" >
-    <Grid Background="DeepPink">
-            
-    </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:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkTemplateListFileContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <Grid Background="#F3F3F3">
+        <ListBox Name="FileWatermarkListbox" 
+                                Width="240" 
+                                BorderThickness="0"
+                                ScrollViewer.CanContentScroll="True"
+                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                                ScrollViewer.VerticalScrollBarVisibility="Hidden"
+                                VirtualizingPanel.IsVirtualizing="True"
+                                VirtualizingPanel.VirtualizationMode="Standard"
+                                VirtualizingPanel.CacheLengthUnit="Page"
+                                VirtualizingPanel.CacheLength="1"
+                                VirtualizingPanel.ScrollUnit="Pixel"   
+                                Background="#F3F3F3"
+                 ItemsSource="{Binding WatermarkModFileCollection}">
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="ListBoxItem">
+                    <Setter Property="Margin" Value="0"/>
+                    <Setter Property="Padding" Value="8 0 8 0"/>
+                    <!--<Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>-->
+                    <Setter Property="Template" Value="{DynamicResource ListBoxItemControlTemplate}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="{x:Type data:WatermarkItem}">
+                    <StackPanel Name="itemPanel" >
+                        <Grid Height="160" Width=" 128" Background="Blue">
+                            <Label  Height="160" Width=" 128"></Label>
+                            <Label  Height="160" Width=" 128"></Label>
+                            <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom"></Button>
+                            <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
+                            </Button>
+                        </Grid>
+                    </StackPanel>
+                    <DataTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="False">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                        </Trigger>
+                    </DataTemplate.Triggers>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Grid Width="140" Margin="64,154,56,312" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
+            <StackPanel Orientation="Vertical">
+                <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
+                <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 10 - 1
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListFileContent.xaml.cs

@@ -1,4 +1,6 @@
-using System.Windows.Controls;
+using ComPDFKitViewer;
+using PDF_Office.ViewModels.EditTools.Watermark;
+using System.Windows.Controls;
 
 namespace PDF_Office.Views.EditTools.Watermark
 {
@@ -7,9 +9,16 @@ namespace PDF_Office.Views.EditTools.Watermark
     /// </summary>
     public partial class WatermarkTemplateListFileContent : UserControl
     {
+        private WatermarkTemplateListFileContentViewModel viewModel;
         public WatermarkTemplateListFileContent()
         {
             InitializeComponent();
+            viewModel = this.DataContext as WatermarkTemplateListFileContentViewModel;
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
         }
     }
 }

+ 65 - 13
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListTextContent.xaml

@@ -1,14 +1,66 @@
 <UserControl x:Class="PDF_Office.Views.EditTools.Watermark.WatermarkTemplateListTextContent"
-              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" 
-             mc:Ignorable="d"
-             d:DesignHeight="632"
-             d:DesignWidth="260" >
-    <Grid Background="CornflowerBlue">
-            
-    </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:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
+               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" d:DataContext="{d:DesignInstance Type=watermark:WatermarkTemplateListTextContentViewModel}"
+             mc:Ignorable="d"
+             d:DesignHeight="632"
+             d:DesignWidth="260">
+    <Grid Background="#F3F3F3">
+        <ListBox Name="TextWatermarkListbox" 
+                                Width="240" 
+                                BorderThickness="0"
+                                ScrollViewer.CanContentScroll="True"
+                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                                ScrollViewer.VerticalScrollBarVisibility="Hidden"
+                                VirtualizingPanel.IsVirtualizing="True"
+                                VirtualizingPanel.VirtualizationMode="Standard"
+                                VirtualizingPanel.CacheLengthUnit="Page"
+                                VirtualizingPanel.CacheLength="1"
+                                VirtualizingPanel.ScrollUnit="Pixel"   
+                                Background="#F3F3F3"
+                 ItemsSource="{Binding WatermarkModTextCollection}">
+            <ListBox.ItemContainerStyle>
+                <Style TargetType="ListBoxItem">
+                    <Setter Property="Margin" Value="0"/>
+                    <Setter Property="Padding" Value="8 0 8 0"/>
+                    <!--<Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}"/>-->
+                    <Setter Property="Template" Value="{DynamicResource ListBoxItemControlTemplate}"/>
+                </Style>
+            </ListBox.ItemContainerStyle>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="{x:Type data:WatermarkItem}">
+                    <StackPanel Name="itemPanel" >
+                        <Grid Height="160" Width=" 128" Background="Blue">
+                            <Label  Height="160" Width=" 128"></Label>
+                            <Label  Height="160" Width=" 128"></Label>
+                            <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom"></Button>
+                            <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
+                            </Button>
+                        </Grid>
+                    </StackPanel>
+                    <DataTemplate.Triggers>
+                        <Trigger Property="IsMouseOver" Value="True">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Visible"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Visible"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="False">
+                            <Setter TargetName="EditTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                            <Setter TargetName="DeleteTemplateBtn" Property="Visibility" Value="Collapsed"/>
+                        </Trigger>
+                    </DataTemplate.Triggers>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Grid Width="140" Margin="64,154,56,312" Visibility="{Binding CreateTemplateVisible, Mode=OneWay}">
+            <StackPanel Orientation="Vertical">
+                <Label Height="87" Width="87" HorizontalAlignment="Center" Background="BlueViolet"></Label>
+                <TextBlock Height="24" FontSize="14" Text="请先创建一个背景模板" Margin="0,8,0,0" VerticalAlignment="Center" ></TextBlock>
+                <Button Height="24" Width="44" Margin="0,12,0,0" Content ="新建" Command="{Binding AddTemplateCommand}"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 10 - 1
PDF Office/Views/EditTools/Watermark/WatermarkTemplateListTextContent.xaml.cs

@@ -1,4 +1,6 @@
-using System.Windows.Controls;
+using ComPDFKitViewer;
+using PDF_Office.ViewModels.EditTools.Watermark;
+using System.Windows.Controls;
 
 namespace PDF_Office.Views.EditTools.Watermark
 {
@@ -7,9 +9,16 @@ namespace PDF_Office.Views.EditTools.Watermark
     /// </summary>
     public partial class WatermarkTemplateListTextContent : UserControl
     {
+        private WatermarkTemplateListTextContentViewModel viewModel;
         public WatermarkTemplateListTextContent()
         {
             InitializeComponent();
+            viewModel = this.DataContext as WatermarkTemplateListTextContentViewModel;
+        }
+
+        private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
+        {
+            viewModel.DeleteTemplateItemCommand?.Execute(sender);
         }
     }
 }

+ 72 - 72
PDFSettings/PDFSettings.csproj

@@ -1,73 +1,73 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{BEE73AAE-9A2C-446B-B64D-3A8F042C985D}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>PDFSettings</RootNamespace>
-    <AssemblyName>PDFSettings</AssemblyName>
-    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <Deterministic>true</Deterministic>
-    <TargetFrameworkProfile />
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="ComPDFKit.Desk, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\PDFReader_WPF\ComPDFKit.Desk.dll</HintPath>
-    </Reference>
-    <Reference Include="ComPDFKit.Viewer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\PDFReader_WPF\ComPDFKit.Viewer.dll</HintPath>
-    </Reference>
-    <Reference Include="PresentationCore" />
-    <Reference Include="PresentationFramework" />
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Drawing" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Net.Http" />
-    <Reference Include="System.Xml" />
-    <Reference Include="WindowsBase" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="APPSettingProperties.cs" />
-    <Compile Include="BatesHeaderFooterList.cs" />
-    <Compile Include="CustomStampList.cs" />
-    <Compile Include="DefaultAnnotProperty.cs" />
-    <Compile Include="DialogCounter.cs" />
-    <Compile Include="DpiHelpers.cs" />
-    <Compile Include="BackgroundTemplateList.cs" />
-    <Compile Include="PDFToolsList.cs" />
-    <Compile Include="ProductActiveInfo.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="RecentOpenFiles.cs" />
-    <Compile Include="RedactionSettings.cs" />
-    <Compile Include="SignatureList.cs" />
-    <Compile Include="WaterMarkTempleteList.cs" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{BEE73AAE-9A2C-446B-B64D-3A8F042C985D}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>PDFSettings</RootNamespace>
+    <AssemblyName>PDFSettings</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="ComPDFKit.Desk, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\PDFReader_WPF\ComPDFKit.Desk.dll</HintPath>
+    </Reference>
+    <Reference Include="ComPDFKit.Viewer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\PDFReader_WPF\ComPDFKit.Viewer.dll</HintPath>
+    </Reference>
+    <Reference Include="PresentationCore" />
+    <Reference Include="PresentationFramework" />
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+    <Reference Include="WindowsBase" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="APPSettingProperties.cs" />
+    <Compile Include="BatesHeaderFooterList.cs" />
+    <Compile Include="CustomStampList.cs" />
+    <Compile Include="DefaultAnnotProperty.cs" />
+    <Compile Include="DialogCounter.cs" />
+    <Compile Include="DpiHelpers.cs" />
+    <Compile Include="BackgroundTemplateList.cs" />
+    <Compile Include="PDFToolsList.cs" />
+    <Compile Include="ProductActiveInfo.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RecentOpenFiles.cs" />
+    <Compile Include="RedactionSettings.cs" />
+    <Compile Include="SignatureList.cs" />
+    <Compile Include="WatermarkTemplateList.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 2 - 2
PDFSettings/WaterMarkTempleteList.cs

@@ -8,12 +8,12 @@ using System.Windows.Input;
 
 namespace PDFSettings
 {
-    public class WaterMarktemplateList:List<WaterMarktemplate>
+    public class WatermarkTemplateList:List<WatermarkItem>
     {
 
     }
 
-    public class WaterMarktemplate:EventArgs
+    public class WatermarkItem : EventArgs
     {
         /// <summary>
         /// 模板名称