using Pilz.UI.Telerik.Dialogs;
using Pilz.UI.Telerik.Extensions;
using Telerik.WinControls;

namespace Pilz.Plugins.Advanced.UI.Telerik;

public abstract class RadPluginModule : PluginModule<RadPluginModuleUI>
{
    /// <summary>
    /// Wrapper for the <see cref="PluginFeature.Icon"/> property to directly use it as <see cref="RadSvgImage"/>.
    /// </summary>
    public RadSvgImage? SvgImage
    {
        get => base.Icon as RadSvgImage;
        set => base.Icon = value;
    }

    protected RadPluginModule(string type, string identifier) : base(type, identifier)
    {

    }

    protected RadPluginModule(string type, string identifier, string? name) : base(type, identifier, name)
    {
    }

    public override void ShowUI(PluginFunctionParameter? @params)
    {
        if (CreateNewUI(@params) is RadPluginModuleUI ui)
        {
            ui.BackColor = Color.Transparent;
            RadDialogBase.Show(ui, Name!, SvgImage!.ToImage().ToIcon()!);
        }
    }
}