protected override void OnPaint(PaintEventArgs e) { try { // Translate the graphics to work the same way the timeline grid does // (ie. Drawing coordinates take into account where we start at in time) e.Graphics.TranslateTransform(-timeToPixels(VisibleTimeStart), 0); drawTicks(e.Graphics, MajorTick, 2, 0.5); drawTicks(e.Graphics, MinorTick, 1, 0.25); drawTimes(e.Graphics); using (Pen p = new Pen(Color.Black, 2)) { e.Graphics.DrawLine(p, 0, Height - 1, timeToPixels(TotalTime), Height - 1); } drawPlaybackIndicators(e.Graphics); _drawMarks(e.Graphics); } catch (Exception ex) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Exception in Timeline.Ruler.OnPaint():\n\n\t" + ex.Message + "\n\nBacktrace:\n\n\t" + ex.StackTrace, @"Error", false, false); messageBox.ShowDialog(); } }
public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options) { MessageBoxForm form = new MessageBoxForm (text, caption, buttons, icon, defaultButton, options); DialogResult result = form.ShowDialog(owner as Form); form.DisposeDialog(); return(result); }
/// <summary> /// 显示一个消息框。 /// </summary> /// <param name="owner">控件拥有者。</param> /// <param name="parameters">设置参数。</param> /// <returns>返回窗体的操作结果。</returns> public static DialogResult ShowMsg(this Control owner, MessageBoxParameters parameters) { if (owner == null) { owner = Form.ActiveForm; } if (owner != null && owner.InvokeRequired) { return((DialogResult)owner.Invoke(new Func <Control, MessageBoxParameters, DialogResult>(ShowMsg), owner, parameters)); } else { if (ShowingMsg != null) { var e = new ShowingMsgEventArgs(owner, parameters); ShowingMsg(owner, e); if (e.Result != DialogResult.OK) { return(e.Result); } } if (owner == null) { var f = new MessageBoxForm(owner, parameters); var r = f.ShowDialog(); parameters.CheckedResult = f.CheckedResult; return(r); } else { var ownerForm = owner.FindForm(); ownerForm.Activate(); var f = new MessageBoxForm(owner, parameters); var r = f.ShowDialog(owner); ownerForm.Activate(); parameters.CheckedResult = f.CheckedResult; return(r); } } }
public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options) { MessageBoxForm form = new MessageBoxForm (text, caption, buttons, icon, defaultButton, options); DialogResult result = form.ShowDialog(owner as Form); form.DisposeDialog(); return result; }
/// <summary> /// 显示一个消息框。 /// </summary> /// <param name="owner">控件拥有者。</param> /// <param name="parameters">设置参数。</param> /// <returns>返回窗体的操作结果。</returns> public static DialogResult ShowMsg(this Control owner, MessageBoxParameters parameters) { if (owner == null) owner = Form.ActiveForm; if (owner != null && owner.InvokeRequired) { return (DialogResult)owner.Invoke(new Func<Control, MessageBoxParameters, DialogResult>(ShowMsg), owner, parameters); } else { if (ShowingMsg != null) { var e = new ShowingMsgEventArgs(owner, parameters); ShowingMsg(owner, e); if (e.Result != DialogResult.OK) return e.Result; } if (owner == null) { var f = new MessageBoxForm(owner, parameters); var r = f.ShowDialog(); parameters.CheckedResult = f.CheckedResult; return r; } else { var ownerForm = owner.FindForm(); ownerForm.Activate(); var f = new MessageBoxForm(owner, parameters); var r = f.ShowDialog(owner); ownerForm.Activate(); parameters.CheckedResult = f.CheckedResult; return r; } } }