コード例 #1
0
        /// <summary>Initializes a new instance of the <see cref="ViewModelInjection"/> class.</summary>
        /// <param name="copy">The objects to copy.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="copy"/> parameter is <b>null</b>.</exception>
        protected ViewModelInjection(IViewModelInjection copy)
        {
            if (copy == null)
            {
                throw new ArgumentNullException(nameof(copy));
            }

            Log            = copy.Log;
            BusyService    = copy.BusyService;
            MessageDisplay = copy.MessageDisplay;
        }
コード例 #2
0
        /// <summary>Initializes a new instance of the <see cref="SettingsPlugInListItemParameters"/> class.</summary>
        /// <param name="plugin">The plugin to evaluate.</param>
        /// <param name="commonServices">Common application services.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="plugin"/> is parameter <b>null</b>.</exception>
        public SettingsPlugInListItemParameters(EditorPlugIn plugin, IViewModelInjection commonServices)
            : base(commonServices)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            Name           = string.IsNullOrWhiteSpace(plugin.Description) ? plugin.Name : plugin.Description;
            Type           = plugin.PlugInType;
            State          = Resources.GOREDIT_PLUGIN_STATE_LOADED;
            DisabledReason = string.Empty;
            Path           = plugin.PlugInPath;
        }
コード例 #3
0
        /// <summary>Initializes a new instance of the <see cref="SettingsPlugInListItemParameters"/> class.</summary>
        /// <param name="plugin">The plugin to evaluate.</param>
        /// <param name="commonServices">Common application services.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="plugin"/> is parameter <b>null</b>.</exception>
        public SettingsPlugInListItemParameters(IDisabledPlugIn plugin, IViewModelInjection commonServices)
            : base(commonServices)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            Name           = plugin.PlugInName;
            Type           = PlugInType.Unknown;
            State          = plugin.ReasonCode.ToString();
            DisabledReason = plugin.Description;
            Path           = plugin.Path;
        }
コード例 #4
0
ファイル: ViewModelFactory.cs プロジェクト: ishkang/Gorgon
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewModelFactory"/> class.
 /// </summary>
 /// <param name="settings">The settings for the application.</param>
 /// <param name="providers">The providers used to open/save files.</param>
 /// <param name="contentPlugIns">The plugins used for content.</param>
 /// <param name="toolPlugIns">The plugins used for application tools.</param>
 /// <param name="projectManager">The application project manager.</param>
 /// <param name="viewModelInjection">The common services for the application.</param>
 /// <param name="clipboardService">The application clipboard service.</param>
 /// <param name="dirLocatorService">The directory locator service.</param>
 /// <param name="fileScanService">The file scanning service used to scan content files for content plugin associations.</param>
 /// <param name="folderBrowser">The file system folder browser service.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <b>null</b>.</exception>
 public ViewModelFactory(EditorSettings settings,
                         FileSystemProviders providers,
                         ContentPlugInService contentPlugIns,
                         ToolPlugInService toolPlugIns,
                         ProjectManager projectManager,
                         IViewModelInjection viewModelInjection,
                         ClipboardService clipboardService,
                         DirectoryLocateService dirLocatorService,
                         FileScanService fileScanService,
                         IEditorFileSystemFolderBrowseService folderBrowser)
 {
     Settings            = settings ?? throw new ArgumentNullException(nameof(settings));
     FileSystemProviders = providers ?? throw new ArgumentNullException(nameof(providers));
     ContentPlugIns      = contentPlugIns ?? throw new ArgumentNullException(nameof(contentPlugIns));
     ToolPlugIns         = toolPlugIns ?? throw new ArgumentNullException(nameof(toolPlugIns));
     _projectManager     = projectManager ?? throw new ArgumentNullException(nameof(projectManager));
     _viewModelInjection = viewModelInjection ?? throw new ArgumentNullException(nameof(viewModelInjection));
     _clipboard          = clipboardService ?? throw new ArgumentNullException(nameof(clipboardService));
     _dirLocator         = dirLocatorService ?? throw new ArgumentNullException(nameof(dirLocatorService));
     _fileScanService    = fileScanService ?? throw new ArgumentNullException(nameof(fileScanService));
     _folderBrowser      = folderBrowser ?? throw new ArgumentNullException(nameof(folderBrowser));
 }
