using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace Compdfkit_Tools.PDFControl { /// /// Interaction logic for AddCertificationDialog.xaml /// public partial class AddCertificationDialog : Window { private AddCertificationControl addCertificationControl = null; private AddCustomCertificationControl addCustomCertificationControl = null; private AddExistedCertificationControl addExistedCertificationControl = null; private SaveCerficateControl saveCerficateControl = null; private string addCertificationControlTitle = "Add Digital Signatures"; private string addExistedCertificationControlTitle = "Add A Digital ID"; private string addCustomCertificationControlTitle = "Customize the Signature"; private string saveCerficateControlTitle = "Save the Self-Signed Digital ID to A File"; public event EventHandler FillSignatureEvent; public AddCertificationDialog() { InitializeComponent(); addCertificationControl = new AddCertificationControl(); BodyBd.Child = addCertificationControl; Title = addCertificationControlTitle; } private void Window_Loaded(object sender, RoutedEventArgs e) { addCertificationControl.ContinueEvent -= ContinueEvent; addCertificationControl.ContinueEvent += ContinueEvent; addCertificationControl.CancelEvent -= CloseEvent; addCertificationControl.CancelEvent += CloseEvent; } private void ContinueEvent(object sender, CreateCertificationMode e) { if(e == CreateCertificationMode.AddExistedCertification) { addExistedCertificationControl = new AddExistedCertificationControl(); BodyBd.Child = addExistedCertificationControl; Title = addExistedCertificationControlTitle; this.Height = addExistedCertificationControl.Height + 35; this.Width = addExistedCertificationControl.Width + 20; addExistedCertificationControl.CancelEvent += CancelEvent; addExistedCertificationControl.FillSignatureEvent -= FillSignature; addExistedCertificationControl.FillSignatureEvent += FillSignature; } else if(e == CreateCertificationMode.AddCustomCertification) { addCustomCertificationControl = new AddCustomCertificationControl(); BodyBd.Child = addCustomCertificationControl; Title = addCustomCertificationControlTitle; this.Height = addCustomCertificationControl.Height + 35; this.Width = addCustomCertificationControl.Width + 20; addCustomCertificationControl.ContinueEvent -= ContinueEvent; addCustomCertificationControl.ContinueEvent += ContinueEvent; addCustomCertificationControl.CancelEvent -= CancelEvent; addCustomCertificationControl.CancelEvent += CancelEvent; } else if (e == CreateCertificationMode.SaveCertificate) { saveCerficateControl = new SaveCerficateControl(); saveCerficateControl.CertificateInfo = addCustomCertificationControl.CertificateInfo; BodyBd.Child = saveCerficateControl; Title = saveCerficateControlTitle; this.Height = saveCerficateControl.Height + 20; this.Width = saveCerficateControl.Width + 20; saveCerficateControl.FillSignatureEvent -= FillSignature; saveCerficateControl.FillSignatureEvent += FillSignature; saveCerficateControl.CancelSaveEvent -= CancelSaveEvent; saveCerficateControl.CancelSaveEvent += CancelSaveEvent; } } private void FillSignature(object sender, CertificateAccess e) { Close(); FillSignatureEvent?.Invoke(sender, e); } private void CancelEvent(object sender, EventArgs e) { addCertificationControl = new AddCertificationControl(); BodyBd.Child = addCertificationControl; Title = addCertificationControlTitle; this.Height = addCertificationControl.Height + 35; this.Width = addCertificationControl.Width + 20; addCertificationControl.ContinueEvent -= ContinueEvent; addCertificationControl.ContinueEvent += ContinueEvent; addCertificationControl.CancelEvent -= CloseEvent; addCertificationControl.CancelEvent += CloseEvent; } private void CancelSaveEvent(object sender, EventArgs e) { BodyBd.Child = addCustomCertificationControl; Title = addCustomCertificationControlTitle; this.Height = addCustomCertificationControl.Height + 35; this.Width = addCustomCertificationControl.Width + 20; addCustomCertificationControl.ContinueEvent -= ContinueEvent; addCustomCertificationControl.ContinueEvent += ContinueEvent; addCustomCertificationControl.CancelEvent -= CancelEvent; addCustomCertificationControl.CancelEvent += CancelEvent; } private void CloseEvent(object sender, EventArgs e) { Close(); } } }