private void Timer_Tick(object sender, EventArgs e) { Progress.Increment(1); if (Progress.Value == Progress.Maximum) { TimerProgress.Stop(); MessageBox.Show("Время вышло!"); Reset(); } }
private void Reset() { currentStep = -1; values.Clear(); Progress.Value = 0; for (int i = 0; i < sizeSqr; i++) { for (int j = 0; j < sizeSqr; j++) { buttons[i, j].Visible = false; } } ControlsParam.Enabled = true; Start.Enabled = true; TimerProgress.Stop(); Start.Click += Start_Click; Start.Click -= Stop_Click; Start.Text = "Start"; Restart.Visible = false; }
/// <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(); }
/// <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(); }