AddCertificationDialog.xaml.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace Compdfkit_Tools.PDFControl
  15. {
  16. /// <summary>
  17. /// Interaction logic for AddCertificationDialog.xaml
  18. /// </summary>
  19. public partial class AddCertificationDialog : Window
  20. {
  21. private AddCertificationControl addCertificationControl = null;
  22. private AddCustomCertificationControl addCustomCertificationControl = null;
  23. private AddExistedCertificationControl addExistedCertificationControl = null;
  24. private SaveCerficateControl saveCerficateControl = null;
  25. private string addCertificationControlTitle = "Add Digital Signatures";
  26. private string addExistedCertificationControlTitle = "Add A Digital ID";
  27. private string addCustomCertificationControlTitle = "Customize the Signature";
  28. private string saveCerficateControlTitle = "Save the Self-Signed Digital ID to A File";
  29. public event EventHandler<CertificateAccess> FillSignatureEvent;
  30. public AddCertificationDialog()
  31. {
  32. InitializeComponent();
  33. addCertificationControl = new AddCertificationControl();
  34. BodyBd.Child = addCertificationControl;
  35. Title = addCertificationControlTitle;
  36. }
  37. private void Window_Loaded(object sender, RoutedEventArgs e)
  38. {
  39. addCertificationControl.ContinueEvent -= ContinueEvent;
  40. addCertificationControl.ContinueEvent += ContinueEvent;
  41. addCertificationControl.CancelEvent -= CloseEvent;
  42. addCertificationControl.CancelEvent += CloseEvent;
  43. }
  44. private void ContinueEvent(object sender, CreateCertificationMode e)
  45. {
  46. if(e == CreateCertificationMode.AddExistedCertification)
  47. {
  48. addExistedCertificationControl = new AddExistedCertificationControl();
  49. BodyBd.Child = addExistedCertificationControl;
  50. Title = addExistedCertificationControlTitle;
  51. this.Height = addExistedCertificationControl.Height + 35;
  52. this.Width = addExistedCertificationControl.Width + 20;
  53. addExistedCertificationControl.CancelEvent += CancelEvent;
  54. addExistedCertificationControl.FillSignatureEvent -= FillSignature;
  55. addExistedCertificationControl.FillSignatureEvent += FillSignature;
  56. }
  57. else if(e == CreateCertificationMode.AddCustomCertification)
  58. {
  59. addCustomCertificationControl = new AddCustomCertificationControl();
  60. BodyBd.Child = addCustomCertificationControl;
  61. Title = addCustomCertificationControlTitle;
  62. this.Height = addCustomCertificationControl.Height + 35;
  63. this.Width = addCustomCertificationControl.Width + 20;
  64. addCustomCertificationControl.ContinueEvent -= ContinueEvent;
  65. addCustomCertificationControl.ContinueEvent += ContinueEvent;
  66. addCustomCertificationControl.CancelEvent -= CancelEvent;
  67. addCustomCertificationControl.CancelEvent += CancelEvent;
  68. }
  69. else if (e == CreateCertificationMode.SaveCertificate)
  70. {
  71. saveCerficateControl = new SaveCerficateControl();
  72. saveCerficateControl.CertificateInfo = addCustomCertificationControl.CertificateInfo;
  73. BodyBd.Child = saveCerficateControl;
  74. Title = saveCerficateControlTitle;
  75. this.Height = saveCerficateControl.Height + 20;
  76. this.Width = saveCerficateControl.Width + 20;
  77. saveCerficateControl.FillSignatureEvent -= FillSignature;
  78. saveCerficateControl.FillSignatureEvent += FillSignature;
  79. saveCerficateControl.CancelSaveEvent -= CancelSaveEvent;
  80. saveCerficateControl.CancelSaveEvent += CancelSaveEvent;
  81. }
  82. }
  83. private void FillSignature(object sender, CertificateAccess e)
  84. {
  85. Close();
  86. FillSignatureEvent?.Invoke(sender, e);
  87. }
  88. private void CancelEvent(object sender, EventArgs e)
  89. {
  90. addCertificationControl = new AddCertificationControl();
  91. BodyBd.Child = addCertificationControl;
  92. Title = addCertificationControlTitle;
  93. this.Height = addCertificationControl.Height + 35;
  94. this.Width = addCertificationControl.Width + 20;
  95. addCertificationControl.ContinueEvent -= ContinueEvent;
  96. addCertificationControl.ContinueEvent += ContinueEvent;
  97. addCertificationControl.CancelEvent -= CloseEvent;
  98. addCertificationControl.CancelEvent += CloseEvent;
  99. }
  100. private void CancelSaveEvent(object sender, EventArgs e)
  101. {
  102. BodyBd.Child = addCustomCertificationControl;
  103. Title = addCustomCertificationControlTitle;
  104. this.Height = addCustomCertificationControl.Height + 35;
  105. this.Width = addCustomCertificationControl.Width + 20;
  106. addCustomCertificationControl.ContinueEvent -= ContinueEvent;
  107. addCustomCertificationControl.ContinueEvent += ContinueEvent;
  108. addCustomCertificationControl.CancelEvent -= CancelEvent;
  109. addCustomCertificationControl.CancelEvent += CancelEvent;
  110. }
  111. private void CloseEvent(object sender, EventArgs e)
  112. {
  113. Close();
  114. }
  115. }
  116. }