private void GoToFrame(Int32 value) { if (videoOpened) { try { this.Cursor = Cursors.WaitCursor; if (value > trackVideo.Maximum) { value = trackVideo.Maximum; } else if (value < 0) { value = 0; } trackVideo.Value = value; this.Cursor = Cursors.Default; } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); this.Cursor = Cursors.Default; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnButtonClick(object sender, EventArgs e) { try { AcMessageBoxButton acBtn = (AcMessageBoxButton)sender; switch (acBtn.buttonType) { case AcMessageBoxButtonTypes.Abort: this.DialogResult = System.Windows.Forms.DialogResult.Abort; this.Hide(); break; case AcMessageBoxButtonTypes.Cancel: this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Hide(); break; case AcMessageBoxButtonTypes.Ignore: this.DialogResult = System.Windows.Forms.DialogResult.Ignore; this.Hide(); break; case AcMessageBoxButtonTypes.No: this.DialogResult = System.Windows.Forms.DialogResult.No; this.Hide(); break; case AcMessageBoxButtonTypes.OK: this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Hide(); break; case AcMessageBoxButtonTypes.Retry: this.DialogResult = System.Windows.Forms.DialogResult.Retry; this.Hide(); break; case AcMessageBoxButtonTypes.Yes: this.DialogResult = System.Windows.Forms.DialogResult.Yes; this.Hide(); break; case AcMessageBoxButtonTypes.Copy: this.DialogResult = System.Windows.Forms.DialogResult.None; Clipboard.SetText(txtMessage.Text); AcMessageBox.Show("Message was copied to clipboard!", "Sucess!", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.Show(ex.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnFormShown(object sender, EventArgs e) { try { txtUserResponse.Select(); } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show(ex.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTextChanged(object sender, EventArgs e) { try { InputResponse = txtUserResponse.Text; } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show(ex.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// The event handler for saving the image to clipboard /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSaveImageToFile(object sender, EventArgs e) { try { HandleImage(_HandleImageTypes.SaveToFile); } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show("Error while saving to file!\r\n" + ex.Message, MessageBoxIcon.Error); } }
/// <summary> /// The event handler for copying the image to clipboard /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnCopyImageToClipboard(object sender, EventArgs e) { try { HandleImage(_HandleImageTypes.CopyToClipboard); } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show("Error while copying to clipboard!\r\n" + ex.Message, MessageBoxIcon.Error); } }
protected override void OnMouseDown(MouseEventArgs e) { //base.OnMouseDown(e); try { Int32 newValue = GetValueFromMouseClick(e.X); if (this.Value != newValue) { this.Value = newValue; } } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show("Error changing value!\r\n" + ex.Message, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnFormShown(object sender, EventArgs e) { try { foreach (AcMessageBoxButton btn in acButtons) { if (btn.buttonType == AcMessageBoxButtonTypes.OK || btn.buttonType == AcMessageBoxButtonTypes.Yes) { btn.Focus(); return; } } } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.Show(ex.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnKeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { if (e.Modifiers == Keys.Control) { txtUserResponse.Text += "\r\n"; txtUserResponse.Select(txtUserResponse.Text.Length, 0); } else { acBtnOK.PerformClick(); } } } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show(ex.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnButtonClick(object sender, EventArgs e) { try { AcInputBoxButton acBtn = (AcInputBoxButton)sender; switch (acBtn.buttonType) { case AcInputBoxButtonTypes.OK: this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Hide(); break; case AcInputBoxButtonTypes.Cancel: this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Hide(); break; } } catch (Exception ex) { AcUtilities.DebugWrite(ex.ToString()); AcMessageBox.AcMessageBox.Show(ex.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// The handler of the image processing /// </summary> private void HandleImage(_HandleImageTypes handleType) { if (this.Image == null) { throw new Exception("Image is null!"); } else if (this.Image == this.ErrorImage) { throw new Exception("Image is error image!"); } else if (this.Image == this.InitialImage) { throw new Exception("Image is initial image!"); } else { switch (handleType) { case _HandleImageTypes.CopyToClipboard: Clipboard.SetImage((Image)this.Image.Clone()); AcUtilities.DebugWrite("Image successfully copied to Clipboard"); AcMessageBox.AcMessageBox.Show("Successfully copied to Clipboard!"); break; case _HandleImageTypes.SaveToFile: SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Select the filename of the image..."; StringBuilder filterBuilder = new StringBuilder(); filterBuilder.AppendFormat("{0} files (*.{0})|*.{0}", "png"); filterBuilder.AppendFormat("|{0} files (*.{0})|*.{0}", "jpg"); filterBuilder.AppendFormat("|{0} files (*.{0})|*.{0}", "gif"); filterBuilder.AppendFormat("|{0} files (*.{0})|*.{0}", "tiff"); filterBuilder.AppendFormat("|{0} files (*.{0})|*.{0}", "bmp"); sfd.Filter = filterBuilder.ToString(); if (sfd.ShowDialog() == DialogResult.OK) { System.Drawing.Imaging.ImageFormat imgFormat = null; switch (sfd.FilterIndex) { case 1: imgFormat = System.Drawing.Imaging.ImageFormat.Png; break; case 2: imgFormat = System.Drawing.Imaging.ImageFormat.Jpeg; break; case 3: imgFormat = System.Drawing.Imaging.ImageFormat.Gif; break; case 4: imgFormat = System.Drawing.Imaging.ImageFormat.Tiff; break; case 5: imgFormat = System.Drawing.Imaging.ImageFormat.Bmp; break; } this.Image.Save(sfd.FileName, imgFormat); AcUtilities.DebugWrite("Image successfully copied to file " + sfd.FileName); AcMessageBox.AcMessageBox.Show("Successfully saved to file!"); } break; } } }