瀏覽代碼

模板-编辑

liuaoran 2 年之前
父節點
當前提交
790db578d3
共有 20 個文件被更改,包括 338 次插入113 次删除
  1. 19 1
      PDF Office/EventAggregators/EditToolsEvent.cs
  2. 2 4
      PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs
  3. 12 5
      PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs
  4. 57 3
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateBaseContentViewModel.cs
  5. 29 3
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs
  6. 19 6
      PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs
  7. 57 13
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs
  8. 30 2
      PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs
  9. 0 1
      PDF Office/ViewModels/EditTools/Watermark/WatermarkContentViewModel.cs
  10. 2 2
      PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs
  11. 4 1
      PDF Office/ViewModels/Tools/ToolsBarContentViewModel.cs
  12. 9 6
      PDF Office/ViewModels/ViewContentViewModel.cs
  13. 15 1
      PDF Office/Views/EditTools/Background/BackgroundCreateBaseContent.xaml
  14. 61 57
      PDF Office/Views/EditTools/Background/BackgroundCreateFileContent.xaml
  15. 3 2
      PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml
  16. 5 0
      PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml.cs
  17. 3 3
      PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml
  18. 6 2
      PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml.cs
  19. 1 1
      PDF Office/Views/Tools/ToolsBarContent.xaml
  20. 4 0
      PDFSettings/BackgroundTemplateList.cs

+ 19 - 1
PDF Office/EventAggregators/EditToolsEvent.cs

@@ -1,5 +1,6 @@
 using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Model.EditTools.Watermark;
+using PDFSettings;
 using Prism.Events;
 using System;
 using System.Collections.Generic;
@@ -31,7 +32,13 @@ namespace PDF_Office.EventAggregators
         StatusFile
     }
 
-    public class EnterSelectedEditToolEvent : PubSubEvent<string>
+    public class StringWithUnicode
+    {
+        public string Unicode;
+        public string EditToolsContentName;
+    }
+
+    public class EnterSelectedEditToolEvent : PubSubEvent<StringWithUnicode>
     {
     }
 
@@ -79,4 +86,15 @@ namespace PDF_Office.EventAggregators
     {
     }
 
+    public class EditBackgroundTemplateItemEvent : PubSubEvent<BackgroundInfo>
+    {
+    }
+
+    public class ConfirmEditBackgroundTemplateItemEvent : PubSubEvent<EnumColorOrFile>
+    {
+    }
+
+    public class SaveEditedBackgroundTemplateItemEvent : PubSubEvent<BackgroundItem>
+    {
+    }
 }

+ 2 - 4
PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs

@@ -22,9 +22,7 @@ namespace PDF_Office.Model.EditTools.Background
         /// <summary>
         /// 背景类型
         /// </summary>
-        public C_Background_Type BackgroundType = C_Background_Type.BG_TYPE_COLOR;
-
-
+        public C_Background_Type BackgroundType = C_Background_Type.BG_TYPE_COLOR; 
 
         /// <summary>
         /// 纯色背景颜色
@@ -59,7 +57,7 @@ namespace PDF_Office.Model.EditTools.Background
         /// <summary>
         /// 
         /// </summary>
-        public int Scale;
+        public float Scale;
 
         /// <summary>
         /// 背景相对垂直距离;

+ 12 - 5
PDF Office/ViewModels/EditTools/Background/BackgroundContentViewModel.cs

@@ -12,6 +12,7 @@ using Visibility = System.Windows.Visibility;
 using Dropbox.Api.FileProperties;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
@@ -111,6 +112,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate);
             eventAggregator.GetEvent<SetCurrentCreateModEvent>().Subscribe(SetCurrentCreateMod);
             eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Subscribe(SetCurrentTemplateListMod);
+            eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Subscribe(EditBackgroundTemplateItem);
         }
 
         public void CloseEditTool()
