Exemple #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);
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            (new string[1])[0] = string.Empty;

            var topLevelForm = new TopLevelForm();

            cApp.Application.AddTopLevelForm(ref topLevelForm);
        }
Exemple #3
0
        TopLevelForm CreateTopLevelWindow(ReadOnlyCollection <string> args)
        {
            // Get file name, if provided
            string fileName = (args.Count > 0 ? args[0] : null);

            // Create a new top-level form
            return(TopLevelForm.CreateTopLevelWindow(fileName));
        }
Exemple #4
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();
        }