public MainForm(IWin32Window owner) : this() { if (owner.GetType().Name.Contains("MainForm")) { var met = owner.GetType().GetMethod("GoToLogItem", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, new Type[] { typeof(int), typeof(bool) }, null); GoToLogItem = (x, y) => (bool)met.Invoke(owner, new object[] { x, y }); } }
/* /// <summary> * /// Gets control resource * /// </summary> * /// <param name="key">Key string</param> * /// <returns>The resource</returns> * /*public static string GetControlResource(string key) * { * if (controlResources.ContainsKey(key)) * { * return controlResources[key] as string; * } * if (missWriter != null & key.Length != 0) * { * missWriter.WriteLine(key); * } * if (key.Length == 0) * { * return ""; * } * return key; * }* * * /// <summary> * /// Gets resource string * /// </summary> * /// <param name="key">Key string</param> * /// <returns>The resource</returns> * public static string GetResourceString(string key) * { * if (resources.ContainsKey(key)) * { * return resources[key] as string; * } * if (missWriter != null & key.Length != 0) * { * missWriter.WriteLine(key); * } * return key; * } * * /// <summary> * /// Loads resources strings to control * /// </summary> * /// <param name="control">The control</param> * private static void LoadControlResources(Control control) * { * LoadControlResources(control, controlResources); * }*/ /// <summary> /// Shows dialog /// </summary> /// <param name="form">Parent form</param> /// <param name="resources">Resources</param> /// <param name="dialog">Dialog</param> /// <returns>Dialog result</returns> public static DialogResult ShowDialog(IWin32Window form, Dictionary <string, object>[] resources, FileDialog dialog) { Type t = form.GetType(); dialog.Filter = GetControlResource(dialog.Filter, resources); return(dialog.ShowDialog(form)); }
} /* Paint */ protected override void OnDoubleClick(DataGridViewCellEventArgs e) { if (DataGridView == null) { return; } if (e.ColumnIndex >= DataGridView.Columns.Count) { return; } ThumbNailImageColumn tnic = ((ThumbNailImageColumn)(this.DataGridView.Columns[e.ColumnIndex])); IWin32Window parent = tnic.Parent; if (parent.GetType() != typeof(PicesCommander)) { return; } PicesCommander pc = (PicesCommander)parent; if (pc == null) { return; } pc.ThumbnailDataGridView_CellContentDoubleClick(DataGridView, e); } /* OnDoubleClick */
} // constructor public static void ShowBox(IWin32Window owner, string context) { using (var box = new NotImplementedBox()) { if (context == null) { context = owner.GetType().Name; } else { string.Format("{0}/{1}", owner.GetType().Name, context); } // if-else BasicGoogleTelemetry.SendScreenHit(box, context); box.ShowDialog(owner); } // using } // ShowBox
/// <summary> /// /// </summary> /// <param name="pOwner"></param> /// <param name="pMsg"></param> /// <returns></returns> public static System.Windows.Forms.DialogResult Question(IWin32Window owner, string message) { string txt = MSG_OPERATE_NOTE; if (owner.GetType().Name == "Form") { Form frm = owner as Form; txt = frm.Text; } return(MessageBox.Show(owner, message, txt, MessageBoxButtons.YesNo, MessageBoxIcon.Question)); }
/// <summary> /// /// </summary> /// <param name="pOwner"></param> /// <param name="pMsg"></param> /// <param name="mustShowByMsgBox">是否必须用MessageBox来显示</param> /// <returns></returns> public static System.Windows.Forms.DialogResult Show(IWin32Window owner, string message, MessageBoxIcon msgIco, bool mustShowByMsgBox) { string txt = MSG_OPERATE_NOTE; if (owner.GetType().Name == "Form") { Form frm = owner as Form; txt = frm.Text; } bool b = false; if (!b) { return(MessageBox.Show(owner, message, txt, MessageBoxButtons.OK, msgIco)); } else { return(System.Windows.Forms.DialogResult.OK); } }
public static void ShowMessageBox(IWin32Window owner, string msg, string caption, MessageBoxButtons btns, MessageBoxIcon icon, MessageBoxDefaultButton defBtn) { Type ownerType = owner.GetType(); PropertyInfo invokeProp = ownerType.GetProperty("InvokeRequired"); bool invokeReq = false; if (invokeProp != null) { invokeReq = Convert.ToBoolean(invokeProp.GetValue(owner, null)); } if (invokeProp == null || !invokeReq) { MessageBox.Show(owner, msg, caption, btns, icon, defBtn); } else { MethodInfo beginInvokeMeth = ownerType.GetMethod(((CrossThreadUI.ExecSync) ? "Invoke" : "BeginInvoke"), new Type[] { typeof(Delegate), typeof(Object[]) }); if (beginInvokeMeth != null) { ShowMessageBoxDelegate del = new ShowMessageBoxDelegate(CrossThreadUI.ShowMessageBox); beginInvokeMeth.Invoke(owner, new object[] { del, new object[] { owner, msg, caption, btns, icon, defBtn } }); } } }
/// <summary> /// Shows a MessageBox properly linked to the given Win32Window owner. /// </summary> /// <param name="owner">The System.Windows.Forms.IWin32Window object who will act as this message box's parent.</param> /// <param name="msg">A System.String value to display as a message on this message box.</param> /// <param name="caption">A System.String value to display in the title bar of this message box.</param> /// <param name="btns">A System.Windows.Forms.MessageBoxButtons value specifying what buttons are displayed on the message box.</param> /// <param name="icon">A System.Windows.Forms.MessageBoxIcon value specifying what icon is displayed on the message box.</param> /// <param name="defBtn">A System.Windows.Forms.MessageBoxDefaultButton value specifying which of the message box's buttons should be activated if the user presses the "Enter" key.</param> public static void ShowMessageBox(IWin32Window owner, string msg, string caption, MessageBoxButtons btns, MessageBoxIcon icon, MessageBoxDefaultButton defBtn) { Type ownerType = owner.GetType(); PropertyInfo invokeProp = ownerType.GetProperty("InvokeRequired"); bool invokeReq = false; if (invokeProp != null) invokeReq = Convert.ToBoolean(invokeProp.GetValue(owner, null)); if (invokeProp == null || !invokeReq) { MessageBox.Show(owner, msg, caption, btns, icon, defBtn); } else { MethodInfo beginInvokeMeth = ownerType.GetMethod(((CrossThreadUI.ExecSync) ? "Invoke" : "BeginInvoke"), new Type[] { typeof(Delegate), typeof(Object[]) }); if (beginInvokeMeth != null) { ShowMessageBoxDelegate del = new ShowMessageBoxDelegate(CrossThreadUI.ShowMessageBox); beginInvokeMeth.Invoke(owner, new object[] { del, new object[] { owner, msg, caption, btns, icon, defBtn } }); } } }