@@ -135,11 +137,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
-        public void SaveBackgroundTemplate()
-        {
-            
-        }
-
         public void SetCurrentCreateMod(string currentCreateModName)
         {
             if (currentCreateModName == CreateModColorName)
@@ -152,6 +149,16 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        public void EditBackgroundTemplateItem(BackgroundInfo backgroundInfo)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("CurrentTemplateListModName", CurrentTemplateListMod);
+            param.Add("BackgroundInfo", backgroundInfo);
+            backgroundRegion.RequestNavigate(BackgroundSettingsRegionName, CreateBaseName, param);
+            BackgroundSettingsVisible = Visibility.Visible;
+        }
+
         public void SetCurrentTemplateListMod(string currentTemplateListModName)
         {
             if (currentTemplateListModName == TemplateListModColorName)

+ 57 - 3
PDF Office/ViewModels/EditTools/Background/BackgroundCreateBaseContentViewModel.cs

@@ -1,8 +1,10 @@
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDF_Office.Model;
+using PDF_Office.Model.EditTools.Background;
 using PDF_Office.Views.EditTools.Background;
 using Prism.Commands;
+using Prism.Common;
 using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
@@ -11,6 +13,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.EditTools.Background
@@ -21,6 +24,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         IRegionManager backgroundCreateRegion;
 
         private CPDFViewer PDFViewer;
+        public BackgroundInfo BackgroundInfo;
 
         private string backgroundCreateRegionName;
 
@@ -52,11 +56,25 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set => isFirstEnter = value;
         }
 
+        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 EnumColorOrFile CurrentTemplateListMod;
         public DelegateCommand<object> ChangeCreateModCommand { get; set; }
         public DelegateCommand EnterTemplateListCommand { get; set; }
         public DelegateCommand SaveToTemplateListCommand { get; set; }
-
+        public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
 
         public BackgroundCreateBaseContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
         {
@@ -66,6 +84,10 @@ namespace PDF_Office.ViewModels.EditTools.Background
             ChangeCreateModCommand = new DelegateCommand<object>(ChangeCreateMod);
             EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
             SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+            SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
+
+            
+
         }
 
         public void SaveToTemplateList()
@@ -80,6 +102,18 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        public void SaveToCurrentTemplateList()
+        {
+            if (CurrentCreateModName == "BackgroundCreateColorContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Publish(EnumColorOrFile.StatusColor);
+            }
+            if (CurrentCreateModName == "BackgroundCreateFileContent")
+            {
+                eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Publish(EnumColorOrFile.StatusFile);
+            }
+        }
+
         public void EnterTemplateList()
         {
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusTemplate);
@@ -91,6 +125,16 @@ namespace PDF_Office.ViewModels.EditTools.Background
             param.Add(ParameterNames.PDFViewer, PDFViewer);
             backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, currentCreateName, param);
             backgroundCreateVisible = System.Windows.Visibility.Visible;
+
+        }
+
+        public void EditSelectedTemplateItem(string currentCreateName)
+        {
+            NavigationParameters param = new NavigationParameters();
+            param.Add(ParameterNames.PDFViewer, PDFViewer);
+            param.Add("BackgroundInfo", BackgroundInfo);
+            backgroundCreateRegion.RequestNavigate(BackgroundCreateRegionName, currentCreateName, param);
+            backgroundCreateVisible = System.Windows.Visibility.Visible;
         }
 
         public void ChangeCreateMod(object e)
@@ -125,9 +169,19 @@ namespace PDF_Office.ViewModels.EditTools.Background
             {
                 CurrentCreateModName = "BackgroundCreateFileContent";
             }
-            EnterSelectedCreateMod(CurrentCreateModName);
+            if(navigationContext.Parameters.TryGetValue<BackgroundInfo>("BackgroundInfo", out BackgroundInfo))
+            {
+                EditSelectedTemplateItem(CurrentCreateModName);
+                EditBaseVisible = Visibility.Visible;
+                CreateBaseVisible= Visibility.Collapsed;
+            }
+            else
+            {
+                EnterSelectedCreateMod(CurrentCreateModName);
+                CreateBaseVisible= Visibility.Visible;
+                EditBaseVisible= Visibility.Collapsed;
+            }
             eventAggregator.GetEvent<SetCurrentCreateModEvent>().Publish(CurrentCreateModName);
-
         }
     }
 }

+ 29 - 3
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -33,7 +33,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         private string RedColorBtn = "RedColorBtn";
         private string GreenColorBtn = "GreenColorBtn";
 
-
+        private BackgroundInfo TemplateBackgroundInfo;
 
         private List<string> _rotationList = new List<string>();
         public List<string> RotationList
@@ -190,6 +190,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             BackgroundInfo.Vertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
             InitLocationButtonMatrix();
             eventAggregator.GetEvent<SaveBackgroundTemplateEvent>().Subscribe(SaveBackgroundTemplate);
