source: trunk/PKCS1/WpfControls/Components/SigGenKuehnControl.xaml.cs @ 1742

Last change on this file since 1742 was 1742, checked in by schomburg, 11 years ago

fixed some bugs
enhanced the GUI
file input possible now

File size: 2.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using System.Windows.Controls;
7using System.Windows.Data;
8using System.Windows.Documents;
9using System.Windows.Input;
10using System.Windows.Media;
11using System.Windows.Media.Imaging;
12using System.Windows.Navigation;
13using System.Windows.Shapes;
14using PKCS1.Library;
15
16namespace PKCS1.WpfControls.Components
17{
18    /// <summary>
19    /// Interaktionslogik für SigGenKuehnControl.xaml
20    /// </summary>
21    public partial class SigGenKuehnControl : UserControl
22    {
23        private KuehnSignature m_signature = new KuehnSignature();
24
25        public SigGenKuehnControl()
26        {
27            InitializeComponent();
28            RSAKeyManager.Instance.RaiseKeyGeneratedEvent += handleCustomEvent; // listen
29            this.handleCustomEvent(ParameterChangeType.RsaKey);
30        }
31
32        private void handleCustomEvent(ParameterChangeType type)
33        {
34            this.lblPublicKeyRes.Content = RSAKeyManager.Instance.PubExponent.ToString();
35            this.lblRsaKeySizeRes.Content = RSAKeyManager.Instance.RsaKeySize.ToString();
36        }
37
38        private void bExecute_Click(object sender, RoutedEventArgs e)
39        {
40            Cursor = Cursors.Wait;
41
42            this.m_signature = (KuehnSignature)SignatureHandler.getInstance().getKuehnSig();
43
44            if (this.m_signature.GenerateSignature())
45            {
46                UserControlHelper.loadRtbColoredSig(this.rtbResult, this.m_signature.GetSignatureDecToHexString());
47                this.tbResultEncrypted.Text = this.m_signature.GetSignatureToHexString();
48                SignatureHandler.getInstance().setKuehnSig(this.m_signature);
49            }
50            else
51            {
52                this.tbError.Text = "Es ist ein Fehler aufgetreten. Signatur konnte nicht erstellt werden.";
53            }
54
55            Cursor = Cursors.Arrow;
56        }
57
58        private void tbResultEncrypted_TextChanged(object sender, TextChangedEventArgs e)
59        {           
60            this.lblEncryptedSignatureLength.Content = "(Länge: " + this.tbResultEncrypted.Text.Length * 4 + " bit)";
61        }
62
63        private void rtbResult_TextChanged(object sender, TextChangedEventArgs e)
64        {
65            this.lblSignatureLength.Content = "(Länge: " + UserControlHelper.GetRtbTextLength(this.rtbResult) * 4 + " bit)";
66        }
67    }
68}
Note: See TracBrowser for help on using the repository browser.