Bladeren bron

EditTools-TemplateList

liuaoran 2 jaren geleden
bovenliggende
commit
31824d3602

+ 10 - 0
PDF Office/App.config

@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
 <configuration>
     <configSections>
     <configSections>
+        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+            <section name="PDF_Office.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+        </sectionGroup>
     </configSections>
     </configSections>
     <startup> 
     <startup> 
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
@@ -13,4 +16,11 @@
       </dependentAssembly>
       </dependentAssembly>
     </assemblyBinding>
     </assemblyBinding>
   </runtime>
   </runtime>
+  <userSettings>
+    <PDF_Office.Properties.Settings>
+      <setting name="BackgroundIndex" serializeAs="String">
+        <value>0</value>
+      </setting>
+    </PDF_Office.Properties.Settings>
+  </userSettings>
 </configuration>
 </configuration>

+ 4 - 0
PDF Office/EventAggregators/EditToolsEvent.cs

@@ -66,4 +66,8 @@ namespace PDF_Office.EventAggregators
     public class SetWatermarkEvent : PubSubEvent<WatermarkInfo>
     public class SetWatermarkEvent : PubSubEvent<WatermarkInfo>
     {
     {
     }
     }
+
+    public class SaveBackgroundTemplate : PubSubEvent<BackgroundInfo>
+    {
+    }
 }
 }

+ 0 - 2
PDF Office/Helper/ToolMethod.cs

@@ -132,8 +132,6 @@ namespace PDF_Office.Helper
                                 fileInfo.ThumbImgPath = imagePath;
                                 fileInfo.ThumbImgPath = imagePath;
                             }
                             }
                         }
                         }
-
-
                     }
                     }
                     else//解锁文件覆盖了加密文件的情况 或者本地缩略图文件被删除
                     else//解锁文件覆盖了加密文件的情况 或者本地缩略图文件被删除
                     {
                     {

+ 24 - 1
PDF Office/Properties/Settings.Designer.cs

@@ -12,7 +12,7 @@ namespace PDF_Office.Properties {
     
     
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -77,5 +77,28 @@ namespace PDF_Office.Properties {
                 this["QuickPDFToolsList"] = value;
                 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;
+            }
+        }
     }
     }
 }
 }

+ 6 - 0
PDF Office/Properties/Settings.settings

@@ -17,5 +17,11 @@
     <Setting Name="QuickPDFToolsList" Type="PDFSettings.QuickPDFToolsList" Scope="User">
     <Setting Name="QuickPDFToolsList" Type="PDFSettings.QuickPDFToolsList" Scope="User">
       <Value Profile="(Default)" />
       <Value Profile="(Default)" />
     </Setting>
     </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>
   </Settings>
 </SettingsFile>
 </SettingsFile>

+ 19 - 0
PDF Office/Styles/ListBoxStyle.xaml

@@ -47,4 +47,23 @@
             </Trigger>-->
             </Trigger>-->
         </ControlTemplate.Triggers>
         </ControlTemplate.Triggers>
     </ControlTemplate>
     </ControlTemplate>
+
+    <ControlTemplate x:Key="EditToolsItemControlTemplate" TargetType="{x:Type ListBox}">
+        <Border x:Name="EditToolsBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
+            <ContentPresenter ContentTemplate="{Binding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+        </Border>
+        <ControlTemplate.Triggers>
+            <MultiTrigger>
+                <MultiTrigger.Conditions>
+                    <Condition Property="IsMouseOver" Value="True"></Condition>
+                </MultiTrigger.Conditions>
+                <Setter Property="Background" TargetName="EditToolsBorder" Value="#1A000000"/>
+                <Setter Property="BorderBrush" TargetName="EditToolsBorder" Value="Transparent"/>
+            </MultiTrigger>
+            <Trigger Property="IsEnabled" Value="False">
+                <Setter Property="TextElement.Foreground" TargetName="EditToolsBorder" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
+            </Trigger>
+        </ControlTemplate.Triggers>
+    </ControlTemplate>
+
 </ResourceDictionary>
 </ResourceDictionary>

