Browse Source

综合-签名页面,缓存文件夹方法拓展

zhuyi 2 years ago
parent
commit
c7ef3e1a33

+ 1 - 0
PDF Office/App.xaml.cs

@@ -194,6 +194,7 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<LinkAnnotProperty>();
             containerRegistry.RegisterForNavigation<SharpsAnnotProperty>();
             containerRegistry.RegisterForNavigation<StampAnnotProperty>();
+            containerRegistry.RegisterForNavigation<SignatureAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextAnnotProperty>();
             containerRegistry.RegisterForNavigation<TextEditProperty>();
             containerRegistry.RegisterForNavigation<BatesContent>();

+ 14 - 5
PDF Office/Helper/CacheFilePath.cs

@@ -17,6 +17,10 @@ namespace PDF_Office.Helper
     {
         private static readonly CacheFilePath instance = new CacheFilePath();
 
+        /// <summary>
+        /// 图章缓存文件夹路径
+        /// </summary>
+        List<string> CustomStamp = new List<string> { "CustomStamp" };
         public static CacheFilePath Instance => instance;
 
         private CacheFilePath()
@@ -31,19 +35,24 @@ namespace PDF_Office.Helper
         {
             get
             {
-               return CreateCacheDirectory("CustomStamp");
+               return CreateCacheDirectory(CustomStamp);
             }
         }
-
         /// <summary>
-        /// 在“文档”路径下创建缓存文件夹,传C:\Users\kdan\Documents\PDF Office 以后的文件夹名
+        ///  在“文档”路径下创建缓存文件夹,传C:\Users\kdan\Documents\PDF Office 以后的文件夹名
         /// </summary>
+        /// <param name="directoryName">文件路径列表,首位为第一个文件夹名,以此类推</param>
         /// <returns></returns>
-        private string CreateCacheDirectory(string directoryName)
+        private string CreateCacheDirectory(List<string> directoryName)
         {
             try
             {
-                string Path = System.IO.Path.Combine(App.CurrentPath, directoryName);
+                string Path = App.CurrentPath;
+                for (int i = 0; i < directoryName.Count; i++)
+                {
+                    Path = System.IO.Path.Combine(Path, directoryName[i]);
+                }
+           
                 System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(Path);
                 if (directoryInfo.Exists
                    && (directoryInfo.Attributes & System.IO.FileAttributes.ReadOnly) != System.IO.FileAttributes.ReadOnly

+ 8 - 0
PDF Office/PDF Office.csproj

@@ -380,6 +380,7 @@
     <Compile Include="ViewModels\Form\FormsToolContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\PDFTools\PDFToolsContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\PDFTools\QuickToolsContentViewModel.cs" />
+    <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureAnnotPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\ViewModular\ReadViewContentViewModel.cs" />
     <Compile Include="ViewModels\HomePanel\RecentFiles\RecentFilesContentViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\CustomCreateDialogViewModel.cs" />
@@ -784,6 +785,9 @@
     <Compile Include="Views\PropertyPanel\AnnotPanel\SharpsAnnotProperty.xaml.cs">
       <DependentUpon>SharpsAnnotProperty.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\PropertyPanel\AnnotPanel\SignatureAnnotProperty.xaml.cs">
+      <DependentUpon>SignatureAnnotProperty.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\PropertyPanel\AnnotPanel\StampAnnotProperty.xaml.cs">
       <DependentUpon>StampAnnotProperty.xaml</DependentUpon>
     </Compile>
@@ -1312,6 +1316,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\PropertyPanel\AnnotPanel\SignatureAnnotProperty.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\PropertyPanel\AnnotPanel\StampAnnotProperty.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

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

@@ -0,0 +1,36 @@
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
+{
+    class SignatureAnnotPropertyViewModel : BindableBase, INavigationAware
+    {
+        private CPDFViewer PDFViewer;
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            return;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if (PDFViewer == null)
+            {
+                return;
+            }
+        }
+    }
+}

+ 6 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -566,6 +566,12 @@ namespace PDF_Office.ViewModels.Tools
             return stampAnnotArgs;
         }
 
+        private AnnotHandlerEventArgs GetSignature()
+        {
+            AddToPropertyPanel(null, null, "SignatureAnnotProperty", null);
+            return null;
+        }
+
         private AnnotHandlerEventArgs GetImage(CustomIconToggleBtn annotBtn)
         {
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();

+ 1 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -103,6 +103,7 @@ namespace PDF_Office.ViewModels.Tools
                         break;
 
                     case "Signature":
+                        annotArgs = GetSignature();
                         break;
 
                     case "Link":

+ 13 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/SignatureAnnotProperty.xaml

@@ -0,0 +1,13 @@
+<UserControl x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.SignatureAnnotProperty"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
+             mc:Ignorable="d" >
+    <Grid Background="Red">
+        <Grid Background="Red">
+            
+        </Grid>
+    </Grid>
+</UserControl>

+ 28 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/SignatureAnnotProperty.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.Views.PropertyPanel.AnnotPanel
+{
+    /// <summary>
+    /// SignatureAnnotProperty.xaml 的交互逻辑
+    /// </summary>
+    public partial class SignatureAnnotProperty : UserControl
+    {
+        public SignatureAnnotProperty()
+        {
+            InitializeComponent();
+        }
+    }
+}