private void OpenForm <T>(string UserID = "", Guid companyID = new Guid()) { var existingForm = MdiChildren.FirstOrDefault(x => x.GetType() == typeof(T)); if (existingForm == null) { T Form = (T)Activator.CreateInstance(typeof(T)); dynamic f = Form; f.MdiParent = this; if (!string.IsNullOrEmpty(UserID)) { f.UserID = UserID; } if (companyID != Guid.Empty) { f.CompanyID = companyID; } OnFormActivated(f, null); f.Show(); f.Activated += new EventHandler(OnFormActivated); } else { existingForm.Activate(); existingForm.Focus(); //existingForm.Activated } }
/// <summary> /// Создать новую зависимую форму /// </summary> /// <param name="args">Параметры, передаваемые на форму</param> public T CreateChildForm <T>(params object[] args) where T : class { Application.DoEvents(); var type = typeof(T); try { var f = MdiChildren.FirstOrDefault(a => a.Name == type.Name); if (f == null) { f = (Form)Activator.CreateInstance(type, args); f.MdiParent = this; } f.Show(); f.Activate(); return(f as T); } catch (Exception ex) { MessageBox.Show(@"Неожиданное поведение при загрузке формы, данные о ней отправлены программистам.", @"Сообщение отправлено программистам", MessageBoxButtons.OK, MessageBoxIcon.Error); DBException.WriteLog(ex); } return(null); }
private void Mdi_MdiChildActivate(object sender, EventArgs e) { var fr = MdiChildren.FirstOrDefault(z => z is QuickTagsWindow); if (fr == null) { return; } fr.BringToFront(); }
private bool FindWindow(string tag) { //Find if window is already open var foundWindow = MdiChildren.FirstOrDefault(o => o.Tag != null && o.Tag.ToString() == tag); if (foundWindow != null) { foundWindow.Focus(); return(true); } return(false); }
void _openForm(Form f) { var frm = MdiChildren.FirstOrDefault(q => q.Text == f.Text); if (frm == null) { f.MdiParent = this; f.Show(); } else { frm.Activate(); } }
//탭 중복 생성 방지 private void Overlap(Form form) { var childform = MdiChildren.FirstOrDefault(x => x.GetType() == form.GetType()); if (childform == null) { form.MdiParent = this; form.Show(); } else { childform.Focus(); } }
private void ShowChild(Form form) { var childform = MdiChildren.FirstOrDefault(x => x.Text == form.Text); if (childform == null) { form.MdiParent = this; form.Show(); } else { childform.Focus(); } }
private void ShowForm(Form form) { var child = MdiChildren.FirstOrDefault(x => x.Name.Equals(form.Name)); if (child != null) { child.BringToFront(); } else { form.Show(); form.MdiParent = this; } }
private void OpenForm <T>() { var fm = MdiChildren.FirstOrDefault(f => f is T); if (fm == null) { fm = Activator.CreateInstance <T>() as Form; // tao đối tượng T thôi fm.MdiParent = this; fm.Show(); } else { fm.Activate(); } }
private void CsManager_CharSetDeleted(object sender, CharSetEventArgs e) { var existing = MdiChildren.FirstOrDefault(c => (c as CharSetEditor)?.CharSetId == e.CharSet.Id) as CharSetEditor; if (existing != null) { existing.Close(); existing.Dispose(); existing.Export -= Editor_Export; existing.Save -= Editor_Save; existing.Update -= Editor_Update; existing.FormClosed -= Editor_FormClosed; } PluginManager.DeleteCharSet(e.CharSet); }
private void ShowChildForm(Form form) { if (form == null) { return; } var childForm = MdiChildren.FirstOrDefault(x => x.GetType() == form.GetType()); if (childForm != null) { childForm.Close(); } ShowForm(form); }
void OpenForm(ref Form newForm) { Form f = newForm; Form form = MdiChildren.FirstOrDefault(ff => ff.Text == f.Text); if (form != null) { form.BringToFront(); } else { f.MdiParent = this; f.StartPosition = FormStartPosition.CenterScreen; f.Show(); } }
private void OpenForm(ref XtraForm form) { XtraForm fo = form; XtraForm from = MdiChildren.FirstOrDefault(f => f.Text == fo.Text) as XtraForm; if (from != null) { from.BringToFront(); } else { form.MdiParent = this; form.Show(); } SplashScreenManager.CloseForm(false); }
public void OpenForm <T>(object arg) where T : Form { MsgBox.ShowWaitForm(); var f = MdiChildren.FirstOrDefault(i => i is T); if (f == null) { f = Activator.CreateInstance(typeof(T), arg) as T; f.MdiParent = this; f.Show(); } else { f.Activate(); } MsgBox.CloseWaitForm(); }
private void MovimentosToolStripMenuItem_Click(object sender, EventArgs e) { var importMovimentos = (ImportMovimentos)MdiChildren.FirstOrDefault(c => c.GetType() == typeof(ImportMovimentos)); if (importMovimentos == null) { importMovimentos = new ImportMovimentos { MdiParent = this }; importMovimentos.Show(); } else { importMovimentos.Activate(); } }
private void ValidarToolStripMenuItem_Click(object sender, EventArgs e) { var validMovimentos = (ValidateForm)MdiChildren.FirstOrDefault(c => c.GetType() == typeof(ValidateForm)); if (validMovimentos == null) { validMovimentos = new ValidateForm() { MdiParent = this }; validMovimentos.Show(); } else { validMovimentos.Activate(); } }
private void ShowNewForm(object sender, EventArgs e) { var child = MdiChildren.FirstOrDefault(f => f.Name == nameof(frmGenerate)); if (child == null) { child = new frmGenerate { MdiParent = this, Text = "生成代码", WindowState = FormWindowState.Maximized }; child.Show(); } else { child.Show(); } }
private void CsManager_CharSetSelected(object sender, CharSetEventArgs e) { var existing = MdiChildren.FirstOrDefault(c => (c as CharSetEditor)?.CharSetId == e.CharSet.Id); if (existing != null) { existing.BringToFront(); return; } CharSetEditor editor = new CharSetEditor(e.CharSet); editor.MdiParent = this; editor.Export += Editor_Export; editor.Save += Editor_Save; editor.Update += Editor_Update; editor.FormClosed += Editor_FormClosed; editor.Show(); }
private void OpenForm <T>() { var f = MdiChildren.FirstOrDefault(i => i is T); if (f == null) { f = Activator.CreateInstance <T>() as Form; if (f == null) { return; } f.MdiParent = this; f.Show(); } else { f.Activate(); } }
public void OpenForm <T>(bool maximize = true, params object[] paramArray) { var f = MdiChildren.FirstOrDefault(x => x is T); if (f == null) { f = Activator.CreateInstance(typeof(T), args: paramArray) as Form; f.MdiParent = this; if (maximize) { f.WindowState = FormWindowState.Maximized; } f.Show(); } else { f.Activate(); } }
/// <summary> /// 显示模板列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmiTemp_Click(object sender, EventArgs e) { var child = MdiChildren.FirstOrDefault(f => f.Name == nameof(frmTemp)); if (child == null) { child = new frmTemp { MdiParent = this, Text = "模板设置", WindowState = FormWindowState.Maximized }; child.Show(); } else { child.Show(); } }
private void ShowChildForm(Form form) { if (form == null) { return; } var childForm = MdiChildren.FirstOrDefault(x => x.GetType() == form.GetType()); if (childForm == null) { form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); } else { childForm.Focus(); } }
public void OpenForm <T>(string chucnang) { MsgBox.ShowWaitForm(); var f = MdiChildren.FirstOrDefault(i => i is T); if (f == null) { f = Activator.CreateInstance <T>() as Form; f.MdiParent = this; if (f is FrmBase) { (f as FrmBase).ChucNang = chucnang; } f.Show(); } else { f.Activate(); } MsgBox.CloseWaitForm(); }
public DataViewForm <T> GetDataViewForm <T>() where T : class, IIdentifiable { return(MdiChildren.FirstOrDefault(i => i is DataViewForm <T>) as DataViewForm <T>); }
private void activarFormulario(int tag) { this.Cursor = Cursors.WaitCursor; Form formularioActivo = MdiChildren.FirstOrDefault(fo => Convert.ToInt32(fo.Tag) == tag); if (formularioActivo == null) { Form formularioVisualizar = null; if (tag == 1001) { formularioVisualizar = new FrmHome(); PanelSelInicio.BackColor = Color.FromArgb(128, 191, 255); } if (tag == 1002) { PanelSelProyectos.BackColor = Color.FromArgb(128, 191, 255); } if (tag == 1003) { PanelSelTareas.BackColor = Color.FromArgb(128, 191, 255); } if (tag == 1004) { PanelSelColaboradores.BackColor = Color.FromArgb(128, 191, 255); } if (formularioVisualizar != null) { formularioVisualizar.MdiParent = this; formularioVisualizar.Dock = DockStyle.Fill; formularioVisualizar.Show(); } } else { if (tag == 1001) { PanelSelInicio.BackColor = Color.FromArgb(128, 191, 255); } if (tag == 1002) { PanelSelProyectos.BackColor = Color.FromArgb(128, 191, 255); } if (tag == 1003) { PanelSelTareas.BackColor = Color.FromArgb(128, 191, 255); } if (tag == 1004) { PanelSelColaboradores.BackColor = Color.FromArgb(128, 191, 255); } formularioActivo.Activate(); } this.Cursor = Cursors.Default; }
// lấy ra form theo tên // ngăn không cho mở 1 form trong nhiều tab Form GetChildFormByName(Type type) { return(MdiChildren.FirstOrDefault(f => f.GetType() == type)); }
/// <summary> /// 判断对应窗体是否已经打开 /// </summary> /// <param name="str">传入当前查询的窗体的名称</param> /// <returns>返回已经存在的窗体</returns> private Form ExistForm(string str) { return(MdiChildren.FirstOrDefault(f => f.Text == str)); }
private void OpenPack(string fileName, bool isShowDialog) { string formCaption = null; if (isShowDialog) { openPackDialog.InitialDirectory = _lastDirectory; if (openPackDialog.ShowDialog() != DialogResult.OK) { return; } fileName = openPackDialog.FileName; AddRecentPack(fileName); _lastDirectory = Path.GetDirectoryName(openPackDialog.FileName); } else if (!fileName.IsNullOrWhiteSpace()) { if (!File.Exists(fileName)) { return; } var frmOpened = MdiChildren.FirstOrDefault(frm => frm.Text == fileName); if (frmOpened != null) { frmOpened.Activate(); if (DialogUtility.ShowConfirm(true, "File is already opened, do you want to reopen it?") == DialogResult.Yes) { frmOpened.Close(); // проверяем, закрылось ли (могли предложить сохранить и закрытия не произошло) if (MdiChildren.Contains(frmOpened)) { return; } } else { return; } } } else { int index = MdiChildren.Length; do { formCaption = String.Format("Noname{0}", ++index); } while (MdiChildren.Any(frm => frm.Text == formCaption)); } try { var packForm = new PackForm(_levelTemplatePath, fileName); packForm.MdiParent = this; packForm.Activated += packForm_Activated; packForm.FormClosing += packForm_FormClosing; packForm.Disposed += packForm_Disposed; if (formCaption != null) { packForm.Text = formCaption; } packForm.Show(); UpdateFormState(); } catch (Exception ex) { DialogUtility.ShowError("Error while opening pack: {0}", ex.Message); } }
private Form CheckExist(Type formType) { return(MdiChildren.FirstOrDefault(item => item.GetType() == formType)); }
private bool CanContinueProcessing(string handle) { return(OriginalImage != null && MdiChildren.FirstOrDefault(f => f.Text == handle) == null); }