コード例 #5
0
 /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteContentParameters"/> class.</summary>
 /// <param name="factory">The factory for building sprite content data.</param>
 /// <param name="spriteFile">The sprite file.</param>
 /// <param name="spriteTextureFile">The sprite texture file.</param>
 /// <param name="fileManager">The file manager used to access external content.</param>
 /// <param name="textureService">The texture service to use when reading sprite texture data.</param>
 /// <param name="sprite">The sprite being edited.</param>
 /// <param name="codec">The codec to use when reading/writing sprite data.</param>
 /// <param name="manualRectEdit">The manual rectangle editor view model.</param>
 /// <param name="manualVertexEdit">The manual vertex editor view model.</param>
 /// <param name="spritePickMaskEditor">The sprite picker mask color editor.</param>
 /// <param name="colorEditor">The color editor for the sprite.</param>
 /// <param name="anchorEditor">The anchor editor for the sprite.</param>
 /// <param name="wrapEditor">The texture wrapping state editor for the sprite.</param>
 /// <param name="settings">The plug in settings view model.</param>
 /// <param name="undoService">The undo service.</param>
 /// <param name="scratchArea">The file system used to write out temporary working data.</param>
 /// <param name="commonServices">Common application services.</param>
 public SpriteContentParameters(
     ISpriteContentFactory factory,
     IContentFile spriteFile,
     IContentFile spriteTextureFile,
     IContentFileManager fileManager,
     ISpriteTextureService textureService,
     GorgonSprite sprite,
     IGorgonSpriteCodec codec,
     IManualRectangleEditor manualRectEdit,
     IManualVertexEditor manualVertexEdit,
     ISpritePickMaskEditor spritePickMaskEditor,
     ISpriteColorEdit colorEditor,
     ISpriteAnchorEdit anchorEditor,
     ISpriteWrappingEditor wrapEditor,
     ISamplerBuildService samplerBuilder,
     IEditorPlugInSettings settings,
     IUndoService undoService,
     IGorgonFileSystemWriter <Stream> scratchArea,
     IViewModelInjection commonServices)
     : base(spriteFile, commonServices)
 {
     Factory               = factory ?? throw new ArgumentNullException(nameof(factory));
     Sprite                = sprite ?? throw new ArgumentNullException(nameof(sprite));
     UndoService           = undoService ?? throw new ArgumentNullException(nameof(undoService));
     ContentFileManager    = fileManager ?? throw new ArgumentNullException(nameof(fileManager));
     ScratchArea           = scratchArea ?? throw new ArgumentNullException(nameof(scratchArea));
     TextureService        = textureService ?? throw new ArgumentNullException(nameof(textureService));
     SpriteCodec           = codec ?? throw new ArgumentNullException(nameof(codec));
     ManualRectangleEditor = manualRectEdit ?? throw new ArgumentNullException(nameof(manualRectEdit));
     ManualVertexEditor    = manualVertexEdit ?? throw new ArgumentNullException(nameof(manualVertexEdit));
     SpritePickMaskEditor  = spritePickMaskEditor ?? throw new ArgumentNullException(nameof(spritePickMaskEditor));
     Settings              = settings ?? throw new ArgumentNullException(nameof(settings));
     ColorEditor           = colorEditor ?? throw new ArgumentNullException(nameof(colorEditor));
     AnchorEditor          = anchorEditor ?? throw new ArgumentNullException(nameof(anchorEditor));
     SpriteWrappingEditor  = wrapEditor ?? throw new ArgumentNullException(nameof(wrapEditor));
     SamplerBuilder        = samplerBuilder ?? throw new ArgumentNullException(nameof(samplerBuilder));
     SpriteTextureFile     = spriteTextureFile;
 }
コード例 #6
0
 /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.ImageEditor.ViewModels.DimensionSettingsParameters"/> class.</summary>
 /// <param name="videoAdapter">The video adapter.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <b>null</b>.</exception>
 public DimensionSettingsParameters(IGorgonVideoAdapterInfo videoAdapter, IViewModelInjection commonServices)
     : base(commonServices) => VideoAdapter = videoAdapter ?? throw new ArgumentNullException(nameof(videoAdapter));
