예제 #1
0
        /// <summary>
        /// Function to load the previous file.
        /// </summary>
        private void LoadLastFile()
        {
            try
            {
                if (!ScratchArea.ScratchFiles.Providers.Any(item => item.CanReadFile(Program.Settings.LastEditorFile)))
                {
                    return;
                }

                _splash.UpdateVersion(Resources.GOREDIT_TEXT_LOAD_PREV_FILE);

                if (!File.Exists(Program.Settings.LastEditorFile))
                {
                    return;
                }

                FileManagement.Open(Program.Settings.LastEditorFile);
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(null, string.Format(Resources.GOREDIT_DLG_OPEN_ERROR, Program.Settings.LastEditorFile, ex.Message), null, ex);
                Program.Settings.LastEditorFile = string.Empty;
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppContext"/> class.
        /// </summary>
        public AppContext()
        {
            float startTime = GorgonTiming.SecondsSinceStart;

            try
            {
                PlugIns.DefaultImageEditorPlugIn = Program.Settings.DefaultImageEditor;

                _splash  = new FormSplash();
                MainForm = new FormMain();

                _splash.Show();
                _splash.Refresh();

                // Fade in our splash screen.
                FadeSplashScreen(true, 500.0f);

                EditorLogging.Open();

                InitializeGraphics();
                InitializePlugIns();
                InitializeScratchArea();
                InitializeInput();

                FileManagement.InitializeFileTypes();

                // Load the last opened file.
                if ((Program.Settings.AutoLoadLastFile) && (!string.IsNullOrWhiteSpace(Program.Settings.LastEditorFile)))
                {
                    LoadLastFile();
                }

                // Set up the default pane.
                _splash.UpdateVersion(Resources.GOREDIT_TEXT_LOAD_DEFAULT);
                ContentManagement.DefaultContentType = typeof(DefaultContent);
                ContentManagement.LoadDefaultContentPane();

                // Keep showing the splash screen.
                while ((GorgonTiming.SecondsSinceStart - startTime) < 3)
                {
                    Thread.Sleep(1);
                }

                FadeSplashScreen(false, 250.0f);

                // Bring up our application form.
                MainForm.Show();
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(null, ex);

                if ((MainForm != null) && (!MainForm.IsDisposed))
                {
                    MainForm.Dispose();
                }

                // Signal quit.
                Gorgon.Quit();
            }
            finally
            {
                if (_splash != null)
                {
                    _splash.Dispose();
                }
                _splash = null;
            }
        }