+ 6 - 0
PDF Office/ViewModels/EditTools/Background/BackgroundCreateBaseContentViewModel.cs

@@ -55,6 +55,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
         public EnumColorOrFile CurrentTemplateListMod;
         public EnumColorOrFile CurrentTemplateListMod;
         public DelegateCommand<object> ChangeCreateModCommand { get; set; }
         public DelegateCommand<object> ChangeCreateModCommand { get; set; }
         public DelegateCommand EnterTemplateListCommand { get; set; }
         public DelegateCommand EnterTemplateListCommand { get; set; }
+        public DelegateCommand SaveToTemplateListCommand { get; set; }
 
 
 
 
         public BackgroundCreateBaseContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
         public BackgroundCreateBaseContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
@@ -64,6 +65,11 @@ namespace PDF_Office.ViewModels.EditTools.Background
             BackgroundCreateRegionName = Guid.NewGuid().ToString();
             BackgroundCreateRegionName = Guid.NewGuid().ToString();
             ChangeCreateModCommand = new DelegateCommand<object>(ChangeCreateMod);
             ChangeCreateModCommand = new DelegateCommand<object>(ChangeCreateMod);
             EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
             EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
+            SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
+        }
+
+        public void SaveToTemplateList()
+        {
 
 
         }
         }
 
 

+ 7 - 5
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -83,7 +83,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             get { return _relativeRatioValue; }
             get { return _relativeRatioValue; }
             set
             set
             {
             {
-               SetProperty(ref _rotationValue, value);
+                SetProperty(ref _rotationValue, value);
                 BackgroundInfo.RelativeRatio = value;
                 BackgroundInfo.RelativeRatio = value;
             }
             }
         }
         }
@@ -124,7 +124,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set
             set
             {
             {
                 SetProperty(ref _stringColor, value);
                 SetProperty(ref _stringColor, value);
-                //BackgroundInfo.Color = EditToolsHelper.ConvertColor(value); ;
+                //BackgroundInfo.Color = EditToolsHelper.ConvertColor(value); 
             }
             }
         }
         }
 
 