コード例 #7
0
 /// <summary>Initializes a new instance of the <see cref="SpriteFilesParameters"/> class.</summary>
 /// <param name="entries">The file system sprite entries.</param>
 /// <param name="searchService">The search service used to search through the sprite entries.</param>
 /// <param name="commonServices">The common services for the application.</param>
 /// <exception cref="ArgumentNullException">Thrown when any of the parameters are <b>null</b>.</exception>
 public SpriteFilesParameters(IReadOnlyList <ContentFileExplorerDirectoryEntry> entries, ISearchService <IContentFileExplorerSearchEntry> searchService, IViewModelInjection commonServices)
     : base(commonServices)
 {
     Entries       = entries ?? throw new ArgumentNullException(nameof(entries));
     SearchService = searchService ?? throw new ArgumentNullException(nameof(searchService));
 }
コード例 #8
0
 /// <summary>Initializes a new instance of the <see cref="TextureAtlasParameters"/> class.</summary>
 /// <param name="settings">The settings for the plug in.</param>
 /// <param name="spriteFiles">The sprite file manager.</param>
 /// <param name="atlasGen">The atlas generation service.</param>
 /// <param name="fileService">The service used for file I/O operations.</param>
 /// <param name="folderBrowser">The folder browser.</param>
 /// <param name="commonServices">The common services for the application.</param>
 /// <exception cref="ArgumentNullException">Thrown when any of the parameters are <b>null</b>.</exception>
 public TextureAtlasParameters(TextureAtlasSettings settings, ISpriteFiles spriteFiles, IGorgonTextureAtlasService atlasGen, IFileIOService fileService, IFileSystemFolderBrowseService folderBrowser, IViewModelInjection commonServices)
     : base(commonServices)
 {
     Settings       = settings ?? throw new ArgumentNullException(nameof(settings));
     SpriteFiles    = spriteFiles ?? throw new ArgumentNullException(nameof(spriteFiles));
     AtlasGenerator = atlasGen ?? throw new ArgumentNullException(nameof(atlasGen));
     FolderBrowser  = folderBrowser ?? throw new ArgumentNullException(nameof(folderBrowser));
     FileManager    = fileService ?? throw new ArgumentNullException(nameof(fileService));
 }
コード例 #9
0
ファイル: ExtractParameters.cs プロジェクト: ishkang/Gorgon
        /// <summary>Initializes a new instance of the <see cref="ExtractParameters"/> class.</summary>
        /// <param name="settings">The plug in settings.</param>
        /// <param name="data">The data structure that will hold the information used to extract sprites.</param>
        /// <param name="textureFile">The file used as the texture.</param>
        /// <param name="extractor">The extractor used to build the sprites.</param>
        /// <param name="colorPicker">The color picker service.</param>
        /// <param name="folderBrowser">The project file system folder browser service.</param>
        /// <param name="commonServices">The common services.</param>
        /// <exception cref="ArgumentNullException">Thrown when the any parameters are <b>null</b>.</exception>
        /// <exception cref="ArgumentMissingException">Thrown when the <see cref="SpriteExtractionData.Texture"/> property of the <paramref name="data"/> parameter is <b>null</b>.</exception>
        public ExtractParameters(ExtractSpriteToolSettings settings, SpriteExtractionData data, IContentFile textureFile, IExtractorService extractor, IColorPickerService colorPicker, IFileSystemFolderBrowseService folderBrowser, IViewModelInjection commonServices)
            : base(commonServices)
        {
            Settings      = settings ?? throw new ArgumentNullException(nameof(settings));
            Data          = data ?? throw new ArgumentNullException(nameof(data));
            Extractor     = extractor ?? throw new ArgumentNullException(nameof(extractor));
            ColorPicker   = colorPicker ?? throw new ArgumentNullException(nameof(colorPicker));
            FolderBrowser = folderBrowser ?? throw new ArgumentNullException(nameof(folderBrowser));
            TextureFile   = textureFile ?? throw new ArgumentNullException(nameof(textureFile));

            if (data.Texture == null)
            {
                throw new ArgumentMissingException(nameof(data.Texture), nameof(data));
            }
        }
コード例 #10
0
 /// <summary>Initializes a new instance of the <see cref="SettingsPlugInsListParameters"/> class.</summary>
 /// <param name="plugins">The plugins to display.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when any of the parameters are <b>null</b>.</exception>
 public SettingsPlugInsListParameters(IEnumerable <ISettingsPlugInListItem> plugins, IViewModelInjection commonServices)
     : base(commonServices) => PlugIns = plugins ?? throw new ArgumentNullException(nameof(plugins));
