Пример #1
0
        /// <summary>
        /// Function to load in the meta data.
        /// </summary>
        /// <remarks>Use this method to retrieve any stored meta data.  If no meta data exists, then this function will do nothing.</remarks>
        /// <exception cref="GorgonLibrary.GorgonException">Thrown when the meta data is corrupted.</exception>
        public static void Load()
        {
            _metaDataFile = ScratchArea.ScratchFiles.GetFile(_path);

            // If the file doesn't exist yet, then move on.
            if (_metaDataFile == null)
            {
                Reset();
                return;
            }

            // Otherwise, load it up and parse it.
            using (Stream stream = _metaDataFile.OpenStream(false))
            {
                _metaData = XDocument.Load(stream);
            }

            // Validate the file.
            XElement rootNode = _metaData.Element(MetaDataRootName);

            GetWriterSettings(rootNode);

            GetFiles(rootNode);

            ScratchArea.AddBlockedFile(_metaDataFile);
        }
Пример #2
0
        public void initialize(StandaloneController standaloneController)
        {
            GUIManager guiManager = standaloneController.GUIManager;

            guiManager.MainGUIShown  += new Action(guiManager_MainGUIShown);
            guiManager.MainGUIHidden += new Action(guiManager_MainGUIHidden);

            //Prop Mover
            MedicalController medicalController = standaloneController.MedicalController;

            propMover = new SimObjectMover("Props", medicalController.PluginManager.RendererPlugin, medicalController.EventManager, standaloneController.SceneViewController);

            this.standaloneController = standaloneController;
            editorTimelineController  = new TimelineController(standaloneController);
            standaloneController.giveGUIsToTimelineController(editorTimelineController);

            scratchAreaController = new ScratchAreaController(standaloneController.Clipboard);

            //Controller
            editorController = new EditorController(standaloneController, editorTimelineController);
            standaloneController.DocumentController.addDocumentHandler(new ProjectDocumentHandler(editorController));
            standaloneController.DocumentController.UnknownDocumentHander = new UnknownDocumentHandler(editorController);
            propEditController = new PropEditController(propMover);

            //UI Helpers
            editorUICallback = new EditorUICallback(standaloneController, editorController, propEditController);

            typeControllerManager = new TypeControllerManager(standaloneController, this);
            typeControllerManager.FilesystemWatcherCreated += typeControllerManager_FilesystemWatcherCreated;

            //Dialogs
            scratchArea = new ScratchArea(scratchAreaController, editorUICallback);
            guiManager.addManagedDialog(scratchArea);

            projectExplorer = new ProjectExplorer(editorController, typeControllerManager);
            guiManager.addManagedDialog(projectExplorer);

            //Tasks Menu
            TaskController taskController = standaloneController.TaskController;

            aspectRatioTask = new AspectRatioTask(standaloneController.SceneViewController);

            if (MedicalConfig.ShowDeveloperTools)
            {
                taskController.addTask(new MDIDialogOpenTask(scratchArea, "Medical.ScratchArea", "Scratch Area", "EditorIcons.ScratchAreaIcon", TaskMenuCategories.Create));
                taskController.addTask(new MDIDialogOpenTask(projectExplorer, "Medical.EditorTools", "Editor Tools", "EditorIcons.EditorTools", TaskMenuCategories.Create));
                taskController.addTask(aspectRatioTask);
            }

            editorTaskbarFactory = new EditorTaskbarFactory(editorController);
            standaloneController.ViewHostFactory.addFactory(new EditorInfoBarFactory());
            standaloneController.ViewHostFactory.addFactory(new TextEditorComponentFactory());
            standaloneController.ViewHostFactory.addFactory(editorTaskbarFactory);
            CommonEditorResources.initialize(standaloneController);

            editorController.ProjectChanged += editorController_ProjectChanged;

            //Editor Views
            standaloneController.ViewHostFactory.addFactory(new OffsetSequenceEditorFactory(standaloneController.MedicalController, standaloneController.Clipboard));
        }
Пример #3
0
        /// <summary>
        /// Function to initialize the scratch files area.
        /// </summary>
        private void InitializeScratchArea()
        {
            ScratchArea.ScratchPath = Program.Settings.ScratchPath;

            EditorLogging.Print("Creating scratch area at \"{0}\"", LoggingLevel.Verbose, ScratchArea.ScratchPath);

            _splash.UpdateVersion(Resources.GOREDIT_TEXT_CREATING_SCRATCH);

            // Ensure that we're not being clever and trying to mess up our system.
            if (ScratchArea.CanAccessScratch(Program.Settings.ScratchPath) == ScratchAccessibility.SystemArea)
            {
                GorgonDialogs.ErrorBox(null, Resources.GOREDIT_ERR_CANNOT_USESYS_SCRATCH);
            }
            else
            {
                // Destroy previous scratch area files if possible.
                // Do not do this when we have it set to a system area, this will keep us from
                // destroying anything critical.
                ScratchArea.CleanOldScratchAreas();
            }

            // Ensure we can actually access the scratch area.
            while (ScratchArea.CanAccessScratch(Program.Settings.ScratchPath) != ScratchAccessibility.Accessible)
            {
                EditorLogging.Print("Could not access scratch area at \"{0}\"", LoggingLevel.Verbose, Program.Settings.ScratchPath);

                if (ScratchArea.SetScratchLocation() == ScratchAccessibility.Canceled)
                {
                    // Exit the application if we cancel.
                    MainForm.Dispose();
                    Gorgon.Quit();
                    return;
                }

                EditorLogging.Print("Setting scratch area to \"{0}\".", LoggingLevel.Verbose, Program.Settings.ScratchPath);

                // Update with the new scratch path.
                Program.Settings.Save();
            }

            ScratchArea.InitializeScratch();

            // Get only the providers that are not disabled.
            var plugIns = from plugIn in Gorgon.PlugIns
                          where plugIn is GorgonFileSystemProviderPlugIn &&
                          PlugIns.UserDisabledPlugIns.All(name => !string.Equals(name, plugIn.Name, StringComparison.OrdinalIgnoreCase))
                          select plugIn;

            foreach (GorgonPlugIn plugIn in plugIns)
            {
                ScratchArea.ScratchFiles.Providers.LoadProvider(plugIn.Name);
            }
        }
