ARCed.Editor.Editor C# (CSharp) Method

Editor() public method

Constructs a new Editor, automatically opening a a project if filename is given
public Editor ( string filename = null ) : System
filename string
return System
        public Editor(string filename = null)
        {
            //******************************************************************************
            #if DEBUG
            // This will automatically remove editor settings on startup, since during development
            // they have been changing and can be corrupted, preventing a proper run. Final version
            // will remove old settings and create new in event of corrupted data due to user edit.
            string editorSetting = PathHelper.EditorSettings;
            if (File.Exists(editorSetting))
                File.Delete(editorSetting);
            #endif
            //*******************************************************************************
            ResourceHelper.Initialize();
            FontHelper.LoadUserFonts();
            LoadSettings();
            //Log.AppendFormat("ARCed Log File: {0}\n\n", DateTime.Now);
            // Create editor form and set the icon to match the executable
            this.InitializeComponent();
            MainInstance = this;
            Registry.Host = this;
            ///////////////////////////////
            MainDock = this.dockMain;
            TilesetXnaPanel.Settings = Settings.ImageColorSettings;
            //////////////////////////////
            FindReplace.ParentDock = this.dockMain;
            StatusBar = this.statusStripMain;
            Windows.ScriptTabContextMenu = this.contextMenuScriptTab;
            this.dockMain.Skin = Settings.WindowSkin;

            Icon = Icon.ExtractAssociatedIcon(PathHelper.EditorPath);
            if (Mode.HasFlag(EditorMode.Debug))
                new Thread(lamda => NativeMethods.SetConsoleIcon(Icon.Handle)).Start();

            // Show the splash screen
            if (Settings.ShowSplash)
            {
                Hide();
                var splashthread = new Thread(SplashScreen.ShowSplashScreen)
                {
                    IsBackground = true
                };
                splashthread.Start();
                this.StartSplash(filename);
            }
            else
            {
                this.RestoreWindowLocation();
                if (File.Exists(filename) && Path.GetExtension(filename) == ".arcproj")
                    this.LoadProject(filename);
            }
            Registry.LoadAll();
            // Set deserializer for restoring window layout.
            this._deserializeDockContent = GetContentFromPersistString;

            Project.Settings = new ProjectSettings();

            // TEST /////////////////////////////////////////////////////////////////////////////////////

            string testPath = Path.Combine(PathHelper.EditorDirectory,
                @"Chronicles of Sir Lag-A-Lot\Chronicles of Sir Lag-A-Lot.arcproj");
            if (File.Exists(testPath))
                this.LoadProject(testPath);

            new MapEditorMainForm().Show(MainDock);
            new StateMainForm().Show(MainDock);
            new AnimationMainForm().Show(MainDock);
            new TilesetsMainForm().Show(MainDock);
            //new Database.Troops.TroopMainForm().Show(Editor.MainDock);

            // TEST /////////////////////////////////////////////////////////////////////////////////////

            // Suspend child controls from resizing every pixel
            ResizeBegin += (s, e) => SuspendLayout();
            ResizeEnd += (s, e) => ResumeLayout(true);
        }