AddCertificationDialog.xaml.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 SaveCertificateControl saveCertificateControl = null;
  25. private string addCertificationControlTitle = Helper.LanguageHelper.SigManager.GetString("Title_AddDigitalSign");
  26. private string addExistedCertificationControlTitle = Helper.LanguageHelper.SigManager.GetString("Title_AddID");
  27. private string addCustomCertificationControlTitle = Helper.LanguageHelper.SigManager.GetString("Title_SigInfo");
  28. private string saveCertificateTitle = Helper.LanguageHelper.SigManager.GetString("Title_Save");
  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.CancelEvent += CancelEvent;
  55. addExistedCertificationControl.FillSignatureEvent -= FillSignature;
  56. addExistedCertificationControl.FillSignatureEvent += FillSignature;
  57. }
  58. else if(e == CreateCertificationMode.AddCustomCertification)
  59. {
  60. addCustomCertificationControl = new AddCustomCertificationControl();
  61. BodyBd.Child = addCustomCertificationControl;
  62. Title = addCustomCertificationControlTitle;
  63. this.Height = addCustomCertificationControl.Height + 35;
  64. this.Width = addCustomCertificationControl.Width + 20;
  65. addCustomCertificationControl.ContinueEvent -= ContinueEvent;
  66. addCustomCertificationControl.ContinueEvent += ContinueEvent;
  67. addCustomCertificationControl.CancelEvent -= CancelEvent;
  68. addCustomCertificationControl.CancelEvent += CancelEvent;
  69. }
  70. else if (e == CreateCertificationMode.SaveCertificate)
  71. {
  72. saveCertificateControl = new SaveCertificateControl();
  73. saveCertificateControl.CertificateInfo = addCustomCertificationControl.CertificateInfo;
  74. BodyBd.Child = saveCertificateControl;
  75. Title = saveCertificateTitle;
  76. this.Height = saveCertificateControl.Height + 20;
  77. this.Width = saveCertificateControl.Width + 20;
  78. saveCertificateControl.FillSignatureEvent -= FillSignature;
  79. saveCertificateControl.FillSignatureEvent += FillSignature;
  80. saveCertificateControl.CancelSaveEvent -= CancelSaveEvent;
  81. saveCertificateControl.CancelSaveEvent += CancelSaveEvent;
  82. }
  83. }
  84. private void FillSignature(object sender, CertificateAccess e)
  85. {
  86. Close();
  87. FillSignatureEvent?.Invoke(sender, e);
  88. }
  89. private void CancelEvent(object sender, EventArgs e)
  90. {
  91. addCertificationControl = new AddCertificationControl();
  92. BodyBd.Child = addCertificationControl;
  93. Title = addCertificationControlTitle;
  94. this.Height = addCertificationControl.Height + 35;
  95. this.Width = addCertificationControl.Width + 20;
  96. addCertificationControl.ContinueEvent -= ContinueEvent;
  97. addCertificationControl.ContinueEvent += ContinueEvent;
  98. addCertificationControl.CancelEvent -= CloseEvent;
  99. addCertificationControl.CancelEvent += CloseEvent;
  100. }
  101. private void CancelSaveEvent(object sender, EventArgs e)
  102. {
  103. BodyBd.Child = addCustomCertificationControl;
  104. Title = addCustomCertificationControlTitle;
  105. this.Height = addCustomCertificationControl.Height + 35;
  106. this.Width = addCustomCertificationControl.Width + 20;
  107. addCustomCertificationControl.ContinueEvent -= ContinueEvent;
  108. addCustomCertificationControl.ContinueEvent += ContinueEvent;
  109. addCustomCertificationControl.CancelEvent -= CancelEvent;
  110. addCustomCertificationControl.CancelEvent += CancelEvent;
  111. }
  112. private void CloseEvent(object sender, EventArgs e)
  113. {
  114. Close();
  115. }
  116. }
  117. }