Пример #4
0
        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();
            }
        }
Пример #5
0
        /// <summary>
        /// Handles the Click event of the buttonScratch control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void buttonScratch_Click(object sender, EventArgs e)
        {
            ScratchAccessibility result = ScratchArea.SetScratchLocation();

            if (result != ScratchAccessibility.Accessible)
            {
                if (result == ScratchAccessibility.SystemArea)
                {
                    GorgonDialogs.ErrorBox(null, Resources.GOREDIT_ERR_CANNOT_USESYS_SCRATCH);
                }

                return;
            }

            textScratchLocation.Text = Program.Settings.ScratchPath;
            textScratchLocation.Select(0, textScratchLocation.Text.Length);
        }
Пример #6
0
        /// <summary>
        /// Function to store the meta data.
        /// </summary>
        /// <remarks>Use this to store the meta data in the file system.</remarks>
        public static void Save()
        {
            if (_metaData == null)
            {
                return;
            }

            XElement root = _metaData.Element(MetaDataRootName);

            if (root == null)
            {
                root = new XElement(MetaDataRootName);
                _metaData.Add(root);
            }

            // Add or update the elements to the XML document.
            XElement   writerPlugInElement = AddOrUpdateNode(root, WriterPlugInNode);
            XAttribute writerTypeAttr      = AddOrUpdateAttribute(writerPlugInElement, TypeNameAttr, WriterPlugInType);

            if (string.IsNullOrWhiteSpace(WriterPlugInType))
            {
                writerTypeAttr.Remove();
            }

            // Add files.
            if (Files.Count > 0)
            {
                XElement fileList = AddOrUpdateNode(root, EditorFilesNode);
                fileList.Add(Files.Serialize());
            }

            _metaDataFile = ScratchArea.ScratchFiles.WriteFile(_path, null);
            using (Stream stream = _metaDataFile.OpenStream(true))
            {
                _metaData.Save(stream);
            }

            // Add to the block list if this file should not show up.
            ScratchArea.AddBlockedFile(_metaDataFile);
        }
Пример #7
0
        /// <summary>
        /// Function to validate any settings on this panel.
        /// </summary>
        /// <returns>
        /// TRUE if the settings are valid, FALSE if not.
        /// </returns>
        public override bool ValidateSettings()
        {
            if (ScratchArea.CanAccessScratch(textScratchLocation.Text.FormatDirectory(Path.DirectorySeparatorChar)) != ScratchAccessibility.Accessible)
            {
                return(false);
            }

            if (!string.Equals(textScratchLocation.Text.FormatDirectory(Path.DirectorySeparatorChar), Program.Settings.ScratchPath, StringComparison.OrdinalIgnoreCase))
            {
                GorgonDialogs.InfoBox(ParentForm, Resources.GOREDIT_DLG_SCRATCH_LOC_CHANGE);
            }

            if ((string.Equals(Program.Settings.DefaultImageEditor,
                               comboImageEditor.Text,
                               StringComparison.OrdinalIgnoreCase)) &&
                (ContentManagement.Current != null))
            {
                GorgonDialogs.InfoBox(ParentForm, Resources.GOREDIT_DLG_IMAGE_EDITOR_CHANGED);
            }

            try
            {
                if (!Directory.Exists(textPlugInLocation.Text.FormatDirectory(Path.DirectorySeparatorChar)))
                {
                    return(false);
                }

                if (!string.Equals(textPlugInLocation.Text.FormatDirectory(Path.DirectorySeparatorChar), Program.Settings.PlugInDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    GorgonDialogs.InfoBox(ParentForm, Resources.GOREDIT_DLG_PLUGIN_LOC_CHANGE);
                }
            }
            catch
            {
                // We don't care about exceptions at this point.
                return(false);
            }

            return(true);
        }
Пример #8
0
 /// <summary>
 /// Function to reset the file data.
 /// </summary>
 private static void ResetFile()
 {
     ScratchArea.DestroyScratchArea();
     ScratchArea.InitializeScratch();
     EditorMetaDataFile.Reset();
 }