AddCertificationDialog.xaml.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /// 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. public event EventHandler<CertificateAccess> FillSignatureEvent;
  26. public AddCertificationDialog()
  27. {
  28. InitializeComponent();
  29. addCertificationControl = new AddCertificationControl();
  30. BodyBd.Child = addCertificationControl;
  31. }
  32. private void Window_Loaded(object sender, RoutedEventArgs e)
  33. {
  34. addCertificationControl.ContinueEvent -= ContinueEvent;
  35. addCertificationControl.ContinueEvent += ContinueEvent;
  36. addCertificationControl.CancelEvent -= CloseEvent;
  37. addCertificationControl.CancelEvent += CloseEvent;
  38. }
  39. private void ContinueEvent(object sender, CreateCertificationMode e)
  40. {
  41. if(e == CreateCertificationMode.AddExistedCertification)
  42. {
  43. addExistedCertificationControl = new AddExistedCertificationControl();
  44. BodyBd.Child = addExistedCertificationControl;
  45. this.Height = addExistedCertificationControl.Height + 35;
  46. this.Width = addExistedCertificationControl.Width + 20;
  47. addExistedCertificationControl.CancelEvent += CancelEvent;
  48. addExistedCertificationControl.FillSignatureEvent -= FillSignature;
  49. addExistedCertificationControl.FillSignatureEvent += FillSignature;
  50. }
  51. else if(e == CreateCertificationMode.AddCustomCertification)
  52. {
  53. addCustomCertificationControl = new AddCustomCertificationControl();
  54. BodyBd.Child = addCustomCertificationControl;
  55. this.Height = addCustomCertificationControl.Height + 35;
  56. this.Width = addCustomCertificationControl.Width + 20;
  57. addCustomCertificationControl.ContinueEvent -= ContinueEvent;
  58. addCustomCertificationControl.ContinueEvent += ContinueEvent;
  59. addCustomCertificationControl.CancelEvent -= CancelEvent;
  60. addCustomCertificationControl.CancelEvent += CancelEvent;
  61. }
  62. else if (e == CreateCertificationMode.SaveCertificate)
  63. {
  64. saveCerficateControl = new SaveCerficateControl();
  65. saveCerficateControl.CertificateInfo = addCustomCertificationControl.certificateInfo;
  66. BodyBd.Child = saveCerficateControl;
  67. this.Height = saveCerficateControl.Height + 20;
  68. this.Width = saveCerficateControl.Width + 20;
  69. saveCerficateControl.FillSignatureEvent -= FillSignature;
  70. saveCerficateControl.FillSignatureEvent += FillSignature;
  71. }
  72. }
  73. private void FillSignature(object sender, CertificateAccess e)
  74. {
  75. Close();
  76. FillSignatureEvent?.Invoke(sender, e);
  77. }
  78. private void CancelEvent(object sender, EventArgs e)
  79. {
  80. addCertificationControl = new AddCertificationControl();
  81. BodyBd.Child = addCertificationControl;
  82. this.Height = addCertificationControl.Height + 35;
  83. this.Width = addCertificationControl.Width + 20;
  84. addCertificationControl.ContinueEvent -= ContinueEvent;
  85. addCertificationControl.ContinueEvent += ContinueEvent;
  86. }
  87. private void CloseEvent(object sender, EventArgs e)
  88. {
  89. Close();
  90. }
  91. }
  92. }