コード例 #11
0
 /// <summary>Initializes a new instance of the <see cref="ImportPlugInSettingsParameters"/> class.</summary>
 /// <param name="settings">The plug in settings.</param>
 /// <param name="codecs">The codec registry.</param>
 /// <param name="openCodecDialog">The service used to locate plug in assemblies for loading.</param>
 /// <param name="pluginService">The content plug in service.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <strong>null</strong>.</exception>
 public ImportPlugInSettingsParameters(SpriteImportSettings settings, ICodecRegistry codecs, IFileDialogService openCodecDialog, IContentPlugInService pluginService, IViewModelInjection commonServices)
     : base(commonServices)
 {
     Settings             = settings ?? throw new ArgumentNullException(nameof(settings));
     Codecs               = codecs ?? throw new ArgumentNullException(nameof(settings));
     OpenCodecDialog      = openCodecDialog ?? throw new ArgumentNullException(nameof(openCodecDialog));
     ContentPlugInService = pluginService ?? throw new ArgumentNullException(nameof(pluginService));
 }
コード例 #12
0
ファイル: SettingsParameters.cs プロジェクト: ishkang/Gorgon
 /// <summary>Initializes a new instance of the ImageContentVmParameters class.</summary>
 /// <param name="settings">The settings for the image editor.</param>
 /// <param name="codecs">The codecs loaded into the system.</param>
 /// <param name="codecDialog">The file dialog used to locate codec assemblies.</param>
 /// <param name="pluginService">The service used to manage content and importer plug ins.</param>
 /// <param name="plugInCache">The cache for plug in assemblies.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when any of the parameters are <b>null</b>.</exception>
 public SettingsParameters(ImageEditorSettings settings, ICodecRegistry codecs, IFileDialogService codecDialog, IContentPlugInService pluginService, GorgonMefPlugInCache plugInCache, IViewModelInjection commonServices)
     : base(commonServices)
 {
     Settings        = settings ?? throw new ArgumentNullException(nameof(settings));
     Codecs          = codecs ?? throw new ArgumentNullException(nameof(codecs));
     CodecFileDialog = codecDialog ?? throw new ArgumentNullException(nameof(codecDialog));
     PlugInService   = pluginService ?? throw new ArgumentNullException(nameof(pluginService));
     PlugInCache     = plugInCache ?? throw new ArgumentNullException(nameof(plugInCache));
 }
コード例 #13
0
ファイル: SharedDataFactory.cs プロジェクト: ishkang/Gorgon
 /// <summary>
 /// Function to retrieve the shared data for the plug ins in this assembly.
 /// </summary>
 /// <param name="plugInService">The application plug in service.</param>
 /// <param name="commonServices">The common services for the application.</param>
 /// <returns>A tuple containing the shared codec registry and the settings view model.</returns>
 public static (ICodecRegistry codecRegisry, ISettings settingsViewModel) GetSharedData(IContentPlugInService plugInService, IViewModelInjection commonServices)
 {
     Interlocked.CompareExchange(ref _plugInService, new WeakReference <IContentPlugInService>(plugInService), null);
     Interlocked.CompareExchange(ref _commonServices, new WeakReference <IViewModelInjection>(commonServices), null);
     return(_codecRegistryFactory.Value, _settingsViewModelFactory.Value);
 }
コード例 #14
0
 /// <summary>Initializes a new instance of the <see cref="ManualInputParameters"/> class.</summary>
 /// <param name="settings">The settings for the sprite editor.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <b>null</b>.</exception>
 public ManualInputParameters(IEditorPlugInSettings settings, IViewModelInjection commonServices)
     : base(commonServices) => Settings = settings ?? throw new ArgumentNullException(nameof(settings));
コード例 #15
0
 /// <summary>Initializes a new instance of the <see cref="FileSystemProviders"/> class.</summary>
 /// <param name="commonServices">The common services for the application.</param>
 /// <exception cref="ArgumentNullException">Thrown when the <paramref name="commonServices"/> parameter is <b>null</b>.</exception>
 public FileSystemProviders(IViewModelInjection commonServices) => _commonServices = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
コード例 #16
0
 /// <summary>
 /// Function to assign the application common services to the plug in.
 /// </summary>
 /// <param name="commonServices">The common services to pass to the plug in.</param>
 public void AssignCommonServices(IViewModelInjection commonServices) => CommonServices = commonServices;