@@ -133,7 +133,10 @@ namespace PDF_Office.ViewModels.EditTools.Background
         private int _pageRangeSelectIndex = 0;
         private int _pageRangeSelectIndex = 0;
         public int PageRangeSelectIndex
         public int PageRangeSelectIndex
         {
         {
-            get { return _pageRangeSelectIndex; }
+            get
+            {
+                return _pageRangeSelectIndex;
+            }
             set
             set
             {
             {
                 SetProperty(ref _pageRangeSelectIndex, value);
                 SetProperty(ref _pageRangeSelectIndex, value);
@@ -154,7 +157,6 @@ namespace PDF_Office.ViewModels.EditTools.Background
             BackgroundInfo.BackgroundHorizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER;
             BackgroundInfo.BackgroundHorizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER;
             BackgroundInfo.BackgroundVertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
             BackgroundInfo.BackgroundVertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
             InitLocationButtonMatrix();
             InitLocationButtonMatrix();
-
             eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditTools);
             eventAggregator.GetEvent<ConfirmEditToolsBackgroundEvent>().Subscribe(ConfirmEditTools);
         }
         }
 
 
@@ -236,7 +238,7 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
 
         public void ConfirmEditTools(EnumColorOrFile enumColorOrFile)
         public void ConfirmEditTools(EnumColorOrFile enumColorOrFile)
         {
         {
-            if(enumColorOrFile == EnumColorOrFile.StatusColor)
+            if (enumColorOrFile == EnumColorOrFile.StatusColor)
             {
             {
                 eventAggregator.GetEvent<SetBackgroundEvent>().Publish(BackgroundInfo);
                 eventAggregator.GetEvent<SetBackgroundEvent>().Publish(BackgroundInfo);
             }
             }

+ 125 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundTemplateListColorContentViewModel.cs

@@ -1,14 +1,137 @@
-using Prism.Regions;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Linq;
+using System.Security.Permissions;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
 
 
 namespace PDF_Office.ViewModels.EditTools.Background
 namespace PDF_Office.ViewModels.EditTools.Background
 {
 {
-    internal class BackgroundTemplateListColorContentViewModel : INavigationAware
+
+    public class BackgroundTemplateListColorContentViewModel : BindableBase, INavigationAware
     {
     {
+        public ObservableCollection<BackgroundItem> backgroundModcolorCollection = new ObservableCollection<BackgroundItem>();
+        public ObservableCollection<BackgroundItem> BackgroundModColorCollection
+        {
+            get { return backgroundModcolorCollection; }
+            set
+            {
+                backgroundModcolorCollection = 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; }
+
+        BackgroundTemplateListColorContentViewModel()
+        {
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+
+            InitBackgroundTemplateList();
+        }
+
+        private void CheckTemplateListIsEmpty(List<BackgroundItem> backgroundTemplateList)
+        {
+            if (backgroundTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetBackgroundSource()
+        {
+            List<BackgroundItem> backgroundModColorTemplateList = new List<BackgroundItem>();
+            for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
+            {
+                if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
+                {
+                    backgroundModColorTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
+                }
+            }
+            BackgroundModColorCollection = new ObservableCollection<BackgroundItem>(backgroundModColorTemplateList);
+            CheckTemplateListIsEmpty(backgroundModColorTemplateList);
+        }
+
+
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BackgroundTemplateList == null)
+            {
+                Settings.Default.BackgroundTemplateList = new BackgroundTemplateList();
+            }
+            GetBackgroundSource();
+        }
+
+        private void UpdateBackgroundSources()
+        {
+            List<BackgroundItem> backgroundModColorTemplateList = new List<BackgroundItem>();
+            for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
+            {
+                if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
+                {
+                    backgroundModColorTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
+                }
+            }
+            BackgroundModColorCollection = new ObservableCollection<BackgroundItem>(backgroundModColorTemplateList);
+            CheckTemplateListIsEmpty(backgroundModColorTemplateList);
+        }
+
+        public void AddTemplate()
+        {
+            var backgroundItem = new BackgroundItem();
+            backgroundItem.pageRange = "0";
+            backgroundItem.type = ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR;
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
+            Settings.Default.BackgroundTemplateList.Add(backgroundItem);
+            Settings.Default.Save();
+            UpdateBackgroundSources();
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if(btn == null)
+            {
+                return;
+            }
+            var template = btn.DataContext as BackgroundItem;
+            if(template == null)
+            {
+                return;
+            }
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.previeImagePath);
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.imagepath);
+
+            Settings.Default.BackgroundTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            BackgroundModColorCollection.Remove(template);
+            UpdateBackgroundSources();
+
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
         {
             return true;
             return true;

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

@@ -1,14 +1,135 @@
-using Prism.Regions;
+using PDF_Office.Properties;
+using PDFSettings;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using System.Windows;
 
 
 namespace PDF_Office.ViewModels.EditTools.Background
 namespace PDF_Office.ViewModels.EditTools.Background
 {
 {
-    public class BackgroundTemplateListFileContentViewModel : INavigationAware
+    public class BackgroundTemplateListFileContentViewModel : BindableBase,INavigationAware
     {
     {
+        public ObservableCollection<BackgroundItem> backgroundModFileCollection = new ObservableCollection<BackgroundItem>();
+        public ObservableCollection<BackgroundItem> BackgroundModFileCollection
+        {
+            get { return backgroundModFileCollection; }
+            set
+            {
+                backgroundModFileCollection = 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; }
+
+        BackgroundTemplateListFileContentViewModel()
+        {
+            AddTemplateCommand = new DelegateCommand(AddTemplate);
+            DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
+
+            InitBackgroundTemplateList();
+        }
+
+        private void CheckTemplateListIsEmpty(List<BackgroundItem> backgroundTemplateList)
+        {
+            if (backgroundTemplateList.Count() == 0)
+            {
+                CreateTemplateVisible = Visibility.Visible;
+            }
+            else
+            {
+                CreateTemplateVisible = Visibility.Collapsed;
+            }
+        }
+
+        private void GetBackgroundSource()
+        {
+            List<BackgroundItem> backgroundModFileTemplateList = new List<BackgroundItem>();
+            for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
+            {
+                if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE)
+                {
+                    backgroundModFileTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
+                }
+            }
+            BackgroundModFileCollection = new ObservableCollection<BackgroundItem>(backgroundModFileTemplateList);
+            CheckTemplateListIsEmpty(backgroundModFileTemplateList);
+        }
+
+
+
+        private void InitBackgroundTemplateList()
+        {
+            if (Settings.Default.BackgroundTemplateList == null)
+            {
+                Settings.Default.BackgroundTemplateList = new BackgroundTemplateList();
+            }
+            GetBackgroundSource();
+        }
+
+        private void UpdateBackgroundSources()
+        {
+            int count = backgroundModFileCollection.Count + backgroundModFileCollection.Count;
+            List<BackgroundItem> backgroundModFileTemplateList = new List<BackgroundItem>();
+            for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
+            {
+                if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE)
+                {
+                    backgroundModFileTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
+                }
+            }
+            BackgroundModFileCollection = new ObservableCollection<BackgroundItem>(backgroundModFileTemplateList);
+            CheckTemplateListIsEmpty(backgroundModFileTemplateList);
+        }
+
+        public void AddTemplate()
+        {
+            var backgroundItem = new BackgroundItem();
+            backgroundItem.pageRange = "0";
+            backgroundItem.type = ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_IMAGE;
+            backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
+            Settings.Default.BackgroundTemplateList.Add(backgroundItem);
+            Settings.Default.Save();
+            UpdateBackgroundSources();
+        }
+
+        public void DeleteTemplateItem(object e)
+        {
+            var btn = e as System.Windows.Controls.Button;
+            if (btn == null)
+            {
+                return;
+            }
+            var template = btn.DataContext as BackgroundItem;
+            if (template == null)
+            {
+                return;
+            }
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.previeImagePath);
+            Settings.Default.AppProperties.NeedToDeletePath.Add(template.imagepath);
+
+            Settings.Default.BackgroundTemplateList.Remove(template);
+            Settings.Default.Save();
+
+            BackgroundModFileCollection.Remove(template);
+            UpdateBackgroundSources();
+
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
         {
             return true;
             return true;

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

@@ -21,7 +21,7 @@
                     <TextBlock Text="创建背景" FontSize="16"></TextBlock>
                     <TextBlock Text="创建背景" FontSize="16"></TextBlock>
                 </StackPanel>
                 </StackPanel>
             </Button>
             </Button>
-            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right">
+            <Button  Height="20" Width="64" Margin="0,0,16,0" HorizontalAlignment="Right" Command="{Binding SaveToTemplateListCommand}">
                 <StackPanel>
                 <StackPanel>
                 <TextBlock Text="保存至模板"  Foreground="#18A0FB"></TextBlock>
                 <TextBlock Text="保存至模板"  Foreground="#18A0FB"></TextBlock>
                     <Rectangle Height="1" Fill="#18A0FB"></Rectangle>
                     <Rectangle Height="1" Fill="#18A0FB"></Rectangle>

+ 56 - 4
PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml

@@ -3,12 +3,64 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:prism="http://prismlibrary.com/"             
              xmlns:prism="http://prismlibrary.com/"             
              prism:ViewModelLocator.AutoWireViewModel="True"
              prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:watermark="clr-namespace:PDF_Office.ViewModels.EditTools.Watermark" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundTemplateListColorContentViewModel}"
              mc:Ignorable="d"
              mc:Ignorable="d"
-             d:DesignHeight="720"
+             d:DesignHeight="632"
              d:DesignWidth="260">
              d:DesignWidth="260">
-    <Grid Background="ForestGreen">
-            
+    <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 BackgroundModColorCollection}">
+            <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:BackgroundItem}">
+                    <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"  Command="{Binding DeleteTemplateItemCommand}" CommandParameter="{Binding ElementName=DeleteTemplateBtn}">
+                            </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" Height="155" Margin="64,153,56,324" 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>
     </Grid>
 </UserControl>
 </UserControl>

+ 12 - 1
PDF Office/Views/EditTools/Background/BackgroundTemplateListColorContent.xaml.cs

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

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

@@ -3,12 +3,64 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:prism="http://prismlibrary.com/"             
              xmlns:prism="http://prismlibrary.com/"             
              prism:ViewModelLocator.AutoWireViewModel="True" 
              prism:ViewModelLocator.AutoWireViewModel="True" 
+             xmlns:data ="clr-namespace:PDFSettings;assembly=PDFSettings"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:background="clr-namespace:PDF_Office.ViewModels.EditTools.Background" d:DataContext="{d:DesignInstance Type=background:BackgroundTemplateListFileContentViewModel}"
              mc:Ignorable="d"
              mc:Ignorable="d"
              d:DesignHeight="632"
              d:DesignHeight="632"
              d:DesignWidth="260">
              d:DesignWidth="260">
-    <Grid Background="CornflowerBlue">
-            
+    <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 BackgroundModFileCollection}">
+            <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:BackgroundItem}">
+                    <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"  Command="{Binding DeleteTemplateItemCommand}" CommandParameter="{Binding ElementName=DeleteTemplateBtn}">
+                            </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" Height="155" Margin="64,153,56,324" 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>
     </Grid>
 </UserControl>
 </UserControl>

+ 10 - 1
PDF Office/Views/EditTools/Background/BackgroundTemplateListFileContent.xaml.cs

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

+ 3 - 3
PDFSettings/PDFBackgroundList.cs

@@ -7,17 +7,17 @@ using System.Threading.Tasks;
 namespace PDFSettings
 namespace PDFSettings
 {
 {
 
 
-    public class PDFBackgroundList : List<PDFBackgroundItem>
+    public class BackgroundTemplateList : List<BackgroundItem>
     {
     {
 
 
     }
     }
 
 
-    public class PDFBackgroundItem : EventArgs
+    public class BackgroundItem : EventArgs
     {
     {
         /// <summary>
         /// <summary>
         /// 模板名称
         /// 模板名称
         /// </summary>
         /// </summary>
-        public string templeteName = "Background";
+        public string templateName = "Background";
 
 
         /// <summary>
         /// <summary>
         /// 文档背景类型
         /// 文档背景类型

+ 1 - 1
PDFSettings/PDFSettings.csproj

@@ -60,7 +60,7 @@
     <Compile Include="DefaultAnnotProperty.cs" />
     <Compile Include="DefaultAnnotProperty.cs" />
     <Compile Include="DialogCounter.cs" />
     <Compile Include="DialogCounter.cs" />
     <Compile Include="DpiHelpers.cs" />
     <Compile Include="DpiHelpers.cs" />
-    <Compile Include="PDFBackgroundList.cs" />
+    <Compile Include="BackgroundTemplateList.cs" />
     <Compile Include="PDFToolsList.cs" />
     <Compile Include="PDFToolsList.cs" />
     <Compile Include="ProductActiveInfo.cs" />
     <Compile Include="ProductActiveInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 3 - 3
PDFSettings/WaterMarkTempleteList.cs

@@ -8,17 +8,17 @@ using System.Windows.Input;
 
 
 namespace PDFSettings
 namespace PDFSettings
 {
 {
-    public class WaterMarkTempleteList:List<WaterMarkTemplete>
+    public class WaterMarktemplateList:List<WaterMarktemplate>
     {
     {
 
 
     }
     }
 
 
-    public class WaterMarkTemplete:EventArgs
+    public class WaterMarktemplate:EventArgs
     {
     {
         /// <summary>
         /// <summary>
         /// 模板名称
         /// 模板名称
         /// </summary>
         /// </summary>
-        public string templeteName = "Watermark";
+        public string templateName = "Watermark";
 
 
         /// <summary>
         /// <summary>
         /// 水印类型
         /// 水印类型