Esempio n. 1
0
        /// <summary>
        /// 子画面を非表示にする
        /// </summary>
        /// <param name="type">閉じる画面</param>
        public static void CloseChildForm(Type type)
        {
            var form = ChildFormList.Where(x => x.GetType() == type).FirstOrDefault();

            if (form != null)
            {
                form.Close();
                ChildFormList.Remove(form);
            }
        }
Esempio n. 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();
            }
        }