/// <summary> /// 关闭弹出功能 /// </summary> /// <param name="winName"></param> private void closeWindow(string winName) { BasisComponent _basFunc; ExtendFunction _extfunc; if (Enum.TryParse(winName, out _extfunc)) { //调用扩展功能 SessionExtend.CloseFunction(); } else if (Enum.TryParse(winName, out _basFunc)) { //调用基础功能扩展组件 BasicComponent.CloseFunction(); } else { if (tool != null) { if (tool.IsDisposed) { tool.Close(); } } } }
public static void ShowForm(FormBase form, FormBase parent) { form.Show(); if (parent != null) { parent.Close(); } }
private T RunInForm <T>(FormBase form, Func <T> func) where T : class { T result = null; Exception error = null; bool done = false; form.Shown += (sender, args) => { try { result = func(); } catch (Exception ex) { error = ex; } finally { done = true; form.Close(); } }; form.Closing += (sender, args) => { if (!done) { args.Cancel = true; } }; form.ShowDialog(); if (error != null) { if (error is ScanDriverException) { throw error; } throw new ScanDriverUnknownException(error); } return(result); }