HomePageControl.xaml.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using ComPDFKit.Controls.Helper;
  17. using Path = System.Windows.Shapes.Path;
  18. namespace ComPDFKit.Controls.PDFControl
  19. {
  20. /// <summary>
  21. /// Interaction logic for HomePageControl.xaml
  22. /// </summary>
  23. public partial class HomePageControl : UserControl
  24. {
  25. private const string AnnotationFileName = @"TestFile\ComPDFKit_Annotations_Sample_File.pdf";
  26. private const string FormFileName = @"TestFile\ComPDFKit_Forms_Sample_File.pdf";
  27. private const string SignatureFileName = @"TestFile\ComPDFKit_Signatures_Sample_File.pdf";
  28. private const string MeasurementFileName = @"TestFile\ComPDFKit_Measurement_Sample_File.pdf";
  29. private const string SampleFileName = @"TestFile\ComPDFKit_Sample_File_Windows.pdf";
  30. private const string WatermarkFileName = @"TestFile\ComPDFKit_Watermark_Sample_File.pdf";
  31. private const string PasswordFileName = @"TestFile\Password_compdfkit_Security_Sample_File.pdf";
  32. private readonly Canvas viewerCanvas = new Canvas();
  33. private readonly Canvas annotationsCanvas = new Canvas();
  34. private readonly Canvas formsCanvas = new Canvas();
  35. private readonly Canvas signatureCanvas = new Canvas();
  36. private readonly Canvas documentEditorCanvas = new Canvas();
  37. private readonly Canvas contentEditorCanvas = new Canvas();
  38. private readonly Canvas securityCanvas = new Canvas();
  39. private readonly Canvas redactionCanvas = new Canvas();
  40. private readonly Canvas watermarkCanvas = new Canvas();
  41. private readonly Canvas compareDocumentsCanvas = new Canvas();
  42. private readonly Canvas conversionCanvas = new Canvas();
  43. private readonly Canvas compressCanvas = new Canvas();
  44. private readonly Canvas measurementCanvas = new Canvas();
  45. private List<CustomItem> customItems;
  46. /// <summary>
  47. /// Open file event.
  48. /// param: Whether to create a file
  49. /// </summary>
  50. public event EventHandler<OpenFileEventArgs> OpenFileEvent;
  51. public HomePageControl()
  52. {
  53. InitializeComponent();
  54. RecentFilesControl.OpenFileEvent += (sender, args) =>
  55. {
  56. OpenFileEvent?.Invoke(this, args);
  57. };
  58. InitFeatureList();
  59. }
  60. private void InitFeatureList()
  61. {
  62. CreatFeatureIcon();
  63. CreateCustomItems();
  64. ImportFeatures();
  65. UseTheScrollViewerScrolling(FeaturesListControl);
  66. }
  67. private void ImportFeatures()
  68. {
  69. if (FeaturesListControl != null)
  70. {
  71. foreach (CustomItem item in customItems)
  72. {
  73. FeaturesListControl.Items.Add(item);
  74. }
  75. }
  76. FeaturesListControl.SelectionChanged -= FeaturesListControl_SelectionChanged;
  77. FeaturesListControl.SelectionChanged += FeaturesListControl_SelectionChanged;
  78. }
  79. private void FeaturesListControl_SelectionChanged(object sender, CustomItem e)
  80. {
  81. var parentWindow = Window.GetWindow(this);
  82. switch (e.Feature)
  83. {
  84. case "Viewer":
  85. {
  86. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, SampleFileName, e.Feature));
  87. break;
  88. }
  89. case "Annotations":
  90. {
  91. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, AnnotationFileName, e.Feature));
  92. break;
  93. }
  94. case "Forms":
  95. {
  96. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, FormFileName, e.Feature));
  97. break;
  98. }
  99. case "Signatures":
  100. {
  101. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, SignatureFileName, e.Feature));
  102. break;
  103. }
  104. case "Document Editor":
  105. {
  106. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, SampleFileName , e.Feature));
  107. break;
  108. }
  109. case "Content Editor":
  110. {
  111. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, SampleFileName, e.Feature));
  112. break;
  113. }
  114. case "Watermark":
  115. {
  116. WatermarkOperationTypeDialog watermarkOperationTypeDialog = new WatermarkOperationTypeDialog()
  117. {
  118. Owner = parentWindow
  119. };
  120. watermarkOperationTypeDialog.ShowDialog();
  121. break;
  122. }
  123. case "Security":
  124. {
  125. SecurityOperationTypeDialog securityOperationTypeDialog = new SecurityOperationTypeDialog()
  126. {
  127. Owner = parentWindow
  128. };
  129. securityOperationTypeDialog.ShowDialog();
  130. break;
  131. }
  132. case "Redaction":
  133. {
  134. System.Diagnostics.Process.Start("https://www.compdf.com/pdf-sdk/security");
  135. break;
  136. }
  137. case "Compare Documents":
  138. {
  139. System.Diagnostics.Process.Start("https://www.compdf.com/pdf-sdk/document-comparison");
  140. break;
  141. }
  142. case "Conversion":
  143. {
  144. System.Diagnostics.Process.Start("https://www.compdf.com/conversion");
  145. break;
  146. }
  147. case "Compress":
  148. {
  149. System.Diagnostics.Process.Start("https://www.compdf.com/contact-sales");
  150. break;
  151. }
  152. case "Measurement":
  153. {
  154. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, MeasurementFileName, e.Feature));
  155. break;
  156. }
  157. default:
  158. break;
  159. }
  160. }
  161. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  162. {
  163. }
  164. private void UseTheScrollViewerScrolling(FrameworkElement fElement)
  165. {
  166. fElement.PreviewMouseWheel += (sender, e) =>
  167. {
  168. var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
  169. eventArg.RoutedEvent = UIElement.MouseWheelEvent;
  170. eventArg.Source = sender;
  171. fElement.RaiseEvent(eventArg);
  172. };
  173. }
  174. private void CreateCustomItems()
  175. {
  176. customItems = new List<CustomItem>()
  177. {
  178. new CustomItem{ IconCanvas = viewerCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Viewer"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Viewer"), Feature = "Viewer"},
  179. new CustomItem{ IconCanvas = annotationsCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Annotations"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Annotations"), Feature = "Annotations"},
  180. new CustomItem{ IconCanvas = formsCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Forms"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Forms"), Feature = "Forms"},
  181. new CustomItem{ IconCanvas = signatureCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Signatures"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Signatures"), Feature = "Signatures"},
  182. new CustomItem{ IconCanvas = documentEditorCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_DocEditor"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_DocEditor"), Feature = "Document Editor"},
  183. new CustomItem{ IconCanvas = contentEditorCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_ContentEditor"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_ContentEditor"), Feature = "Content Editor"},
  184. new CustomItem{ IconCanvas = watermarkCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Watermark"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Watermark"), Feature = "Watermark"},
  185. new CustomItem{ IconCanvas = securityCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Security"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Security"), Feature = "Security"},
  186. new CustomItem{ IconCanvas = redactionCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Redaction"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Redaction"), Feature = "Redaction"},
  187. new CustomItem{ IconCanvas = compareDocumentsCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_DocCompare"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_DocCompare"), Feature = "Compare Documents"},
  188. new CustomItem{ IconCanvas = conversionCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Conversion"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Conversion"), Feature = "Conversion"},
  189. new CustomItem{ IconCanvas = compressCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Compress"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Compress"), Feature = "Compress"},
  190. new CustomItem{ IconCanvas = measurementCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Measurement"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Measurement"), Feature = "Measurement"},
  191. };
  192. }
  193. private void CreatFeatureIcon()
  194. {
  195. //Viewer
  196. {
  197. Path path1 = new Path
  198. {
  199. Data = Geometry.Parse("M13.2071 1.5H2.5V18.5H17.5V5.79289L13.2071 1.5Z"),
  200. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#80477EDE")),
  201. Clip = new RectangleGeometry(new Rect(0, 0, 20, 20))
  202. };
  203. Path path2 = new Path
  204. {
  205. Data = Geometry.Parse("M4.5 3.5H12.5L15.5 6.5V16.5H4.5L4.5 3.5Z"),
  206. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  207. };
  208. Path path3 = new Path
  209. {
  210. Data = Geometry.Parse("M9.95833 12.75C11.6763 12.75 13.1387 11.2833 13.6862 10.6551C13.8279 10.4925 13.8279 10.2575 13.6862 10.0949C13.1387 9.46673 11.6763 8 9.95833 8C8.24035 8 6.778 9.46673 6.23047 10.0949C6.08878 10.2575 6.08878 10.4925 6.23047 10.6551C6.778 11.2833 8.24035 12.75 9.95833 12.75Z"),
  211. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"))
  212. };
  213. Path path4 = new Path
  214. {
  215. Data = Geometry.Parse("M9.95833 11.3639C10.5049 11.3639 10.9479 10.9209 10.9479 10.3743C10.9479 9.82782 10.5049 9.38477 9.95833 9.38477C9.41181 9.38477 8.96875 9.82782 8.96875 10.3743C8.96875 10.9209 9.41181 11.3639 9.95833 11.3639Z"),
  216. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE"))
  217. };
  218. viewerCanvas.Children.Add(path1);
  219. viewerCanvas.Children.Add(path2);
  220. viewerCanvas.Children.Add(path3);
  221. viewerCanvas.Children.Add(path4);
  222. }
  223. // Annotations
  224. {
  225. Path path1 = new Path
  226. {
  227. Data = Geometry.Parse("M11.2071 0.5H0.5V17.5H15.5V4.79289L11.2071 0.5Z"),
  228. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#806675FE")),
  229. };
  230. Path path2 = new Path
  231. {
  232. Data = Geometry.Parse("M2.5 2.5H10.5L13.5 5.5V15.5H2.5L2.5 2.5Z"),
  233. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6675FE")),
  234. };
  235. Path path3 = new Path
  236. {
  237. Data = Geometry.Parse("M8.81755 12.6459C8.71612 12.559 8.56646 12.559 8.46503 12.6459L8.32746 12.7639C8.02318 13.0247 7.57419 13.0247 7.26991 12.7639L7.13234 12.6459C7.03091 12.559 6.88125 12.559 6.77982 12.6459L6.59593 12.8036C6.32336 13.0372 5.92977 13.0643 5.62778 12.8701L5.12441 12.5465C4.99859 12.4656 4.96216 12.2981 5.04305 12.1722C5.12393 12.0464 5.2915 12.01 5.41733 12.0909L5.9207 12.4145C6.02136 12.4792 6.15256 12.4702 6.24341 12.3923L6.4273 12.2347C6.73158 11.9739 7.18058 11.9739 7.48486 12.2347L7.62243 12.3526C7.72385 12.4395 7.87352 12.4395 7.97494 12.3526L8.11251 12.2347C8.41679 11.9739 8.86579 11.9739 9.17006 12.2347L9.35396 12.3923C9.44481 12.4702 9.57601 12.4792 9.67667 12.4145L10.18 12.0909C10.3059 12.01 10.4734 12.0464 10.5543 12.1722C10.6352 12.2981 10.5988 12.4656 10.473 12.5465L9.96959 12.8701C9.6676 13.0643 9.27401 13.0372 9.00144 12.8036L8.81755 12.6459Z"),
  238. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"))
  239. };
  240. Path path4 = new Path
  241. {
  242. Data = Geometry.Parse("M10.5066 6V7.15097H8.50593V11.0556H7.09957V7.15097H5.08984V6H10.5066Z"),
  243. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"))
  244. };
  245. annotationsCanvas.Children.Add(path1);
  246. annotationsCanvas.Children.Add(path2);
  247. annotationsCanvas.Children.Add(path3);
  248. annotationsCanvas.Children.Add(path4);
  249. }
  250. // Forms
  251. {
  252. Path path1 = new Path
  253. {
  254. Data = Geometry.Parse("M6.12502 4.25H1.90628V6.76817H6.12502V4.25ZM0.500028 3.55233V1.19767C0.500028 0.81236 0.812387 0.5 1.1977 0.5H14.8024C15.1877 0.5 15.5 0.81236 15.5 1.19767V3.55233V14.8023C15.5 15.1876 15.1877 15.5 14.8024 15.5H1.1977C0.812388 15.5 0.500028 15.1876 0.500028 14.8023V8.17442H0.5V6.76817H0.500028V3.55233ZM7.53127 4.25H14.0938V6.76817H7.53127V4.25ZM1.90628 8.17442H6.12502V14.0938H1.90628V8.17442ZM7.53127 14.0938H14.0938V8.17442H7.53127V14.0938ZM13.2437 9.73906C13.3232 9.81854 13.3232 9.94741 13.2437 10.0269L10.7112 12.5594C10.4552 12.8154 10.0403 12.8154 9.78432 12.5594L8.37532 11.1504C8.29584 11.071 8.29584 10.9421 8.37532 10.8626L8.74955 10.4884C8.82903 10.4089 8.9579 10.4089 9.03738 10.4884L10.2478 11.6988L12.5817 9.36484C12.6612 9.28535 12.79 9.28535 12.8695 9.36484L13.2437 9.73906Z"),
  255. Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff")),
  256. };
  257. Path path2 = new Path
  258. {
  259. Data = Geometry.Parse("M6.12502 4.25H1.90628V6.76817H6.12502V4.25ZM0.500028 3.55233V1.19767C0.500028 0.81236 0.812387 0.5 1.1977 0.5H14.8024C15.1877 0.5 15.5 0.81236 15.5 1.19767V3.55233V14.8023C15.5 15.1876 15.1877 15.5 14.8024 15.5H1.1977C0.812388 15.5 0.500028 15.1876 0.500028 14.8023V8.17442H0.5V6.76817H0.500028V3.55233ZM7.53127 4.25H14.0938V6.76817H7.53127V4.25ZM1.90628 8.17442H6.12502V14.0938H1.90628V8.17442ZM7.53127 14.0938H14.0938V8.17442H7.53127V14.0938ZM13.2437 9.73906C13.3232 9.81854 13.3232 9.94741 13.2437 10.0269L10.7112 12.5594C10.4552 12.8154 10.0403 12.8154 9.78432 12.5594L8.37532 11.1504C8.29584 11.071 8.29584 10.9421 8.37532 10.8626L8.74955 10.4884C8.82903 10.4089 8.9579 10.4089 9.03738 10.4884L10.2478 11.6988L12.5817 9.36484C12.6612 9.28535 12.79 9.28535 12.8695 9.36484L13.2437 9.73906Z"),
  260. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  261. };
  262. formsCanvas.Children.Add(path1);
  263. formsCanvas.Children.Add(path2);
  264. }
  265. // Signature
  266. {
  267. Path path1 = new Path
  268. {
  269. Data = Geometry.Parse("M11.4771 3.16735C11.6151 2.96809 11.8998 2.94242 12.0712 3.11378L15.2582 6.30084C15.4296 6.4722 15.4039 6.75692 15.2047 6.89487L12.0633 9.06966C12.0332 9.09048 12.0114 9.12124 12.0018 9.15653L11.2248 12.0057C11.2059 12.0747 11.143 12.123 11.0717 12.1277C10.7929 12.1458 10.0064 12.2356 8.44611 12.6725C7.06518 13.0592 5.39632 13.8125 4.47439 14.2527C4.61684 14.5428 4.56744 14.9032 4.32618 15.1445C4.0228 15.4479 3.53092 15.4479 3.22754 15.1445C2.92415 14.8411 2.92415 14.3492 3.22754 14.0458C3.46379 13.8096 3.81435 13.7573 4.10119 13.889C4.57233 12.8495 5.42026 10.9231 5.69949 9.92588C6.02875 8.74998 6.19116 7.62277 6.23578 7.28285C6.24404 7.21992 6.28895 7.16832 6.35019 7.15162L9.21546 6.37018C9.25075 6.36056 9.28151 6.33879 9.30233 6.30872L11.4771 3.16735ZM14.7596 14.6595C14.7015 14.6633 14.6428 14.6651 14.5837 14.6651C14.5253 14.6651 14.4673 14.6633 14.4098 14.6597L13.209 16.7396C13.148 16.8452 12.9948 16.8427 12.9374 16.7352L12.4679 15.8567C12.44 15.8045 12.3849 15.7726 12.3258 15.7746L11.3303 15.8073C11.2084 15.8113 11.1297 15.6799 11.1906 15.5743L12.372 13.5281C12.0527 13.0824 11.8647 12.5362 11.8647 11.9461C11.8647 10.4445 13.082 9.22712 14.5837 9.22712C16.0854 9.22712 17.3027 10.4445 17.3027 11.9461C17.3027 12.5355 17.1152 13.0811 16.7966 13.5264L17.9789 15.5743C18.0399 15.6799 17.9611 15.8113 17.8393 15.8073L16.8437 15.7746C16.7846 15.7726 16.7295 15.8045 16.7016 15.8567L16.2322 16.7352C16.1747 16.8427 16.0215 16.8452 15.9606 16.7396L14.7596 14.6595Z"),
  270. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6675FE")),
  271. };
  272. Path path2 = new Path
  273. {
  274. Data = Geometry.Parse("M8.66951 8.63805C8.69551 8.59472 8.75532 8.58735 8.79106 8.62309L9.74899 9.58102C9.78473 9.61676 9.77737 9.67657 9.73403 9.70257L7.33919 11.1395C7.26984 11.1811 7.191 11.1022 7.23261 11.0329L8.66951 8.63805Z"),
  275. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff")),
  276. };
  277. signatureCanvas.Children.Add(path1);
  278. signatureCanvas.Children.Add(path2);
  279. }
  280. // Document Editor
  281. {
  282. Path path1 = new Path
  283. {
  284. Data = Geometry.Parse("M8.6 17.5H15.5V9.6H8.6V17.5ZM15.5 8.4V0.5H8.6V8.4H15.5ZM7.4 17.5V9.6H0.5V17.5H7.4ZM0.5 8.4H7.4V0.5H0.5V8.4Z"),
  285. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  286. };
  287. documentEditorCanvas.Children.Add(path1);
  288. }
  289. // Content Editor
  290. {
  291. Path path1 = new Path
  292. {
  293. Data = Geometry.Parse("M4.13281 15.8681V4.13281H15.8681V15.8681H4.13281Z"),
  294. Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F08E26")),
  295. StrokeThickness = 1.5
  296. };
  297. Path path2 = new Path
  298. {
  299. Data = Geometry.Parse("M6.42546 6.0293C6.33775 6.0293 6.26664 6.1004 6.26664 6.18812V6.7528C6.26664 6.84051 6.33775 6.91162 6.42546 6.91162H8.83596C8.92368 6.91162 8.99478 6.84051 8.99478 6.7528V6.18812C8.99478 6.1004 8.92368 6.0293 8.83596 6.0293H6.42546ZM10.1456 6.02938C10.0579 6.02938 9.98679 6.10049 9.98679 6.1882V8.51753C9.98679 8.60524 10.0579 8.67635 10.1456 8.67635H13.5482C13.6359 8.67635 13.707 8.60524 13.707 8.51753V6.1882C13.707 6.10049 13.6359 6.02938 13.5482 6.02938H10.1456ZM6.2666 7.95299C6.2666 7.86527 6.33771 7.79416 6.42543 7.79416H8.83592C8.92364 7.79416 8.99475 7.86527 8.99475 7.95299V8.51766C8.99475 8.60538 8.92364 8.67649 8.83592 8.67649H6.42543C6.33771 8.67649 6.2666 8.60538 6.2666 8.51766V7.95299ZM6.42543 9.55876C6.33771 9.55876 6.2666 9.62987 6.2666 9.71759V10.2823C6.2666 10.37 6.33771 10.4411 6.42542 10.4411H13.5482C13.6359 10.4411 13.707 10.37 13.707 10.2823V9.71759C13.707 9.62987 13.6359 9.55876 13.5482 9.55876H6.42543ZM6.2666 11.4822C6.2666 11.3945 6.33771 11.3234 6.42543 11.3234H13.5482C13.6359 11.3234 13.707 11.3945 13.707 11.4822V12.0469C13.707 12.1346 13.6359 12.2057 13.5482 12.2057H6.42542C6.33771 12.2057 6.2666 12.1346 6.2666 12.0469V11.4822ZM6.42543 13.0881C6.33771 13.0881 6.2666 13.1593 6.2666 13.247V13.8116C6.2666 13.8994 6.33771 13.9705 6.42542 13.9705H11.3161C11.4038 13.9705 11.4749 13.8994 11.4749 13.8116V13.247C11.4749 13.1593 11.4038 13.0881 11.3161 13.0881H6.42543Z"),
  300. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F08E26")),
  301. };
  302. for (int i = 0; i < 4; i++)
  303. {
  304. Rectangle rectangle = new Rectangle
  305. {
  306. Width = 2.64706,
  307. Height = 2.64706,
  308. RadiusX = 0.441176,
  309. RadiusY = 0.441176,
  310. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F08E26")),
  311. Opacity = 0.5
  312. };
  313. switch (i)
  314. {
  315. case 0:
  316. Canvas.SetLeft(rectangle, 2.5);
  317. Canvas.SetTop(rectangle, 2.5);
  318. break;
  319. case 1:
  320. Canvas.SetLeft(rectangle, 14.8525);
  321. Canvas.SetTop(rectangle, 2.5);
  322. break;
  323. case 2:
  324. Canvas.SetLeft(rectangle, 2.5);
  325. Canvas.SetTop(rectangle, 14.8535);
  326. break;
  327. case 3:
  328. Canvas.SetLeft(rectangle, 14.8525);
  329. Canvas.SetTop(rectangle, 14.8535);
  330. break;
  331. }
  332. contentEditorCanvas.Children.Add(rectangle);
  333. }
  334. contentEditorCanvas.Children.Add(path1);
  335. contentEditorCanvas.Children.Add(path2);
  336. }
  337. // Watermark
  338. {
  339. Path path1 = new Path
  340. {
  341. Data = Geometry.Parse("M13.2071 1.5H2.5V18.5H17.5V5.79289L13.2071 1.5Z"),
  342. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6675FE")),
  343. Opacity = 0.5,
  344. };
  345. Path path2 = new Path
  346. {
  347. Data = Geometry.Parse("M4.5 3.5H12.5L15.5 6.5V16.5H4.5L4.5 3.5Z"),
  348. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6675FE")),
  349. };
  350. Path path3 = new Path
  351. {
  352. Data = Geometry.Parse("M11.168 12.1729C10.8242 12.7637 10.2119 13.0967 9.43848 13.0967C8.32666 13.0967 7.50488 12.4199 7.50488 11.3618V11.3511C7.50488 10.3091 8.28906 9.70215 9.68018 9.61621L11.2593 9.5249V9.00928C11.2593 8.37012 10.8564 8.01562 10.0669 8.01562C9.42236 8.01562 8.99805 8.25195 8.8584 8.66553L8.85303 8.68701H7.73047L7.73584 8.64941C7.87549 7.69336 8.79395 7.0542 10.1206 7.0542C11.5869 7.0542 12.4141 7.78467 12.4141 9.00928V13H11.2593V12.1729H11.168ZM8.66504 11.3135C8.66504 11.8506 9.12158 12.1675 9.75 12.1675C10.6201 12.1675 11.2593 11.5981 11.2593 10.8462V10.3467L9.83594 10.438C9.03027 10.4863 8.66504 10.7764 8.66504 11.3027V11.3135Z"),
  353. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"))
  354. };
  355. watermarkCanvas.Children.Add(path1);
  356. watermarkCanvas.Children.Add(path2);
  357. watermarkCanvas.Children.Add(path3);
  358. }
  359. // Security
  360. {
  361. Path path1 = new Path
  362. {
  363. Data = Geometry.Parse("M10.3071 0.225716L9.99547 0L9.68692 0.230128C8.51956 1.1008 7.30957 1.81198 6.05658 2.36432C4.80991 2.91388 3.61227 3.26584 2.46352 3.42184L2 3.48479V9.32316C2 12.3349 3.41409 15.1613 5.79677 16.9119L10 20L14.2032 16.9119C16.5859 15.1613 18 12.3349 18 9.32316V3.49464L17.5473 3.42343C16.3019 3.22754 15.101 2.8746 13.9434 2.36432C12.7803 1.85161 11.5679 1.139 10.3071 0.225716Z"),
  364. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  365. Opacity = 0.5,
  366. };
  367. Path path2 = new Path
  368. {
  369. Data = Geometry.Parse("M10.2303 2.66929L9.9966 2.5L9.76519 2.6726C8.88967 3.3256 7.98218 3.85898 7.04243 4.27324C6.10743 4.68541 5.20921 4.94938 4.34764 5.06638L4 5.11359V9.49237C4 11.7512 5.06057 13.871 6.84758 15.1839L10 17.5L13.1524 15.1839C14.9394 13.871 16 11.7512 16 9.49237V5.12098L15.6605 5.06757C14.7265 4.92065 13.8257 4.65595 12.9576 4.27324C12.0852 3.88871 11.1759 3.35425 10.2303 2.66929Z"),
  370. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  371. };
  372. securityCanvas.Children.Add(path1);
  373. securityCanvas.Children.Add(path2);
  374. }
  375. //Redaction
  376. {
  377. Path path1 = new Path
  378. {
  379. Data = Geometry.Parse("M13.2071 1.5H2.5V18.5H17.5V5.79289L13.2071 1.5Z"),
  380. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6675FE")),
  381. Opacity = 0.5,
  382. };
  383. Path path2 = new Path
  384. {
  385. Data = Geometry.Parse("M4.5 3.5H12.5L15.5 6.5V16.5H4.5L4.5 3.5Z"),
  386. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6675FE")),
  387. };
  388. Rectangle rectangle = new Rectangle
  389. {
  390. Width = 10,
  391. Height = 3,
  392. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff")),
  393. };
  394. Canvas.SetLeft(rectangle, 5);
  395. Canvas.SetTop(rectangle, 8);
  396. redactionCanvas.Children.Add(path1);
  397. redactionCanvas.Children.Add(path2);
  398. redactionCanvas.Children.Add(rectangle);
  399. }
  400. // Compare Documents
  401. {
  402. Path path1 = new Path
  403. {
  404. Data = Geometry.Parse("M0 0.5H7L8.5 2.10714L10 3.71429V15.5H0V0.5Z"),
  405. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  406. };
  407. Path path2 = new Path
  408. {
  409. Data = Geometry.Parse("M4.05861 11L2.28516 5.36324H3.92189L4.94924 9.47655H5.02346L6.0469 5.36324H7.68363L5.91018 11H4.05861Z"),
  410. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff")),
  411. };
  412. Path path3 = new Path
  413. {
  414. Data = Geometry.Parse("M10 0.5H17L18.5 2.10714L20 3.71429V15.5H10V0.5Z"),
  415. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  416. };
  417. Path path4 = new Path
  418. {
  419. Data = Geometry.Parse("M14.8291 11.1523C13.4229 11.1523 12.54 10.5117 12.4814 9.46483L12.4775 9.39452H13.8447L13.8486 9.42968C13.8877 9.77734 14.2744 10.0273 14.8526 10.0273C15.4112 10.0273 15.7783 9.77343 15.7783 9.41405V9.41015C15.7783 9.09374 15.5283 8.9453 14.8682 8.81639L14.2861 8.70311C13.0947 8.47264 12.5791 7.91014 12.5791 7.03122V7.02732C12.583 5.92184 13.5205 5.2109 14.8174 5.2109C16.2315 5.2109 17.001 5.92575 17.0869 6.92185L17.0909 6.96872H15.7627L15.7549 6.92185C15.6963 6.57028 15.3447 6.33591 14.8252 6.33591C14.3096 6.33591 14.0049 6.56638 14.0049 6.90232V6.90622C14.0049 7.22654 14.2627 7.40232 14.8721 7.52342L15.4541 7.6367C16.6533 7.87107 17.2002 8.35155 17.2002 9.26171V9.26561C17.2002 10.418 16.3135 11.1523 14.8291 11.1523Z"),
  420. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff")),
  421. };
  422. compareDocumentsCanvas.Children.Add(path1);
  423. compareDocumentsCanvas.Children.Add(path2);
  424. compareDocumentsCanvas.Children.Add(path3);
  425. compareDocumentsCanvas.Children.Add(path4);
  426. }
  427. // Conversion
  428. {
  429. Path path1 = new Path
  430. {
  431. Data = Geometry.Parse("M17.0999 12.5541V1.40002H3.50348V2.60002H15.8999L15.8999 12.5482L14.4238 11.0753L13.5762 11.9248L16.5069 14.8486L19.4248 11.9238L18.5752 11.0763L17.0999 12.5541ZM4.1028 17.4001L4.10331 7.45219L5.57574 8.92429L6.42427 8.07576L3.50001 5.1515L0.575745 8.07576L1.42427 8.92429L2.90338 7.44552V18.6001H16.4998V17.4001H4.1028Z"),
  432. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  433. Opacity = 0.5,
  434. };
  435. Path path2 = new Path
  436. {
  437. Data = Geometry.Parse("M11.6667 5H6V15H14V6.75L11.6667 5Z"),
  438. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE")),
  439. };
  440. conversionCanvas.Children.Add(path1);
  441. conversionCanvas.Children.Add(path2);
  442. }
  443. // Compress
  444. {
  445. Path path1 = new Path
  446. {
  447. Data = Geometry.Parse("M12.5 1.5H2.5V18.5H17.5V6.5H12.5V1.5Z"),
  448. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F08E26")),
  449. };
  450. Path path2 = new Path
  451. {
  452. Data = Geometry.Parse("M13.5 1.20703L17.793 5.50003H13.5V1.20703Z"),
  453. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F08E26")),
  454. };
  455. Path path3 = new Path
  456. {
  457. Data = Geometry.Parse("M6.90456 5.5H8.30912V6.4364H6.90456V5.5ZM5.5 6.43652H6.90456V7.37292H5.5V6.43652ZM8.3091 7.37264V8.30902H6.90454V7.37262L8.3091 7.37264ZM6.90456 8.30912V9.2455H5.5V8.3091L6.90456 8.30912ZM8.3091 9.24569V10.1821H6.90454V9.24567L8.3091 9.24569ZM6.90456 10.1817V11.1181H5.5V10.1817H6.90456ZM6.90456 12.0546H5.5V15.8001H8.30912V11.1183H6.90456V12.0546ZM5.9682 14.8637V13.9273H7.84094V14.8637H5.9682Z"),
  458. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff")),
  459. };
  460. compressCanvas.Children.Add(path1);
  461. compressCanvas.Children.Add(path2);
  462. compressCanvas.Children.Add(path3);
  463. }
  464. // Measurement
  465. {
  466. Path path1 = new Path
  467. {
  468. Data = Geometry.Parse("M15.1176 11.6606V15.1176H11.6606L15.1176 11.6606ZM15.1176 9.53924L9.53927 15.1176H5.88235L15.1176 5.88232V9.53924ZM13.9963 4.88232L4.88235 13.9963V10.8959L10.8781 4.90008C10.8838 4.89446 10.8889 4.88852 10.8935 4.88232H13.9963ZM8.77457 4.88232H4.88235V8.77454L8.77457 4.88232ZM3.38235 3.8235C3.38235 3.57985 3.57988 3.38232 3.82353 3.38232H16.1765C16.4201 3.38232 16.6176 3.57985 16.6176 3.8235V16.1764C16.6176 16.4201 16.4201 16.6176 16.1765 16.6176H3.82353C3.57988 16.6176 3.38235 16.4201 3.38235 16.1764V3.8235Z"),
  469. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00CC92")),
  470. };
  471. for (int i = 0; i < 4; i++)
  472. {
  473. Rectangle rectangle = new Rectangle
  474. {
  475. Width = 2.64706,
  476. Height = 2.64706,
  477. RadiusX = 0.441176,
  478. RadiusY = 0.441176,
  479. Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00CC92")),
  480. Opacity = 0.5
  481. };
  482. switch (i)
  483. {
  484. case 0:
  485. Canvas.SetLeft(rectangle, 2.5);
  486. Canvas.SetTop(rectangle, 2.5);
  487. break;
  488. case 1:
  489. Canvas.SetLeft(rectangle, 14.8525);
  490. Canvas.SetTop(rectangle, 2.5);
  491. break;
  492. case 2:
  493. Canvas.SetLeft(rectangle, 2.5);
  494. Canvas.SetTop(rectangle, 14.8535);
  495. break;
  496. case 3:
  497. Canvas.SetLeft(rectangle, 14.8525);
  498. Canvas.SetTop(rectangle, 14.8535);
  499. break;
  500. }
  501. measurementCanvas.Children.Add(rectangle);
  502. }
  503. measurementCanvas.Children.Add(path1);
  504. }
  505. }
  506. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  507. {
  508. }
  509. private void CreateDocument_Click(object sender, RoutedEventArgs e)
  510. {
  511. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.CreateNewFile));
  512. }
  513. private void OpenDocument_Click(object sender, RoutedEventArgs e)
  514. {
  515. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDialog));
  516. }
  517. }
  518. public class OpenFileEventArgs : EventArgs
  519. {
  520. public string FilePath { get; set; }
  521. public FileOperationType OperationType { get; set; }
  522. public string FeatureName { get; set; } = string.Empty;
  523. public OpenFileEventArgs(FileOperationType operationType, string filePath = "", string featureName = "")
  524. {
  525. OperationType = operationType;
  526. FilePath = filePath;
  527. FeatureName = featureName;
  528. }
  529. }
  530. public enum FileOperationType
  531. {
  532. CreateNewFile,
  533. OpenFileDialog,
  534. OpenFileDirectly
  535. }
  536. }