示例#1
0
        // Constructor that initializes GUI.
        public MainWindow()
        {
            _rsa           = new RSA();
            _fileOperation = new FileOperation();
            _form          = new Form
            {
                Text            = LABELS[5],
                Width           = WIDTH,
                Height          = HEIGHT,
                StartPosition   = FormStartPosition.Manual,
                Left            = LEFT,
                Top             = TOP,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                MaximizeBox     = false
            };

            _plainTextBox = new TextBox {
                Multiline = true, ScrollBars = ScrollBars.Vertical, Top = 40, Left = SMALL_GAP
                , Height  = 200, Width = 300
            };
            _cipheredTextBox = new TextBox {
                Multiline = true, ScrollBars = ScrollBars.Vertical, Top = 290
                , Left    = SMALL_GAP, Height = 200, Width = 300
            };
            _publicKeyBox = new TextBox {
                Top = 160, Left = BIG_GAP, Width = 200
            };
            _privateKeyBox = new TextBox {
                Top = 220, Left = BIG_GAP, Width = 200
            };
            _statusBox = new TextBox {
                Top    = SMALL_GAP + 490, Left = SMALL_GAP, ReadOnly = true, Width = 540
                , Text = LABELS[10]
            };
            _fileDialogButton = new Button {
                Text = LABELS[6], Top = 290, Left = BIG_GAP, Width = 200
            };
            _fileDialogButton.Click += FileDialogClicked;
            _encryptButton           = new Button {
                Text = LABELS[7], Top = 320, Left = BIG_GAP, Width = 200
            };
            _encryptButton.Click += EncryptClicked;
            _decryptButton        = new Button {
                Text = LABELS[8], Top = 350, Left = BIG_GAP, Width = 200
            };
            _decryptButton.Click += DecryptClicked;
            _exitButton           = new Button {
                Text = LABELS[9], Top = 380, Left = BIG_GAP, Width = 200
            };
            _exitButton.Click += (sender, e) => { Application.Exit(); };
            var sampleLabel = new Label {
                Text = LABELS[0], Top = SMALL_GAP, Left = SMALL_GAP
            };

            _form.Controls.Add(sampleLabel);
            sampleLabel = new Label {
                Text = LABELS[1], Top = SMALL_GAP + 250, Left = SMALL_GAP
            };
            _form.Controls.Add(sampleLabel);
            sampleLabel = new Label {
                Text = LABELS[2], Top = SMALL_GAP + 120, Left = BIG_GAP
            };
            _form.Controls.Add(sampleLabel);
            sampleLabel = new Label {
                Text = LABELS[3], Top = SMALL_GAP + 180, Left = BIG_GAP
            };
            _form.Controls.Add(sampleLabel);
            sampleLabel = new Label {
                Text = LABELS[4], Top = SMALL_GAP + 250, Left = BIG_GAP, Width = 200
            };
            _form.Controls.Add(sampleLabel);
            _form.Controls.Add(_plainTextBox);
            _form.Controls.Add(_cipheredTextBox);
            _form.Controls.Add(_publicKeyBox);
            _form.Controls.Add(_privateKeyBox);
            _form.Controls.Add(_statusBox);
            _form.Controls.Add(_fileDialogButton);
            _form.Controls.Add(_encryptButton);
            _form.Controls.Add(_decryptButton);
            _form.Controls.Add(_exitButton);
            _form.ShowDialog();
        }