+            eventAggregator.GetEvent<ConfirmEditBackgroundTemplateItemEvent>().Subscribe(ConfirmEditBackgroundTemplateItem);
         }
 
         public void InitComponent()
@@ -269,7 +270,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             backgroundItem.type = backgroundInfo.BackgroundType;
             backgroundItem.bgColor = backgroundInfo.Color;
-            backgroundItem.pageRange = backgroundInfo.PageRange;
             backgroundItem.horizalign = backgroundInfo.Horizalign;
             backgroundItem.vertalign = backgroundInfo.Vertalign;
             backgroundItem.vertOffset = backgroundInfo.VertOffset;
@@ -277,7 +277,8 @@ namespace PDF_Office.ViewModels.EditTools.Background
             backgroundItem.opacity = backgroundInfo.Opacity;
             backgroundItem.rotation = backgroundInfo.Rotation;
             backgroundItem.scale = backgroundInfo.Scale;
-          //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
+            backgroundItem.pageRange = backgroundInfo.PageRange;
+            //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
         }
 
         public void SaveCurrentTemplate()
@@ -288,8 +289,29 @@ namespace PDF_Office.ViewModels.EditTools.Background
             Settings.Default.BackgroundTemplateList.Add(backgroundItem);
             Settings.Default.Save();
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusTemplate);
+
         }
 
+        /// <summary>
+        /// 根据已知Info初始化
+        /// </summary>
+        public void InitComponentBySelectedInfo()
+        {
+            
+        }
+
+        public void ConfirmEditBackgroundTemplateItem(EnumColorOrFile enumColorOrFile)
+        {
+            if(enumColorOrFile == EnumColorOrFile.StatusColor)
+            {
+                var backgroundItem = new BackgroundItem();
+                ConvertInfoToItem(ref backgroundItem, BackgroundInfo);
+                this.eventAggregator.GetEvent<SaveEditedBackgroundTemplateItemEvent>().Publish(backgroundItem);
+                this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusTemplate);
+            }
+        }
+
+
         public void SaveBackgroundTemplate(EnumColorOrFile enumColorOrFile)
         {
             if (enumColorOrFile == EnumColorOrFile.StatusColor)
@@ -309,6 +331,10 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if(navigationContext.Parameters.TryGetValue<BackgroundInfo>("BackgroundInfo", out TemplateBackgroundInfo))
+            {
+                InitComponentBySelectedInfo();
+            }
             InitOpacityList();
         }
     }

+ 19 - 6
PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs

@@ -26,6 +26,8 @@ namespace PDF_Office.ViewModels.EditTools.Background
     {
         IEventAggregator eventAggregator;
 
+        private BackgroundInfo TemplateBackgroundInfo;
+
         public BackgroundInfo BackgroundInfo = new BackgroundInfo();
         private CPDFViewer PDFViewer;
 
@@ -137,13 +139,13 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set => isFirstEnter = value;
         }
 
-        private Visibility _createModFileVisible =  Visibility.Collapsed;
+        private Visibility _createModFileVisible = Visibility.Collapsed;
         public Visibility CreateModFileVisible
         {
             get => _createModFileVisible;
-            set=>SetProperty(ref _createModFileVisible, value);
+            set => SetProperty(ref _createModFileVisible, value);
         }
-        
+
 
         public DelegateCommand OpenFileCommand { get; set; }
         public DelegateCommand<object> ChangeLocationCommand { get; set; }
@@ -227,6 +229,11 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         }
 
+        public void InitComponentBySelectedInfo()
+        {
+
+        }
+
         public void ChangeLocation(object e)
         {
             string args = e as string;
@@ -280,8 +287,9 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public void ConvertInfoToItem(ref BackgroundItem backgroundItem, BackgroundInfo backgroundInfo)
         {
             backgroundItem.type = backgroundInfo.BackgroundType;
-            backgroundItem.bgColor = backgroundInfo.Color;
-            backgroundItem.pageRange = backgroundInfo.PageRange;
+            backgroundItem.imageArray = backgroundInfo.ImageArray;
+            backgroundItem.imageWidth = backgroundInfo.ImageWidth;
+            backgroundItem.imageHeight = backgroundInfo.ImageHeight;
             backgroundItem.horizalign = backgroundInfo.Horizalign;
             backgroundItem.vertalign = backgroundInfo.Vertalign;
             backgroundItem.vertOffset = backgroundInfo.VertOffset;
@@ -289,6 +297,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             backgroundItem.opacity = backgroundInfo.Opacity;
             backgroundItem.rotation = backgroundInfo.Rotation;
             backgroundItem.scale = backgroundInfo.Scale;
+            backgroundItem.pageRange = backgroundInfo.PageRange;
             //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
         }
 
@@ -304,7 +313,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void SaveBackgroundTemplate(EnumColorOrFile enumColorOrFile)
         {
-            if (enumColorOrFile == EnumColorOrFile.StatusColor)
+            if (enumColorOrFile == EnumColorOrFile.StatusFile)
             {
                 SaveCurrentTemplate();
             }
@@ -321,6 +330,10 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (navigationContext.Parameters.TryGetValue<BackgroundInfo>("BackgroundInfo", out TemplateBackgroundInfo))
+            {
+                InitComponentBySelectedInfo();
+            }
             InitOpacityList();
         }
     }

