/// <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));
 }
Пример #2
0
        /// <summary>
        /// Function to perform any required initialization for the plugin.
        /// </summary>
        /// <param name="pluginService">The plugin service used to access other plugins.</param>
        /// <param name="graphicsContext">The graphics context for the application.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="pluginService"/>, or the <paramref name="graphicsContext"/> parameter is <b>null</b>.</exception>
        /// <remarks>
        /// <para>
        /// This method is only called when the plugin is loaded at startup.
        /// </para>
        /// </remarks>
        public void Initialize(IContentPlugInService pluginService, IGraphicsContext graphicsContext)
        {
            if (Interlocked.Exchange(ref _initialized, 1) == 1)
            {
                return;
            }

            CommonServices.Log.Print($"Initializing {Name}...", LoggingLevel.Simple);

            ContentPlugInService = pluginService ?? throw new ArgumentNullException(nameof(pluginService));
            GraphicsContext      = graphicsContext ?? throw new ArgumentNullException(nameof(graphicsContext));

            OnInitialize();
        }
Пример #3
0
        /// <summary>Function to inject dependencies for the view model.</summary>
        /// <param name="injectionParameters">The parameters to inject.</param>
        /// <remarks>
        /// Applications should call this when setting up the view model for complex operations and/or dependency injection. The constructor should only be used for simple set up and initialization of objects.
        /// </remarks>
        protected override void OnInitialize(ImportPlugInSettingsParameters injectionParameters)
        {
            _messageDisplay  = injectionParameters.MessageDisplay ?? throw new ArgumentMissingException(nameof(injectionParameters.MessageDisplay), nameof(injectionParameters));
            _settings        = injectionParameters.Settings ?? throw new ArgumentMissingException(nameof(injectionParameters.Settings), nameof(injectionParameters));
            _plugInService   = injectionParameters.ContentPlugInService ?? throw new ArgumentMissingException(nameof(injectionParameters.ContentPlugInService), nameof(injectionParameters));
            _codecs          = injectionParameters.Codecs ?? throw new ArgumentMissingException(nameof(injectionParameters.Codecs), nameof(injectionParameters));
            _openCodecDialog = injectionParameters.OpenCodecDialog ?? throw new ArgumentMissingException(nameof(injectionParameters.OpenCodecDialog), nameof(injectionParameters));
            _busyService     = injectionParameters.BusyService ?? throw new ArgumentMissingException(nameof(injectionParameters.BusyService), nameof(injectionParameters));

            foreach (GorgonSpriteCodecPlugIn plugin in _codecs.CodecPlugIns)
            {
                foreach (GorgonSpriteCodecDescription desc in plugin.Codecs)
                {
                    IGorgonSpriteCodec codec = _codecs.Codecs.FirstOrDefault(item => string.Equals(item.GetType().FullName, desc.Name, StringComparison.OrdinalIgnoreCase));

                    if (codec == null)
                    {
                        continue;
                    }

                    CodecPlugInPaths.Add(new CodecSetting(codec.CodecDescription, plugin, desc));
                }
            }
        }
Пример #4
0
 /// <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));
 }
Пример #5
0
 /// <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);
 }