Beispiel #1
0
        private void menuItemDefaultProperties_Click(object sender, System.EventArgs e)
        {
            DefaultProperties dp = new DefaultProperties(this);
            DialogResult result = dp.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                IMyGenContent bw = null;
                DockContentCollection coll = this.dockManager.Contents;

                DefaultSettings settings = DefaultSettings.Instance;

                for (int i = 0; i < coll.Count; i++)
                {
                    bw = coll[i] as IMyGenContent;

                    if (bw != null)
                    {
                        try
                        {
                            bw.Alert(dp, "UpdateDefaultSettings");
                        }
#if DEBUG
						catch (Exception ex) { throw ex; }
#else
                        catch { }
#endif
                    }
                }
            }
        }
 private void toolStripButtonOptions_Click(object sender, EventArgs e)
 {
     if (!settings.EnableDocumentStyleSettings)
     {
         if (options != null) { this.OptionsDockContent.Hide(); this.options = null; }
         DefaultSettingsDialog dsd = new DefaultSettingsDialog(this);
         dsd.ShowDialog(this);
     }
     else
     {
         if (this.OptionsDockContent.IsHidden)
         {
             this.OptionsDockContent.Show(this.dockPanel);
         }
         else
         {
             this.OptionsDockContent.Hide();
         }
     }
 }
Beispiel #3
0
        private void MDIParent_Load(object sender, System.EventArgs e)
        {
            DefaultSettings settings = DefaultSettings.Instance;

            if (settings.CompactMemoryOnStartup) FlushMemory();

            switch (settings.WindowState)
            {
                case "Maximized":

                    this.WindowState = FormWindowState.Maximized;
                    break;

                case "Minimized":

                    this.WindowState = FormWindowState.Minimized;
                    break;

                case "Normal":

                    int x = Convert.ToInt32(settings.WindowPosLeft);
                    int y = Convert.ToInt32(settings.WindowPosTop);
                    int w = Convert.ToInt32(settings.WindowPosWidth);
                    int h = Convert.ToInt32(settings.WindowPosHeight);

                    this.Location = new System.Drawing.Point(x, y);
                    this.Size = new Size(w, h);
                    break;
            }

            if (settings.FirstLoad)
            {
                DefaultProperties dp = new DefaultProperties(this);
                DialogResult result = dp.ShowDialog(this);
            }

            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DOCK_CONFIG_FILE);
            try
            {
                if (File.Exists(configFile))
                {
                    dockManager.LoadFromXml(configFile, new DeserializeDockContent(GetContentFromPersistString));

                    //TemplateEditor e1 = this.OpenTemplateEditor();
                    foreach (DockContent content in dockManager.Contents)
                    {
                        if (content is IMyGenContent)
                        {
                            IMyGenContent baseWindow = content as IMyGenContent;
                            //baseWindow.ResetMenu();
                        }
                    }
                }
            }
#if DEBUG
			catch (Exception ex)
			{
				throw ex;
			}
#else
            catch
            {
                if (File.Exists(configFile))
                {
                    try
                    {
                        File.Delete(configFile);
                    }
                    catch { }
                }
            }
#endif

            if (this.startupFiles != null)
            {
                foreach (string filename in this.startupFiles)
                {
                    try
                    {
                        LaunchFileEditor(filename);
                    }
#if DEBUG
				catch (Exception ex) { throw ex; }
#else
                    catch { }
#endif

                }
            }

            if (settings.CompactMemoryOnStartup)
            {
                FlushMemory();
            }

            if (this.dockingStartupTemplates.Count > 0)
            {
                foreach (string filename in this.dockingStartupTemplates)
                {
                    try
                    {
                        if (filename == EMPTY_CONSTANT)
                        {
                            this.OpenTemplateEditor();
                        }
                        else
                        {
                            this.OpenTemplateEditor(filename);
                        }
                    }
#if DEBUG
				catch (Exception ex) { throw ex; }
#else
                    catch { }
#endif

                }
            }

            if (this.dockingStartupProjects.Count > 0)
            {
                foreach (string filename in this.dockingStartupProjects)
                {
                    try
                    {
                        this.OpenProjectEditor(filename);
                    }
#if DEBUG
				catch (Exception ex) { throw ex; }
#else
                    catch { }
#endif

                }
            }

            if (settings.CompactMemoryOnStartup)
            {
                this.Update();
                FlushMemory();
            }

            FinishVersionCheck(settings);
        }
        private void MyGenerationMDI_Load(object sender, EventArgs e)
        {
            switch (settings.WindowState)
            {
                case "Maximized":

                    this.WindowState = FormWindowState.Maximized;
                    break;

                case "Minimized":

                    this.WindowState = FormWindowState.Minimized;
                    break;

                case "Normal":

                    int x = Convert.ToInt32(settings.WindowPosLeft);
                    int y = Convert.ToInt32(settings.WindowPosTop);
                    int w = Convert.ToInt32(settings.WindowPosWidth);
                    int h = Convert.ToInt32(settings.WindowPosHeight);

                    this.Location = new System.Drawing.Point(x, y);
                    this.Size = new Size(w, h);
                    break;
            }

            // Load up the scintilla configuration
            ConfigurationUtility cu = new ConfigurationUtility();

            FileInfo scintillaConfigFile = new FileInfo(startupPath + SCINTILLA_CONFIG_FILE);
            #region HACK: this needs to be cleaned up at some point.
            // If the file doesn't exist, create it.
            if (scintillaConfigFile.Exists)
            {
                //TODO: Retry this with a copy of the file until we can upgrade Scintilla.Net with a fix.
                int maxTries = 3;
                while (maxTries > 0)
                {
                    try
                    {
                        configFile = cu.LoadConfiguration(scintillaConfigFile.FullName) as ConfigFile;
                        break;
                    }
                    catch
                    {
                        if (--maxTries == 1)
                        {
                            File.Copy(scintillaConfigFile.FullName, scintillaConfigFile.FullName + ".tmp", true);
                            scintillaConfigFile = new FileInfo(scintillaConfigFile.FullName + ".tmp");
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(10);
                        }
                    }
                }
            }
            #endregion
            if (configFile != null)
            {
                configureDelegate = configFile.MasterScintilla.Configure;
                ZeusScintillaControl.StaticConfigure = configureDelegate;
            }

            // Dock Content configuration
            DeserializeDockContent deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
            string dockConfigFileName = startupPath + DOCK_CONFIG_FILE;

            if (File.Exists(dockConfigFileName))
            {
                try 
                {
                    dockPanel.LoadFromXml(dockConfigFileName, deserializeDockContent);
                }
                catch (Exception ex)
                {
                    try 
                    {
                        File.Delete(dockConfigFileName);
                    }
                    catch {}
                }
            }

            // Startup files from the command line
            if (this.startupFiles != null)
            {
                OpenDocuments(startupFiles);
            }

            // Show Default Properties if this is the first load.
            if (settings.FirstLoad)
            {
                if (!settings.EnableDocumentStyleSettings)
                {
                    if (options != null) { this.OptionsDockContent.Hide(); this.options = null; }
                    DefaultSettingsDialog dsd = new DefaultSettingsDialog(this);
                    dsd.ShowDialog(this);
                }
                else
                {
                    if (this.OptionsDockContent.IsHidden)
                        this.OptionsDockContent.Show(this.dockPanel);
                    this.OptionsDockContent.Activate();
                }
            }
        }