+ 57 - 13
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs

@@ -14,7 +14,7 @@ using System.Security.Permissions;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
-using System.Windows.Forms;
+using System.Windows.Controls;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
@@ -23,6 +23,8 @@ namespace PDF_Office.ViewModels.EditTools.Background
     {
         private readonly IEventAggregator eventAggregator;
         public BackgroundInfo BackgroundInfo = new BackgroundInfo();
+        public BackgroundItem BackgroundItem = new BackgroundItem();
+        public int TemplateIndex = 0;
 
         private ObservableCollection<BackgroundItem> backgroundModcolorCollection = new ObservableCollection<BackgroundItem>();
         public ObservableCollection<BackgroundItem> BackgroundModColorCollection
@@ -42,19 +44,21 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set { SetProperty(ref _createTemplateVisible, value); }
         }
 
-
-
         public DelegateCommand AddTemplateCommand { get; set; }
         public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand<object> EditTemplateItemCommand { get; set; }
         public DelegateCommand DeleteAllTemplateItemCommand { get; set; }
         public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
         BackgroundTemplateListColorContentViewModel(IEventAggregator eventAggregator)
         {
             this.eventAggregator = eventAggregator;
             AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(RequestEditTemplateItem);
             DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
             DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
             SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
+
+            eventAggregator.GetEvent<SaveEditedBackgroundTemplateItemEvent>().Subscribe(SaveEditedBackgroundTemplateItem);
         }
 
         private void CheckTemplateListIsEmpty(List<BackgroundItem> backgroundTemplateList)
@@ -97,6 +101,32 @@ namespace PDF_Office.ViewModels.EditTools.Background
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusCreate);
         }
 
+        public void SaveEditedBackgroundTemplateItem(BackgroundItem backgroundItem)
+        {
+            Settings.Default.BackgroundTemplateList[TemplateIndex] = backgroundItem;
+            Settings.Default.Save();
+            GetBackgroundSource();
+        }
+
+
+        public void RequestEditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BackgroundItem;
+            if (template == null)
+            {
+                return;
+            }
+            TemplateIndex = Settings.Default.BackgroundTemplateList.IndexOf(template);
+            ConvertItemToInfo(template, ref BackgroundInfo);
+            this.eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Publish(BackgroundInfo);
+        }
+
+
         public void DeleteTemplateItem(object e)
         {
             var btn = e as System.Windows.Controls.Button;
@@ -104,20 +134,19 @@ namespace PDF_Office.ViewModels.EditTools.Background
             {
                 return;
             }
-            var template = btn.DataContext as BackgroundItem;
-            if(template == null)
+            BackgroundItem = btn.DataContext as BackgroundItem;
+            if(BackgroundItem == null)
             {
                 return;
             }
-            Settings.Default.AppProperties.NeedToDeletePath.Add(template.previeImagePath);
-            Settings.Default.AppProperties.NeedToDeletePath.Add(template.imagepath);
+            Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.previeImagePath);
+            Settings.Default.AppProperties.NeedToDeletePath.Add(BackgroundItem.imagepath);
 
-            Settings.Default.BackgroundTemplateList.Remove(template);
+            Settings.Default.BackgroundTemplateList.Remove(BackgroundItem);
             Settings.Default.Save();
 
-            BackgroundModColorCollection.Remove(template);
+            BackgroundModColorCollection.Remove(BackgroundItem);
             GetBackgroundSource();
-
         }
 
         public void DeleteAllTemplateItem()
@@ -139,13 +168,28 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void ConvertItemToInfo(BackgroundItem backgroundItem, ref BackgroundInfo backgroundInfo)
         {
-
+                 backgroundInfo.BackgroundType=backgroundItem.type;
+                 backgroundInfo.Color = backgroundItem.bgColor ;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Vertalign = backgroundItem.vertalign;
+                backgroundInfo.VertOffset = backgroundItem.vertOffset;
+                backgroundInfo.Horizalign = backgroundItem.horizalign;
+                backgroundInfo.Opacity = backgroundItem.opacity;
+                backgroundInfo.Rotation = backgroundItem.rotation;
+                 backgroundInfo.Scale =  backgroundItem.scale ;
+                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);
             eventAggregator.GetEvent<SetBackgroundEvent>().Publish(BackgroundInfo);
+            }
+
         }
 
 

+ 30 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListFileContentViewModel.cs

@@ -43,6 +43,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public DelegateCommand AddTemplateCommand { get; set; }
         public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
+        public DelegateCommand <object> EditTemplateItemCommand { get; set; }
         public DelegateCommand DeleteAllTemplateItemCommand{ get; set; }
         public DelegateCommand<object> SelectTemplateItemCommand { get; set; }
 
@@ -50,6 +51,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         {
             this.eventAggregator = eventAggregator;
             AddTemplateCommand = new DelegateCommand(AddTemplate);
+            EditTemplateItemCommand = new DelegateCommand<object>(EditTemplateItem);
             DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
             DeleteAllTemplateItemCommand = new DelegateCommand(DeleteAllTemplateItem);
             SelectTemplateItemCommand = new DelegateCommand<object>(SelectTemplateItem);
@@ -92,11 +94,25 @@ namespace PDF_Office.ViewModels.EditTools.Background
             GetBackgroundSource();
         }
 
-
         public void AddTemplate()
         {
             this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(EnumTemplateListOrCreate.StatusCreate);
+        }
 
+        public void EditTemplateItem(object e)
+        {
+            var control = e as Control;
+            if (control == null)
+            {
+                return;
+            }
+            var template = control.DataContext as BackgroundItem;
+            if (template == null)
+            {
+                return;
+            }
+            ConvertItemToInfo(template, ref BackgroundInfo);
+            this.eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Publish(BackgroundInfo);
         }
 
         public void DeleteTemplateItem(object e)
@@ -141,7 +157,19 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
         public void ConvertItemToInfo(BackgroundItem backgroundItem, ref BackgroundInfo backgroundInfo)
         {
-
+            backgroundInfo.BackgroundType = backgroundItem.type ;
+            backgroundInfo.ImageArray = backgroundItem.imageArray;
+            backgroundInfo.ImageWidth = backgroundItem.imageWidth;
+            backgroundInfo.ImageHeight = backgroundItem.imageHeight;
+            backgroundInfo.Horizalign = backgroundItem.horizalign;
+            backgroundInfo.Vertalign = backgroundItem.vertalign;
+            backgroundInfo.VertOffset = backgroundItem.vertOffset;
+            backgroundInfo.Horizalign = backgroundItem.horizalign;
+            backgroundInfo.Opacity = backgroundItem.opacity;
+            backgroundInfo.Rotation = backgroundItem.rotation;
+            backgroundInfo.Scale = backgroundItem.scale;
+            backgroundInfo.PageRange = backgroundItem.pageRange;
+            //  backgroundItem.pagRangeMode = backgroundInfo.PageRange;
         }
 
         public void SendTemplateItemToDocument(BackgroundItem BackgroundItem)

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

@@ -177,7 +177,6 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
         }
 
         private void DeleteWatermark() {
-
             AlertsMessage alertsMessage = new AlertsMessage();
             alertsMessage.ShowDialog("", "请输入有效范围", "OK");
             PDFViewer.Document.DeleteWatermarks();

+ 2 - 2
PDF Office/ViewModels/EditTools/Watermark/WatermarkTemplateListFileContentViewModel.cs

@@ -129,12 +129,12 @@ namespace PDF_Office.ViewModels.EditTools.Watermark
                 WatermarkModFileCollection.Remove(template);
             }
             GetWatermarkSource();
-        }
+        }  
 
         public void SelectTemplateItem(object e)
         {
             var listBox = e as ListBox;
-            WatermarkItem WatermarkItem = listBox.SelectedItem as WatermarkItem;
+            WatermarkItem WatermarkItem   = listBox.SelectedItem as WatermarkItem;
             SendTemplateItemToDocument(WatermarkItem);
         }
 

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

@@ -23,6 +23,8 @@ namespace PDF_Office.ViewModels.Tools
 
         public IEventAggregator eventAggregator;
 
+        public string unicode = null;
+
         /// <summary>
         /// 是否是第一次加载
         /// </summary>
@@ -44,6 +46,7 @@ namespace PDF_Office.ViewModels.Tools
         {
             dialogs= dialogService;
             this.eventAggregator= eventAggregator;
+            unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             CompressCommand = new DelegateCommand(OpenCompressDialog);
             SetPasswordCommand = new DelegateCommand(OpenSetPasswordDialog);
             CancelPasswordCommand = new DelegateCommand(OpenCancelPasswordDialog);
@@ -55,7 +58,7 @@ namespace PDF_Office.ViewModels.Tools
             var args = e as System.Windows.Controls.Button;
             if (args != null)
             {
-                this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(args.Name);
+                this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(new StringWithUnicode() { Unicode=unicode,EditToolsContentName=args.Name}) ;
             }
         }
 

+ 9 - 6
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -341,6 +341,8 @@ namespace PDF_Office.ViewModels
 
         public string CurrentBar = "";
 
+        public string unicode = null;
+
         /// <summary>
         /// 用来避免重复触发导航事件的标志符
         /// </summary>
@@ -377,7 +379,7 @@ namespace PDF_Office.ViewModels
         {
             region = regionManager;
             dialogs = dialogService;
-
+            unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             LoadFile = new DelegateCommand(loadFile);
             Load = new DelegateCommand(LoadControl);
             SaveFile = new DelegateCommand(() => { saveFile(); });
@@ -407,7 +409,7 @@ namespace PDF_Office.ViewModels
             InitialregionNameByTabItem(ref regionNameByTabItem);
             InitialbarContentByTabItem(ref barContentByTabItem);
 
-            eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools);
+            eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools,e=>e.Unicode==unicode);
             eventAggregator.GetEvent<CloseEditToolEvent>().Subscribe(CloseEditTool);
 
             //TODO:根据缓存 选择用户上次选择的菜单
@@ -900,8 +902,9 @@ namespace PDF_Office.ViewModels
         /// 从二级工具栏进入需要修改界面布局的场景
         /// </summary>
         /// <param name="EditToolName"></param>
-        private void EnterEditTools(string EditToolName)
+        private void EnterEditTools(StringWithUnicode EditToolName)
         {
+            
             EnterSelectedEditTool(EditToolName);
         }
 
@@ -915,10 +918,10 @@ namespace PDF_Office.ViewModels
         /// 二级菜单指定目标处理
         /// </summary>
         /// <param name="e"></param>
-        private void EnterSelectedEditTool(string EditToolName)
+        private void EnterSelectedEditTool(StringWithUnicode EditToolName)
         {
-            CurrentBar = EditToolName;
-            EnterToolMode(EditToolName);
+            CurrentBar = EditToolName.EditToolsContentName;
+            EnterToolMode(CurrentBar);
         }
 
         /// <summary>

+ 15 - 1
PDF Office/Views/EditTools/Background/BackgroundCreateBaseContent.xaml

@@ -14,7 +14,7 @@
             <RowDefinition Height="48"></RowDefinition>
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
-        <Grid Grid.Row="0">
+        <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>
@@ -28,6 +28,20 @@
                 </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>

+ 61 - 57
PDF Office/Views/EditTools/Background/BackgroundCreateFileContent.xaml

@@ -16,18 +16,22 @@
         </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 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 Grid.Row="1" Visibility="{Binding CreateModFileVisible}" Grid.ColumnSpan="2">
             <Grid.RowDefinitions>
                 <RowDefinition Height="157"></RowDefinition>
                 <RowDefinition Height="163"></RowDefinition>
@@ -35,69 +39,69 @@
                 <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>
+                <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="0" Value="{Binding RotationValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
-                    <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
+                        <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="100 %"  Value="{Binding OpacityValue,Mode=TwoWay}"></cus:CommonWritableComboBox>
-                </StackPanel>
-                <StackPanel Orientation="Horizontal"></StackPanel>
-                <Grid Margin="0,19,0,0">
-                    <CheckBox Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"></CheckBox>
-                </Grid>
-                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}"  Text="100 %"></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>
+                    </StackPanel>
+                    <StackPanel Orientation="Horizontal"></StackPanel>
+                    <Grid Margin="0,19,0,0">
+                        <CheckBox Grid.Column="0" Style="{StaticResource EditToolsCheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"></CheckBox>
                     </Grid>
