コード例 #1
0
        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
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
ファイル: mdi.cs プロジェクト: lanicon/Commander
        private void Mdi_MdiChildActivate(object sender, EventArgs e)
        {
            var fr = MdiChildren.FirstOrDefault(z => z is QuickTagsWindow);

            if (fr == null)
            {
                return;
            }
            fr.BringToFront();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        void _openForm(Form f)
        {
            var frm = MdiChildren.FirstOrDefault(q => q.Text == f.Text);

            if (frm == null)
            {
                f.MdiParent = this;
                f.Show();
            }
            else
            {
                frm.Activate();
            }
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: KEEHY/E-BookSystem
        //탭 중복 생성 방지
        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();
            }
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: DAE-GYUN/PetShelter
        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();
            }
        }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: gusmanb/ResourceDesigner
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: saitorhan/ISO27001Tools
        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();
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: FrmMain.cs プロジェクト: truonghoaiphuc/CRMNew
        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();
        }
コード例 #15
0
ファイル: MainForm.cs プロジェクト: silvarui/Honeywell
        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();
            }
        }
コード例 #16
0
ファイル: MainForm.cs プロジェクト: silvarui/Honeywell
        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();
            }
        }
コード例 #17
0
        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();
            }
        }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: gusmanb/ResourceDesigner
        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();
        }
コード例 #19
0
ファイル: frmTrangChu.cs プロジェクト: ngocthangh/OOAD
        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();
            }
        }
コード例 #20
0
        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();
            }
        }
コード例 #21
0
        /// <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();
            }
        }
コード例 #22
0
ファイル: MainForm.cs プロジェクト: kaiascezar/GothamSubway
        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();
            }
        }
コード例 #23
0
ファイル: FrmMain.cs プロジェクト: truonghoaiphuc/CRMNew
        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();
        }
コード例 #24
0
 public DataViewForm <T> GetDataViewForm <T>() where T : class, IIdentifiable
 {
     return(MdiChildren.FirstOrDefault(i => i is DataViewForm <T>) as DataViewForm <T>);
 }
コード例 #25
0
        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;
        }
コード例 #26
0
ファイル: frmMain.cs プロジェクト: tonnystark/quanlinv
 // 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));
 }
コード例 #27
0
ファイル: WmsRibbonMain.cs プロジェクト: dreakchang/JWMSH
 /// <summary>
 /// 判断对应窗体是否已经打开
 /// </summary>
 /// <param name="str">传入当前查询的窗体的名称</param>
 /// <returns>返回已经存在的窗体</returns>
 private Form ExistForm(string str)
 {
     return(MdiChildren.FirstOrDefault(f => f.Text == str));
 }
コード例 #28
0
        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);
            }
        }
コード例 #29
0
ファイル: FormMain.cs プロジェクト: koolstyle1905/SE-Final
 private Form CheckExist(Type formType)
 {
     return(MdiChildren.FirstOrDefault(item => item.GetType() == formType));
 }
コード例 #30
0
 private bool CanContinueProcessing(string handle)
 {
     return(OriginalImage != null &&
            MdiChildren.FirstOrDefault(f => f.Text == handle) == null);
 }