Exemple #1
0
        public static TopLevelForm <T> CreateTopLevelWindow(string fileName, IUnityContainer container)
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                foreach (Form openForm in Application.OpenForms)
                {
                    if (!(openForm is TopLevelForm <T>))
                    {
                        continue;
                    }
                    TopLevelForm <T> f = openForm as TopLevelForm <T>;
                    if (string.Compare(f.fileName, fileName,
                                       true) == 0)
                    {
                        openForm.Activate();
                        return(f);
                    }
                }
            }
            TopLevelForm <T> form = container.Resolve <TopLevelForm <T> >();

            form.Initialize(fileName);
            container.Resolve <SingleInstanceApplication <T> >()
            .AddTopLevelForm(form);
            form.Activate();
            form.Show();
            return(form);
        }
        public void AddTopLevelForm(TopLevelForm <T> form)
        {
            form.Activated  += TopLevelForm_Activated;
            form.FormClosed += TopLevelForm_FormClosed;
            AddWindowMenu(form);

            if (this.OpenForms.Count == 1)
            {
                this.MainForm = form;
            }
        }
 private void AddWindowMenu(TopLevelForm <T> windowsMenuForm)
 {
     windowsMenuForm.WindowsMenu.DropDownOpening +=
         WindowMenu_DropDownOpening;
 }
        public TopLevelForm <T> CreateTopLevelWindow(ReadOnlyCollection <string> args)
        {
            string fileName = (args.Count > 0) ? args[0] : null;

            return(TopLevelForm <T> .CreateTopLevelWindow(fileName, container));
        }