コード例 #1
0
        static void Main(string [] args)
        {
            prescreen = new FerdaPrescreen();

            prescreen.Show();
            prescreen.Refresh();

            //tries to load the config
            try
            {
                iceConfig = FrontEndConfig.Load();
            }
            catch
            {
                prescreen.Hide();
                MessageBox.Show("Could not locate the FrontEndConfig.xml configuration file",
                    "Invalid config file",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            //loading the form
            FerdaForm form = new FerdaForm();
            form.SetupResources(iceConfig);

            //switching to the "bin" directory
            string previousDir = FrontEndCommon.SwitchToBinDirectory();

            prescreen.DisplayText(form.ResManager.GetString("LoadingProjectManager"));
            //loading the project manager
            ProjectManager.ProjectManager pm =
                new ProjectManager.ProjectManager(
                args,
                iceConfig.ProjectManagerOptions,
                new Ferda.FrontEnd.OutputI());

            //setting the form for the project manager
            form.RightAfterConstructor(pm, prescreen);

            prescreen.DisplayText(form.ResManager.GetString("LoadingAddIns"));
            //loading the add ins
            loadAddIns(form, pm.ModulesManager.Helper.ObjectAdapter, pm.ModulesManager, form.propertyGrid);
            pm.ModulesManager.AddModuleServices(iceConfig.FrontEndIceObjects);

            //switching to the directory from where it was executed
            FrontEndCommon.SwitchToPreviousDirectory(previousDir);

            //loading the associated file (if there is one)
            if (args.Length > 0 && !(args[0].StartsWith("--")))
            {
                FrontEndCommon.LoadProject(args[0], form, form.ResManager, ref pm,
                    form);
                form.AddToRecentProjects(args[0]);
                form.menu.SetupDesktop();
                form.WindowState = FormWindowState.Maximized;
            }

            prescreen.Hide();
            try
            {
                //running the application
                Application.Run(form);
            }
            finally
            {
                //clearing the add in and project manager resources
                addIns.Clear();
                pm.DestroyProjectManager();
            }

            form.SaveRecentProjects();

            //tries to save the config
            try
            {
                FrontEndConfig.Save(iceConfig);
            }
            catch
            {
                MessageBox.Show("Could not save the FrontEndConfig.xml configuration file",
                    "Invalid config file",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }