using Microsoft.AspNetCore.Components; namespace Egw.Core.Razor.Comp { public partial class Toggler { #region Public Properties [Parameter] public EventCallback FilterChanged { get; set; } [Parameter] public SelectGlobalToggle SelFilter { get; set; } = new SelectGlobalToggle(); #endregion Public Properties #region Protected Properties protected bool isActive { get => SelFilter.isActive; set { SelFilter.isActive = value; reportChange(); } } protected string leftString { get => SelFilter.leftString; set { if (SelFilter.leftString != value) { SelFilter.leftString = value; } } } protected string leftStringCSS { get => SelFilter.leftStringCSS; set { if (SelFilter.leftStringCSS != value) { SelFilter.leftStringCSS = value; reportChange(); } } } protected string placardCss { get => SelFilter.placardCss; set { if (SelFilter.placardCss != value) { SelFilter.placardCss = value; } } } protected string rightString { get => SelFilter.rightString; set { if (SelFilter.rightString != value) { SelFilter.rightString = value; reportChange(); } } } protected string rightStringCSS { get => SelFilter.rightStringCSS; set { if (SelFilter.rightStringCSS != value) { SelFilter.rightStringCSS = value; } } } protected string toolTip { get => SelFilter.toolTip; set { if (SelFilter.toolTip != value) { SelFilter.toolTip = value; } } } #endregion Protected Properties #region Protected Methods protected override async Task OnInitializedAsync() { if (isActive) { rightStringCSS = "fw-bold"; leftStringCSS = "text-secondary"; } else { leftStringCSS = "fw-bold"; rightStringCSS = "text-secondary"; } //await FilterChanged.InvokeAsync(SelFilter); } protected void toggle() { var currFilt = SelFilter; currFilt.isActive = !currFilt.isActive; SelFilter = currFilt; if (isActive) { rightStringCSS = "fw-bold"; leftStringCSS = "text-secondary"; } else { leftStringCSS = "fw-bold"; rightStringCSS = "text-secondary"; } } #endregion Protected Methods #region Private Methods private void reportChange() { FilterChanged.InvokeAsync(SelFilter); } #endregion Private Methods #region Public Classes /// /// Classe utility x toggle /// public class SelectGlobalToggle { #region Public Constructors public SelectGlobalToggle() { } #endregion Public Constructors #region Public Properties /// /// Bool: indica se il toggleClosed � attivo /// public bool isActive { get; set; } = true; /// /// string: stringa da mostrare a sinistra (disattivo onInitialize) /// public string leftString { get; set; } = ""; /// /// string: stile stringa da mostrare a sinistra (disattivo onInitialize) /// public string leftStringCSS { get; set; } = ""; /// /// CSS specifico x placard /// public string placardCss { get; set; } = ""; /// /// string: stringa da mostrare a destra (attivo onInitialize) /// public string rightString { get; set; } = ""; /// /// string: stile stringa da mostrare a destra (attivo onInitialize) /// public string rightStringCSS { get; set; } = ""; /// /// Parametro da mostrare in tooltip /// public string toolTip { get; set; } = ""; #endregion Public Properties #region Public Methods public override bool Equals(object obj) { if (!(obj is SelectGlobalToggle item)) return false; if (isActive != item.isActive) return false; if (leftString != item.leftString) return false; if (rightString != item.rightString) return false; if (leftStringCSS != item.leftStringCSS) return false; if (rightStringCSS != item.rightStringCSS) return false; if (toolTip != item.toolTip) return false; if (placardCss != item.placardCss) return false; return true; } public override int GetHashCode() { return base.GetHashCode(); } #endregion Public Methods } #endregion Public Classes } }