Table of Contents

Class HiddenParameterEditor

Namespace
Dynamicweb.Extensibility.Editors
Assembly
Dynamicweb.Core.dll

Creates a hidden input control.

public class HiddenParameterEditor : ParameterEditor
Inheritance
HiddenParameterEditor
Inherited Members

Examples

using System;
using System.Collections.Generic;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;

namespace Dynamicweb.Examples.Extensibility;

/// <summary>
/// The example of an abstract addin with attributes and parameter editors
/// </summary>
[
    AddInActive(true),
    AddInName("Abstract add-in"),
    AddInLabel("Abstract add-in"),
    AddInDescription("Just an example of using attributes and parameter editors."),
    AddInImage("image.png"),
    AddInIcon(Core.UI.Icons.KnownIcon.ObjectGroup),
    AddInDeprecated(false),
    AddInAuthor("James Bond"),
    AddInGroup("Examples"),
    AddInTarget("Examples"),
    AddInOrder(0),
    AddInUseParameterOrdering(true),
    AddInUseParameterGrouping(true),
    AddInUseParameters(false)
]
public class AddInWithEditors : ConfigurableAddIn, IParameterOptions
{
    [AddInLabel("Color"), AddInParameter("ColorParameterEditor"), AddInParameterEditor(typeof(ColorParameterEditor), "")]
    public string ColorEditor { get; set; } = "";

    [AddInLabel("Date"), AddInParameter("DateEditor"), AddInParameterEditor(typeof(DateTimeParameterEditor), "hideName=true;AllowNeverExpire=true;AllowEmpty=true;show=date"), AddInParameterGroup("Source")]
    public DateTime DateEditor { get; set; }

    [AddInLabel("Decimal"), AddInParameter("DecimalEditor"), AddInParameterEditor(typeof(FloatingPointNumberParameterEditor), "minValue=0;maxValue=10;allowNegativeValues=false;localizeValues=true;inputClass=std;disabled=false")]
    public decimal DecimalEditor { get; set; }

    [AddInParameter("FileEditor"), AddInParameterEditor(typeof(FileManagerEditor), "usefilesfolder=true;allowBrowse=true;extensions=js;file=System/config/clean.js;showfullpath=true;Icon=fa fa-exclamation-triangle;Tooltip=Select a js file;")]
    public string FileEditor { get; set; } = "";

    [AddInParameter("FolderCustom"), AddInParameterEditor(typeof(FolderSelectEditor), "htmlClass=NewUIinput;")]
    public string FolderCustomEditor { get; set; } = "/MyCustomFolder";

    [AddInParameter("FolderImages"), AddInParameterEditor(typeof(FolderSelectEditor), "htmlClass=NewUIinput;useimagesfolder=true")]
    public string FolderImagesEditor { get; set; } = "";

    [AddInParameter("FolderFiles"), AddInParameterEditor(typeof(FolderSelectEditor), "htmlClass=NewUIinput;usefilesfolder=true")]
    public string FolderFilesEditor { get; set; } = "";

    [AddInParameter("Default font"), AddInParameterEditor(typeof(GoogleFontParameterEditor), "")]
    public Dynamicweb.Content.Items.Editors.GoogleFont? FontEditor { get; set; }

    [AddInParameter("DefaultFontName"), AddInParameterEditor(typeof(HiddenParameterEditor), "")]
    public string DefaultFontName
    {
        get { return FontEditor?.Family ?? ""; }
        set
        {
            if (FontEditor is not null)
                FontEditor.Family = value;
        }
    }

    [AddInParameter("DefaultFontWeight"), AddInParameterEditor(typeof(HiddenParameterEditor), "")]
    public string DefaultFontWeight
    {
        get { return FontEditor?.SelectedVariant ?? ""; }
        set
        {
            if (FontEditor is not null)
                FontEditor.SelectedVariant = value;
        }
    }

    [AddInParameter("IntegerEditor"), AddInParameterEditor(typeof(IntegerNumberParameterEditor), "inputClass=std editor-parameter;allowNegativeValues=false")]
    public int IntegerEditor { get; set; }

    [AddInParameter("NumberEditorInteger"), AddInParameterEditor(typeof(NumberParameterEditor), "inputClass=std editor-parameter;allowNegativeValues=false")]
    public int NumberEditorInteger { get; set; }

    [AddInParameter("NumberEditorDecimal"), AddInParameterEditor(typeof(NumberParameterEditor), "inputClass=std editor-parameter;allowNegativeValues=false;numberType=Decimal")]
    public int NumberEditorDecimal { get; set; }

