Beispiel #1
0
 public void RemoveLayerBrush(LayerBrushRegistration registration)
 {
     if (registration == null)
     {
         throw new ArgumentNullException(nameof(registration));
     }
     LayerBrushStore.Remove(registration);
 }
Beispiel #2
0
        /// <summary>
        ///     Registers a layer brush descriptor for a given layer brush, so that it appears in the UI.
        ///     <para>Note: You do not need to manually remove these on disable</para>
        /// </summary>
        /// <typeparam name="T">The type of the layer brush you wish to register</typeparam>
        /// <param name="displayName">The name to display in the UI</param>
        /// <param name="description">The description to display in the UI</param>
        /// <param name="icon">
        ///     The Material icon to display in the UI, a full reference can be found
        ///     <see href="https://materialdesignicons.com">here</see>
        /// </param>
        protected void RegisterLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerBrush
        {
            if (!IsEnabled)
                throw new ArtemisPluginException(Plugin, "Can only add a layer brush descriptor when the plugin is enabled");

            LayerBrushDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
            _layerBrushDescriptors.Add(descriptor);
            LayerBrushStore.Add(descriptor);
        }
Beispiel #3
0
        public LayerBrushRegistration RegisterLayerBrush(LayerBrushDescriptor descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            return(LayerBrushStore.Add(descriptor));
        }
        public LayerBrushDescriptor GetDefaultLayerBrush()
        {
            PluginSetting <LayerBrushReference> defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
            {
                BrushPluginGuid = Guid.Parse("92a9d6ba-6f7a-4937-94d5-c1d715b4141a"),
                BrushType       = "ColorBrush"
            });

            return(LayerBrushStore.Get(defaultReference.Value.BrushPluginGuid, defaultReference.Value.BrushType)?.LayerBrushDescriptor);
        }
Beispiel #5
0
        public LayerBrushDescriptor?GetDefaultLayerBrush()
        {
            PluginSetting <LayerBrushReference> defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
            {
                LayerBrushProviderId = "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba",
                BrushType            = "SolidBrush"
            });

            defaultReference.Value.LayerBrushProviderId ??= "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba";
            defaultReference.Value.BrushType ??= "SolidBrush";
            return(LayerBrushStore.Get(defaultReference.Value.LayerBrushProviderId, defaultReference.Value.BrushType)?.LayerBrushDescriptor);
        }
Beispiel #6
0
        /// <summary>
        ///     Registers a layer brush descriptor for a given layer brush, so that it appears in the UI.
        ///     <para>Note: You do not need to manually remove these on disable</para>
        /// </summary>
        /// <typeparam name="T">The type of the layer brush you wish to register</typeparam>
        /// <param name="displayName">The name to display in the UI</param>
        /// <param name="description">The description to display in the UI</param>
        /// <param name="icon">
        ///     The Material icon to display in the UI, a full reference can be found
        ///     <see href="https://materialdesignicons.com">here</see>
        /// </param>
        protected void RegisterLayerBrushDescriptor <T>(string displayName, string description, string icon) where T : BaseLayerBrush
        {
            if (!IsEnabled)
            {
                throw new ArtemisPluginException(Plugin, "Can only add a layer brush descriptor when the plugin is enabled");
            }

            if (icon.ToLower().EndsWith(".svg"))
            {
                icon = Plugin.ResolveRelativePath(icon);
            }
            LayerBrushDescriptor descriptor = new(displayName, description, icon, typeof(T), this);

            _layerBrushDescriptors.Add(descriptor);
            LayerBrushStore.Add(descriptor);
        }
Beispiel #7
0
 public List <LayerBrushDescriptor> GetLayerBrushes()
 {
     return(LayerBrushStore.GetAll().Select(r => r.LayerBrushDescriptor).ToList());
 }