Exemplo n.º 1
0
        public static TopLevelForm CreateTopLevelWindow(string fileName)
        {
            // Detect whether file is already open
            if (!string.IsNullOrEmpty(fileName))
            {
                foreach (TopLevelForm openForm in Application.OpenForms)
                {
                    if (string.Compare(openForm.FileName(), fileName, true) == 0)
                    {
                        // Bring form to top
                        openForm.Activate();
                        return(openForm);
                    }
                }
            }

            // Create new top-level form and open file
            TopLevelForm form = new TopLevelForm();

            form.OpenFile(fileName);
            form.Show();
            // Bring form to top
            form.Activate();
            return(form);
        }
Exemplo n.º 2
0
        public void AddTopLevelForm(ref TopLevelForm form)
        {
            // Add form to collection of forms and
            // watch for it to activate and close

            // Set initial top-level form to activate
            if (this.OpenForms.Count == 1)
            {
                this.MainForm = form;
            }

            form.Show();
        }