Пример #1
0
        /// <summary>
        /// Function to fill the plug-in list.
        /// </summary>
        private void FillList()
        {
            listPlugIns.Items.Clear();

            var plugIns = from plugIn in PlugIns.ContentPlugIns
                          where !PlugIns.IsDisabled(plugIn.Value) &&
                          plugIn.Value is IPlugInSettingsUI
                          orderby plugIn.Key
                          select plugIn;

            listPlugIns.BeginUpdate();

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                foreach (KeyValuePair <string, ContentPlugIn> plugIn in plugIns)
                {
                    listPlugIns.Items.Add(new PlugInListItem(plugIn.Value));
                }

                if (listPlugIns.Items.Count > 0)
                {
                    listPlugIns.SelectedIndex = 0;
                }
            }
            finally
            {
                listPlugIns.EndUpdate();
                Cursor.Current = Cursors.Default;
            }
        }
Пример #2
0
        /// <summary>
        /// Function to open the editor file.
        /// </summary>
        /// <param name="path">Path to the editor file.</param>
        public static void Open(string path)
        {
            var packFileSystem = new GorgonFileSystem();

            FileChanged = false;

            // Add the new file system as a mount point.
            var plugIns = from plugIn in Gorgon.PlugIns
                          where plugIn is GorgonFileSystemProviderPlugIn &&
                          !PlugIns.IsDisabled(plugIn)
                          select plugIn;

            foreach (var plugIn in plugIns)
            {
                packFileSystem.Providers.LoadProvider(plugIn.Name);
            }

            if (!packFileSystem.Providers.Any(item => item.CanReadFile(path)))
            {
                throw new FileLoadException(string.Format(APIResources.GOREDIT_ERR_NO_READ_PROVIDERS,
                                                          Path.GetFileName(path)));
            }

            packFileSystem.Mount(path);

            try
            {
                // Remove our previous scratch data.
                ResetFile();

                // At this point we should have a clean scratch area, so all files will exist in the packed file.
                // Unpack the file structure so we can work with it.
                var directories = packFileSystem.FindDirectories("*", true);
                var files       = packFileSystem.FindFiles("*", true);

                // Create our directories.
                foreach (var directory in directories)
                {
                    ScratchArea.ScratchFiles.CreateDirectory(directory.FullPath);
                }

                // Copy our files.
                foreach (var file in files)
                {
                    using (var inputStream = packFileSystem.OpenStream(file, false))
                    {
                        using (var outputStream = ScratchArea.ScratchFiles.OpenStream(file.FullPath, true))
                        {
                            inputStream.CopyTo(outputStream);
                        }
                    }
                }

                FilePath = string.Empty;
                Filename = Path.GetFileName(path);

                // Load the meta data if it exists.
                EditorMetaDataFile.Load();

                // If we can't write the file, then leave the editor file path as blank.
                // If the file path is blank, then the Save As function will be triggered if we attempt to save so we
                // can save it in a format that we DO understand.  This is of course assuming we have any plug-ins loaded
                // that will allow us to save.
                if (GetWriterPlugIn(path) != null)
                {
                    FilePath = path;
                }
            }
            catch
            {
                // We have a problem, reset whatever changes we've made.
                ResetFile();
                throw;
            }
            finally
            {
                // At this point we don't need this file system any more.  We'll
                // be using our scratch system instead.
                packFileSystem.Clear();
            }
        }
Пример #3
0
 /// <summary>
 /// Function to determine if this preference panel should be added as a tab.
 /// </summary>
 /// <returns>
 /// TRUE if the panel can be added as a tab, FALSE if not.
 /// </returns>
 public override bool CanAddAsTab()
 {
     return(PlugIns.ContentPlugIns.Any(item => !PlugIns.IsDisabled(item.Value) && item.Value is IPlugInSettingsUI));
 }