Beispiel #1
0
        /// <summary>
        /// 多单例显示
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="form"></param>
        public static void Show <T>(string key, CreateFormEventHandler <T> form)
            where T : Form
        {
            lock (syncobj)
            {
                if (dict.ContainsKey(key))
                {
                    var winform = dict[key] as WinForm <T>;
                    if (winform.IsDisposed)
                    {
                        winform   = new WinForm <T>(form());
                        dict[key] = winform;
                    }

                    winform.Show();
                }
                else
                {
                    var t = new WinForm <T>(form());
                    dict.Add(key, t);

                    t.Show();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 单例
        /// </summary>
        public static WinForm <T> GetInstance(CreateFormEventHandler <T> form)
        {
            if (_instance == null || _instance.IsDisposed)
            {
                lock (syncobj)
                {
                    if (_instance == null || _instance.IsDisposed)       //双检查
                    {
                        _instance = new WinForm <T>(form());
                    }
                }
            }

            return(_instance);
        }
Beispiel #3
0
 /// <summary>
 /// 显示窗体
 /// </summary>
 /// <param name="form"></param>
 public static void Show <T>(CreateFormEventHandler <T> form, Rectangle rect)
     where T : Form
 {
     WinForm <T> .GetInstance(form).Show(rect);
 }