117 lines
3.5 KiB
C#
117 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using WinformGeneralDeveloperFrame.Commons;
|
|
|
|
namespace WinformGeneralDeveloperFrame
|
|
{
|
|
public sealed class ChildWinManagement
|
|
{
|
|
private ChildWinManagement()
|
|
{
|
|
}
|
|
|
|
public static bool ExistWin(Form MDIwin, string caption)
|
|
{
|
|
bool flag = false;
|
|
foreach (Form mdiChild in MDIwin.MdiChildren)
|
|
{
|
|
if (mdiChild.Text == caption)
|
|
{
|
|
flag = true;
|
|
mdiChild.Show();
|
|
mdiChild.Activate();
|
|
break;
|
|
}
|
|
}
|
|
|
|
return flag;
|
|
}
|
|
|
|
public static Form LoadMdiForm(Form mainDialog, Type formType)
|
|
{
|
|
|
|
bool flag = false;
|
|
Form form = (Form) null;
|
|
foreach (Form mdiChild in mainDialog.MdiChildren)
|
|
{
|
|
if (mdiChild.GetType() == formType)
|
|
{
|
|
flag = true;
|
|
form = mdiChild;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!flag)
|
|
{
|
|
form = (Form) Activator.CreateInstance(formType);
|
|
form.MdiParent = mainDialog;
|
|
form.Show();
|
|
}
|
|
|
|
form.BringToFront();
|
|
form.Activate();
|
|
return form;
|
|
}
|
|
public static Form LoadShowForm(Form mainDialog, Type formType,string caption)
|
|
{
|
|
|
|
bool flag = false;
|
|
Form form = (Form)null;
|
|
foreach (Form mdiChild in mainDialog.MdiChildren)
|
|
{
|
|
if (mdiChild.GetType() == formType)
|
|
{
|
|
flag = true;
|
|
form = mdiChild;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!flag)
|
|
{
|
|
form = (Form)Activator.CreateInstance(formType);
|
|
form.MdiParent = mainDialog;
|
|
form.Show();
|
|
}
|
|
FrmShowForm frmShowForm=form as FrmShowForm;
|
|
frmShowForm.Text = caption;
|
|
MainForm manForm= mainDialog as MainForm;
|
|
frmShowForm.mainform = manForm;
|
|
form.BringToFront();
|
|
form.Activate();
|
|
return form;
|
|
}
|
|
public static void PopControlForm(Type control, string caption)
|
|
{
|
|
object instance = ReflectionUtil.CreateInstance(control);
|
|
if (!typeof(Control).IsAssignableFrom(instance.GetType()))
|
|
return;
|
|
Form form = new Form();
|
|
form.WindowState = FormWindowState.Maximized;
|
|
form.ShowIcon = false;
|
|
form.Text = caption;
|
|
form.ShowInTaskbar = false;
|
|
form.StartPosition = FormStartPosition.CenterScreen;
|
|
Control control1 = instance as Control;
|
|
control1.Dock = DockStyle.Fill;
|
|
form.Controls.Add(control1);
|
|
int num = (int) form.ShowDialog();
|
|
}
|
|
|
|
public static void PopDialogForm(Type type)
|
|
{
|
|
object instance = ReflectionUtil.CreateInstance(type);
|
|
if (!typeof(Form).IsAssignableFrom(instance.GetType()))
|
|
return;
|
|
Form form = instance as Form;
|
|
form.ShowInTaskbar = false;
|
|
form.StartPosition = FormStartPosition.CenterScreen;
|
|
int num = (int) form.ShowDialog();
|
|
}
|
|
}
|
|
} |