예제 #1
0
        /// <summary>
        /// Function to commit any settings.
        /// </summary>
        public override void CommitSettings()
        {
            if (!string.IsNullOrWhiteSpace(textScratchLocation.Text))
            {
                Program.Settings.ScratchPath = textScratchLocation.Text.FormatDirectory(Path.DirectorySeparatorChar);
            }

            if (!string.IsNullOrWhiteSpace(textPlugInLocation.Text))
            {
                Program.Settings.PlugInDirectory = textPlugInLocation.Text.FormatDirectory(Path.DirectorySeparatorChar);
            }

            Program.Settings.DefaultImageEditor = comboImageEditor.Text;

            var speed = (float)numericAnimateSpeed.Value;

            if ((ContentManagement.Current == null) &&
                ((!Program.Settings.StartPageAnimationPulseRate.EqualsEpsilon(speed)) ||
                 (Program.Settings.AnimateStartPageLogo != checkAnimateLogo.Checked)))
            {
                Program.Settings.AnimateStartPageLogo        = checkAnimateLogo.Checked;
                Program.Settings.StartPageAnimationPulseRate = speed;
                ContentManagement.EditorSettingsUpdated();
            }

            Program.Settings.AutoLoadLastFile = checkAutoLoadFile.Checked;
        }
예제 #2
0
파일: Program.cs 프로젝트: tmp7701/Gorgon
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Settings.Load();

                Gorgon.PlugIns.AssemblyResolver = (appDomain, e) => appDomain.GetAssemblies()
                                                  .FirstOrDefault(assembly => assembly.FullName == e.Name);

                Gorgon.Run(new AppContext());
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(null, ex);
            }
            finally
            {
                Gorgon.PlugIns.AssemblyResolver = null;

                ContentManagement.UnloadCurrentContent();

                // Clean up the plug-ins.
                foreach (var plugInItem in PlugIns.ContentPlugIns)
                {
                    plugInItem.Value.Dispose();
                }

                foreach (var plugInItem in PlugIns.WriterPlugIns)
                {
                    plugInItem.Value.Dispose();
                }

                // Shut down the graphics interface.
                if (ContentObject.Graphics != null)
                {
                    ContentObject.Graphics.Dispose();
                    ContentObject.Graphics = null;
                }

                // Clean up temporary files in scratch area.
                if (Settings != null)
                {
                    ScratchArea.DestroyScratchArea();
                }

                EditorLogging.Close();
            }
        }
예제 #3
0
        /// <summary>
        /// Function to get the file data.
        /// </summary>
        private void GetFileData()
        {
            ExpandedImage  = APIResources.unknown_document_16x16;
            CollapsedImage = ExpandedImage;
            PlugIn         = null;

            EditorMetaDataFile.Files.TryGetValue(File.FullPath, out _editorFile);

            PlugIn = ContentManagement.GetContentPlugInForFile(_editorFile) ?? ContentManagement.GetContentPlugInForFile(File.Extension);

            if ((PlugIn != null) &&
                (_editorFile != null))
            {
                ExpandedImage = CollapsedImage = PlugIn.GetContentIcon();
            }
        }
예제 #4
0
        /// <summary>
        /// Function called when the close button is clicked.
        /// </summary>
        private void OnCloseClicked()
        {
            if (Content == null)
            {
                return;
            }

            labelClose.Enabled = false;

            try
            {
                var args = new CancelEventArgs();

                OnContentClosing(args);

                if (args.Cancel)
                {
                    return;
                }

                if (ContentClosed != null)
                {
                    args = new CancelEventArgs();
                    ContentClosed(this, args);

                    if (args.Cancel)
                    {
                        return;
                    }
                }

                ContentManagement.LoadDefaultContentPane();
            }
            finally
            {
                if (!labelClose.IsDisposed)
                {
                    labelClose.Enabled = true;
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Function to commit any settings.
        /// </summary>
        public override void CommitSettings()
        {
            foreach (KeyValuePair <EditorPlugIn, PreferencePanel> panel in _settingPanels)
            {
                try
                {
                    panel.Value.CommitSettings();

                    // If we have content open that uses the plug-in that's been updated, notify its UI (if it has one).
                    if ((ContentManagement.Current != null) &&
                        (ContentManagement.Current.PlugIn == panel.Key))
                    {
                        ContentManagement.EditorSettingsUpdated();
                    }
                }
                catch (Exception ex)
                {
                    GorgonDialogs.ErrorBox(ParentForm, ex);
                }
            }
        }
예제 #6
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;
            }
        }