示例#1
0
        private void Start_Click(object sender, EventArgs e)
        {
            Start.Click    -= Start_Click;
            Start.Click    += Stop_Click;
            Start.Text      = "Stop";
            Restart.Visible = true;
            Random rand = new Random();

            buttons = new Button[sizeSqr, sizeSqr];
            Box.Controls.Clear();

            int koef = 290 / sizeSqr;

            for (int i = 0; i < sizeSqr; i++)
            {
                for (int j = 0; j < sizeSqr; j++)
                {
                    buttons[i, j]          = new Button();
                    buttons[i, j].Location = new Point(koef * i, koef * j);
                    buttons[i, j].Size     = new Size(koef, koef);
                    buttons[i, j].TabIndex = 10;
                    buttons[i, j].UseVisualStyleBackColor = true;
                    buttons[i, j].Click += PlayButton_Click;

                    int min = (int)Min.Value;
                    int max = (int)Max.Value;
                    int res = rand.Next(min, max);
                    while (values.IndexOf(res) != -1)
                    {
                        res = rand.Next(min, max);
                    }

                    values.Add(res);

                    buttons[i, j].Text    = res.ToString();
                    buttons[i, j].Visible = true;

                    Box.Controls.Add(buttons[i, j]);
                }
            }
            values.Sort();
            TimerProgress.Start();
            ControlsParam.Enabled = false;
            Progress.Maximum      = (int)TrackTime.Value;
        }
示例#2
0
        /// <summary>
        /// Handles the Click event of the BtnDecode control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private async void BtnDecode_ClickAsync(object sender, EventArgs e)
        {
            if (BtnDecodeReady() == false)
            {
                return;
            }

            int    charLength = (int)StegDecode.GetCharactersToRead();
            string password   = TextBoxAesPassword.Text;

            // Set up progress report
            TimerProgress.Start();
            BtnDecode.Enabled         = false;
            ProgressBarDecode.Maximum = charLength * 8;
            ProgressBarDecode.Value   = 0;

            string message = await Task.Run(() => StegDecode.ReadImage());

            if (CheckBoxAes.Checked)
            {
                message = Crypto.Decrypt(message, password);
                if (message == null)
                {
                    TimerProgress.Stop();
                    BtnDecode.Enabled = true;

                    MessageBox.Show(String.Format("{0} is not a valid hash type", Settings.Hash));
                    return;
                }
            }

            if (CheckBoxBase64.Checked)
            {
                message = Converter.Base64ToAscii(message);
            }
            TextOutput.Text = message;

            BtnDecode.Enabled       = true;
            ProgressBarDecode.Value = ProgressBarDecode.Maximum;
            TimerProgress.Stop();
        }
示例#3
0
        /// <summary>
        /// Handles the Click event of the BtnEncode control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private async void BtnEncodeAsync_ClickAsync(object sender, EventArgs e)
        {
            if (!BtnEncodeReady())
            {
                return;
            }

            string message = TextMessage.Text;

            if (CheckBoxBase64.Checked)
            {
                message = Converter.AsciiToBase64(message);
            }

            if (CheckBoxAes.Checked)
            {
                message = Crypto.Encrypt(message, TextBoxAesKey.Text);
                if (message == null)
                {
                    MessageBox.Show(String.Format("{0} is not a valid hash type", Settings.Hash));
                    return;
                }
            }
            BtnEncode.Enabled = false;

            // Set up progress report
            TimerProgress.Start();
            ProgressBarEncode.Maximum = StegEncode.MaxCharacters * 8;
            ProgressBarEncode.Value   = 0;

            Task tEncode = new Task(() => StegEncode.CreateImage(message, StegEncode.OutputFile));

            tEncode.Start();
            await Task.WhenAll(tEncode);

            BtnEncode.Enabled       = true;
            ProgressBarEncode.Value = ProgressBarEncode.Maximum;
            TimerProgress.Stop();
        }