コード例 #17
0
        /// <summary>
        /// Function to perform the boot strapping operation.
        /// </summary>
        /// <returns>The main application window.</returns>
        public async void BootStrap()
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            try
            {
                // Get our initial context.
                SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

                Program.Log.Print("Booting application...", LoggingLevel.All);

                Cursor.Current = Cursors.WaitCursor;

                await ShowSplashAsync();

                // Initalize the common resources.
                EditorCommonResources.LoadResources();

                _folderBrowser   = new FileSystemFolderBrowseService();
                _commonServices  = new ViewModelInjection(Program.Log, new WaitCursorBusyState(), new MessageBoxService());
                _pluginCache     = new GorgonMefPlugInCache(Program.Log);
                _graphicsContext = GraphicsContext.Create(Program.Log);

                _plugInLocation = new DirectoryInfo(Path.Combine(GorgonApplication.StartupPath.FullName, "PlugIns"));

                if (!_plugInLocation.Exists)
                {
                    Program.Log.Print($"[ERROR] Plug in path '{_plugInLocation.FullName}' was not found.  No plug ins will be loaded.", LoggingLevel.Simple);
                    GorgonDialogs.ErrorBox(null, Resources.GOREDIT_ERR_LOADING_PLUGINS);
                }

                // Get any application settings we might have.
                _settings = LoadSettings();

                // Load our file system import/export plugins.
                FileSystemProviders fileSystemProviders = LoadFileSystemPlugIns();

                // Load our tool plug ins.
                _toolPlugIns = LoadToolPlugIns();

                // Load our content service plugins.
                _contentPlugIns = LoadContentPlugIns();

                // Create the project manager for the application
                _projectManager = new ProjectManager(fileSystemProviders);

                _mainForm = new FormMain
                {
                    Location    = new Point(_settings.WindowBounds.Value.X, _settings.WindowBounds.Value.Y),
                    Size        = new Size(_settings.WindowBounds.Value.Width, _settings.WindowBounds.Value.Height),
                    WindowState = FormWindowState.Normal
                };

                await HideSplashAsync();

                MainForm = _mainForm;

                var factory = new ViewModelFactory(_settings,
                                                   fileSystemProviders,
                                                   _contentPlugIns,
                                                   _toolPlugIns,
                                                   _projectManager,
                                                   _commonServices,
                                                   new ClipboardService(),
                                                   new DirectoryLocateService(),
                                                   new FileScanService(_contentPlugIns),
                                                   _folderBrowser);

                FormWindowState windowState;
                // Ensure the window state values fall into an acceptable range.
                if (!Enum.IsDefined(typeof(FormWindowState), _settings.WindowState))
                {
                    windowState = FormWindowState.Maximized;
                }
                else
                {
                    windowState = (FormWindowState)_settings.WindowState;
                }

                _mainForm.GraphicsContext = _graphicsContext;
                _mainForm.SetDataContext(factory.CreateMainViewModel(_graphicsContext.Graphics.VideoAdapter.Name));
                _mainForm.Show();
                _mainForm.WindowState = windowState;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
コード例 #18
0
 /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteWrappingEditorParameters"/> class.</summary>
 /// <param name="builder">The builder used to create samplers.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <b>null</b>.</exception>
 public SpriteWrappingEditorParameters(ISamplerBuildService builder, IViewModelInjection commonServices)
     : base(commonServices) => SamplerStateBuilder = builder ?? throw new ArgumentNullException(nameof(builder));
コード例 #19
0
 /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SettingsParameters"/> class.</summary>
 /// <param name="settings">The plug in settings.</param>
 /// <param name="commonServices">Common application services.</param>
 /// <exception cref="ArgumentNullException">Thrown when the <paramref name="settings" /> parameter is <strong>null</strong>.</exception>
 public SettingsParameters(SpriteEditorSettings settings, IViewModelInjection commonServices)
     : base(commonServices) => Settings = settings ?? throw new ArgumentNullException(nameof(settings));
コード例 #20
0
 /// <summary>Initializes a new instance of the ContentViewModelInjectionCommon class.</summary>
 /// <param name="file">The file that contains the content.</param>
 /// <param name="commonServices">The common services for the application.</param>
 /// <exception cref="ArgumentNullException">Thrown any of the parameters are <b>null</b></exception>
 public ContentViewModelInjectionCommon(IContentFile file, IViewModelInjection commonServices)
     : base(commonServices) => File = file ?? throw new ArgumentNullException(nameof(file));