-                    <StackPanel Orientation="Vertical" Margin="70,0,0,0">
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}"  Text="100 %"></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"/>
+                            </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> 
-            </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>
+                </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>
+                </StackPanel>
+            </Grid>
         </Grid>
     </Grid>
-    </Grid>
 </UserControl>

+ 3 - 2
PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml

@@ -37,7 +37,8 @@
                                 VirtualizingPanel.CacheLength="1"
                                 VirtualizingPanel.ScrollUnit="Pixel"   
                                 Background="#F3F3F3"
-                 ItemsSource="{Binding BackgroundModColorCollection}">
+                 ItemsSource="{Binding BackgroundModColorCollection}"
+                           SelectionChanged="ListBox_SelectionChanged">
             <ListBox.ItemContainerStyle>
                 <Style TargetType="ListBoxItem">
                     <Setter Property="Margin" Value="0"/>
@@ -53,7 +54,7 @@
                             <Grid Height="160" Width=" 128" Background="LightBlue">
                                 <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="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
                                 <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click" >
                                 </Button>
                             </Grid>

+ 5 - 0
PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml.cs

@@ -44,5 +44,10 @@ namespace PDF_Office.Views.EditTools.Background
         {
             viewModel.DeleteAllTemplateItemCommand?.Execute();
         }
+
+        private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
     }
 }

+ 3 - 3
PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml

@@ -24,7 +24,7 @@
             <MenuItem Name="MenuDeleteAll" Header="删除全部" Click="MenuDeleteAll_Click"></MenuItem>
         </ContextMenu>
     </UserControl.Resources>
-    
+
     <Grid Background="#F3F3F3">
         <ListBox
                                 Width="240" 
@@ -40,7 +40,7 @@
                                 Background="#F3F3F3"
                  ItemsSource="{Binding BackgroundModFileCollection}"  
             SelectionChanged="ListBox_SelectionChanged">
-            
+
             <ListBox.ItemContainerStyle>
                 <Style TargetType="ListBoxItem">
                     <Setter Property="Margin" Value="20"/>
@@ -56,7 +56,7 @@
                     <StackPanel Name="itemPanel">
                         <Grid Height="160" Width=" 128" Background="LightBlue">
                             <Label  Height="160" Width=" 128"></Label>
-                              <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom"></Button>
+                            <Button Name="EditTemplateBtn" Height="43" Width="63" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="EditTemplateBtn_Click"></Button>
                             <Button Name="DeleteTemplateBtn"  Height="43" Width="63" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="DeleteTemplateBtn_Click">
                             </Button>
                         </Grid>

+ 6 - 2
PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml.cs

@@ -30,18 +30,22 @@ namespace PDF_Office.Views.EditTools.Background
 
         private void MenuEdit_Click(object sender, RoutedEventArgs e)
         {
-
+            viewModel.EditTemplateItemCommand?.Execute(sender);
         }
 
         private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
         {
             viewModel.DeleteTemplateItemCommand?.Execute(sender);
-
         }
 
         private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
         {
             viewModel.DeleteAllTemplateItemCommand?.Execute();
         }
+
+        private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
+        {
+            viewModel.EditTemplateItemCommand?.Execute(sender);
+        }
     }
 }

+ 1 - 1
PDF Office/Views/Tools/ToolsBarContent.xaml

@@ -1,7 +1,7 @@
 <UserControl x:Class="PDF_Office.Views.Tools.ToolsBarContent"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:prism="http://prismlibrary.com/" xmlns:tools="clr-namespace:PDF_Office.ViewModels.Tools" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
+             xmlns:prism="http://prismlibrary.com/" xmlns:tools="clr-namespace:PDF_Office.ViewModels.Tools" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              prism:ViewModelLocator.AutoWireViewModel="True">
     <UserControl.Resources>
         <ResourceDictionary>

+ 4 - 0
PDFSettings/BackgroundTemplateList.cs

@@ -44,6 +44,10 @@ namespace PDFSettings
         /// </summary>
         public float horizOffset = 0;
 
+        /// <summary>
+        /// 图片水印内容
+        /// </summary>
+        public byte[] imageArray = null;
 
         public string previeImagePath = "";