Пример #1
0
        /// <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();
                    }
                }
            }
        }
Пример #2
0
        public static void ShowForm(FormBase form, FormBase parent)
        {
            form.Show();

            if (parent != null)
            {
                parent.Close();
            }
        }
Пример #3
0
        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);
        }