    [AddInParameter("NumberEditorCurrency"), AddInParameterEditor(typeof(NumberParameterEditor), "inputClass=std editor-parameter;allowNegativeValues=false;numberType=Currency")]
    public int NumberEditorCurrency { get; set; }

    [AddInParameter("Item type"), AddInParameterEditor(typeof(ItemListParameterEditor), "inputClass=std; StructureType=All; AllowEditParameterOptions=False")]
    public string ItemType { get; set; } = "";

    [AddInParameter("Example of static link"), AddInParameterEditor(typeof(LabelParameterEditor), "")]
    public string LabelEditor { get; set; } = @"<a href=""http://doc.dynamicweb.com/forum"" target=""_blank"">Developer forum</a>";

    [AddInParameter("MoreLessEditor"), AddInParameterEditor(typeof(MoreLessParameterEditor), "")]
    public string MoreLessEditor { get; set; } = "";

    [AddInParameter("MultipleValuesEditor"), AddInParameterEditor(typeof(MultipleValuesEditor), "")]
    public string MultipleValuesEditor { get; set; } = "";

    [AddInParameter("Page"), AddInParameterEditor(typeof(PageSelectEditor), "")]
    public string Page { get; set; } = "";

    [AddInParameter("Show on paragraph"), AddInParameterEditor(typeof(ParagraphSelectEditor), "htmlClass=std")]
    public string ParagraphId { get; set; } = "";

    [AddInParameter("Period editor"), AddInParameterEditor(typeof(PeriodParameterEditor), "")]
    public string PeriodEditor { get; set; } = "";

    [AddInParameter("Template"), AddInParameterEditor(typeof(TemplateParameterEditor), "folder=templates/MyModule/Email/;FullPath=true;NewGUI=true")]
    public string Template { get; set; } = "";

    [AddInLabel("Text"), AddInParameter("Text"), AddInParameterOrder(0), AddInParameterEditor(typeof(TextParameterEditor), "")]
    public string Text { get; set; } = "";

    [AddInParameter("User group"), AddInParameterEditor(typeof(UserGroupParameterEditor), "multiple=false;")]
    public string UserGroup { get; set; } = "";

    [AddInParameter("User"), AddInParameterEditor(typeof(UserParameterEditor), "")]
    public string UserEditor { get; set; } = "";

    [AddInLabel("YesNo"), AddInParameter("YesNo"), AddInParameterEditor(typeof(YesNoParameterEditor), "")]
    public bool YesNoEditor { get; set; } = false;

    [AddInParameter("CheckList"), AddInParameterGroup("Parameters with options"), AddInParameterEditor(typeof(CheckListParameterEditor), "infoText=A little description for parameter")]
    public string CheckListEditor { get; set; } = "";

    [AddInParameter("DropDownEditor"), AddInParameterGroup("Parameters with options"), AddInParameterEditor(typeof(DropDownParameterEditor), "none=false;SortBy=Value;")]
    public string DropDownEditor { get; set; } = "";

    [AddInParameter("GroupedDropDown"), AddInParameterGroup("Parameters with options"), AddInParameterEditor(typeof(GroupedDropDownParameterEditor), "SortBy=Group,Key;none=false;")]
    public string GroupedDropDownEditor { get; set; } = "";

    [AddInParameter("RadioButtons"), AddInParameterGroup("Parameters with options"), AddInParameterEditor(typeof(RadioParameterEditor), "")]
    public string RadioEditor { get; set; } = "";

    /// <summary>
    /// Implementation of IParameterOptions interface
    /// </summary>
    public IEnumerable<ParameterOption> GetParameterOptions(string parameterName) => parameterName switch
    {
        "CheckList" or
        "DropDownEditor" or
        "RadioButtons" => [
            new("label 1", "value1"),
            new("label 2", "value2"),
            new("label 3", "value3"),
            new("label 4", "value4")
        ],

        "GroupedDropDown" => [
            new("Group1 -> Item1", new GroupedDropDownParameterEditor.DropDownItem("Item 1", "Group 1", "Group1_Item1")),
            new("Group1 -> Item2", new GroupedDropDownParameterEditor.DropDownItem("Item 2", "Group 1", "Group1_Item2")),
            new("Group2 -> Item1", new GroupedDropDownParameterEditor.DropDownItem("Item 1", "Group 2", "Group2_Item1")),
        ],

        _ => throw new ArgumentException($"Unknown dropdown name: '{parameterName}'")
    };
}
To top