123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- using ComPDFKit.PDFDocument;
- using PDF_Master.Properties;
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Master.Helper
- {
-
-
-
-
-
- public class CacheFilePath : BindableBase
- {
- private static CacheFilePath instance = new CacheFilePath();
-
-
-
- List<string> CustomStamp = new List<string> { "CustomStamp" };
- List<string> SignatureFreeHand = new List<string> { "Signature", "FreeHand" };
- List<string> SignatureStamp = new List<string> { "Signature", "Stamp" };
- List<string> MergeFile = new List<string> { "Temp" };
-
-
-
- List<string> GuidPDF = new List<string>() { "GuidPDF" };
-
-
-
- List<string> ScanFile = new List<string> { "ScanTemp" };
- private List<string> CreatedFile = new List<string>() { "CreatedFile"};
-
-
-
- List<string> ADFile = new List<string> { "ADTemp" };
- private CPDFDocument copyDoc;
-
-
-
- public CPDFDocument CopyDoc
- {
- get { return copyDoc; }
- set
- {
- SetProperty(ref copyDoc, value);
- }
- }
- public static CacheFilePath Instance => instance;
- private CacheFilePath()
- {
- }
- ~CacheFilePath()
- {
- if (CopyDoc != null)
- {
- CopyDoc.Release();
- }
- }
-
-
-
- public string CustomStampPath
- {
- get
- {
- return CreateCacheDirectory(CustomStamp);
- }
- }
-
-
-
- public string SignatureStampPath
- {
- get
- {
- return CreateCacheDirectory(SignatureStamp);
- }
- }
-
-
-
- public string SignatureFreeHandPath
- {
- get
- {
- return CreateCacheDirectory(SignatureFreeHand);
- }
- }
-
-
-
- public string MergeFilePath
- {
- get
- {
- return CreateCacheDirectory(MergeFile);
- }
- }
-
-
-
- public string ScanFilePath
- {
- get
- {
- return CreateCacheDirectory(ScanFile);
- }
- }
-
-
-
- public string ADFilePath
- {
- get
- {
- return CreateCacheDirectory(ADFile);
- }
- }
-
-
-
- public string CreatedFilePath
- {
- get
- {
- return CreateCacheDirectory(CreatedFile);
- }
- }
- public string GuidPDFPath
- {
- get
- {
- return CreateCacheDirectory(GuidPDF);
- }
- }
-
-
-
-
-
- private string CreateCacheDirectory(List<string> directoryName)
- {
- try
- {
- 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
- && (directoryInfo.Attributes & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden
- )
- {
- return Path;
- }
- else
- {
- return "";
- }
- }
- catch (Exception)
- {
- return "";
- }
- }
-
-
-
-
- public void AddToDeleteFiles(string file)
- {
-
- try
- {
- if (!Settings.Default.AppProperties.NeedToDeletePath.Contains(file))
- {
- Settings.Default.AppProperties.NeedToDeletePath.Add(file);
- }
- Settings.Default.Save();
-
- Settings.Default.Reload();
- }
- catch { }
- }
- public void AddToDeleteFiles(List<string> files)
- {
- foreach (string file in files)
- {
- AddToDeleteFiles(file);
- }
- }
-
-
-
- public void ClearDeleteFiles()
- {
- try
- {
- foreach (string file in Settings.Default.AppProperties.NeedToDeletePath)
- {
- if (File.Exists(file))
- {
- File.Delete(file);
- }
- }
- Settings.Default.AppProperties.NeedToDeletePath.Clear();
-
- string ScanTempPath = Path.Combine(App.CurrentPath, "ScanTemp");
- DirectoryInfo Scantempfolder = new DirectoryInfo(ScanTempPath);
- if (Scantempfolder.Exists)
- {
- Directory.Delete(ScanTempPath, true);
- }
-
- string TempPath= Path.Combine(App.CurrentPath, "Temp");
- DirectoryInfo tempfolder = new DirectoryInfo(TempPath);
- if (tempfolder.Exists)
- {
- Directory.Delete(TempPath, true);
- }
-
- string CreatedFilePath = Path.Combine(App.CurrentPath, CreatedFile[0]);
- DirectoryInfo CreatedFilePathFolder = new DirectoryInfo(CreatedFilePath);
- if (CreatedFilePathFolder.Exists)
- {
- Directory.Delete(CreatedFilePath, true);
- }
- }
- catch { }
- }
- }
- }
|