Example #1
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));
 }
Example #2
0
        /// <summary>
        /// Function to show the tool form.
        /// </summary>
        private void ShowForm()
        {
            TextureAtlasSettings settings;
            FormAtlasGen         form = null;

            CommonServices.BusyService.SetBusy();

            try
            {
                settings = ToolPlugInService.ReadContentSettings <TextureAtlasSettings>(typeof(TextureAtlasToolPlugIn).FullName);

                if (settings == null)
                {
                    settings = new TextureAtlasSettings();
                }

                (List <IContentFileExplorerSearchEntry> searchEntries, List <ContentFileExplorerDirectoryEntry> entries) = GetFileEntries();

                if (_fileVm == null)
                {
                    _fileVm = new SpriteFiles();
                }

                if (_textureAtlas == null)
                {
                    _textureAtlas = new TextureAtlas();
                }

                var fileIO = new FileIOService(_fileManager, _defaultImageCodec, _defaultSpriteCodec);

                _fileVm.Initialize(new SpriteFilesParameters(entries, new EditorContentSearchService(searchEntries), CommonServices));
                _textureAtlas.Initialize(new TextureAtlasParameters(settings,
                                                                    _fileVm,
                                                                    new GorgonTextureAtlasService(GraphicsContext.Renderer2D),
                                                                    fileIO,
                                                                    FolderBrowser,
                                                                    CommonServices));

                form = new FormAtlasGen();
                form.SetupGraphics(GraphicsContext);
                form.SetDataContext(_textureAtlas);

                CommonServices.BusyService.SetIdle();
                form.ShowDialog(GorgonApplication.MainForm);

                ToolPlugInService.WriteContentSettings(typeof(TextureAtlasToolPlugIn).FullName, settings);
            }
            catch (Exception ex)
            {
                CommonServices.MessageDisplay.ShowError(ex, Resources.GORTAG_ERR_LAUNCH);
            }
            finally
            {
                CommonServices.BusyService.SetIdle();
                form?.Dispose();
            }
        }