Пример #1
0
 /// <summary>
 /// 子画面が開いているか確認
 /// </summary>
 /// <param name="type">調べる画面</param>
 /// <returns>true : false </returns>
 public static bool IsOpenChildForm(Type type)
 {
     if (ChildFormList.Any(x => x.GetType() == type))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #2
0
        /// <summary>
        /// 子画面を開く
        /// </summary>
        /// <param name="type">開く画面</param>
        public static void ShowChildForm(Type type, int?height = null, int?width = null, int?top = null, int?left = null)
        {
            if (ChildFormList == null)
            {
                ChildFormList = new List <Form>();
            }

            if (!ChildFormList.Any(x => x.GetType() == type))
            {
                var form = (Form)Activator.CreateInstance(type);
                ChildFormList.Add(form);
                form.MdiParent = ParentForm;

                if (height != null)
                {
                    form.Height = (int)height;
                }
                if (width != null)
                {
                    form.Width = (int)width;
                }

                if (top != null)
                {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Top           = (int)top;
                    form.Left          = (int)left;
                }
                form.Show();
            }
            else
            {
                var form = ChildFormList.Where(x => x.GetType() == type).First();
                form.Show();
                form.Activate();
            }
        }