From ca1939a6bb64ec916d89ac32f36c2b4ce753c453 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 7 Jan 2021 11:29:34 +0100 Subject: [PATCH] Aggiunto comp toggle --- GPW_Admin/WebUserControls/cmp_toggle.ascx | 4 + GPW_Admin/WebUserControls/cmp_toggle.ascx.cs | 149 ++++++++++++++++++ .../cmp_toggle.ascx.designer.cs | 44 ++++++ 3 files changed, 197 insertions(+) create mode 100644 GPW_Admin/WebUserControls/cmp_toggle.ascx create mode 100644 GPW_Admin/WebUserControls/cmp_toggle.ascx.cs create mode 100644 GPW_Admin/WebUserControls/cmp_toggle.ascx.designer.cs diff --git a/GPW_Admin/WebUserControls/cmp_toggle.ascx b/GPW_Admin/WebUserControls/cmp_toggle.ascx new file mode 100644 index 0000000..4541773 --- /dev/null +++ b/GPW_Admin/WebUserControls/cmp_toggle.ascx @@ -0,0 +1,4 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_toggle.ascx.cs" Inherits="GPW_Admin.WebUserControls.cmp_toggle" %> + + + \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/cmp_toggle.ascx.cs b/GPW_Admin/WebUserControls/cmp_toggle.ascx.cs new file mode 100644 index 0000000..63e4ac9 --- /dev/null +++ b/GPW_Admin/WebUserControls/cmp_toggle.ascx.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace GPW_Admin.WebUserControls +{ + public partial class cmp_toggle : System.Web.UI.UserControl + { + #region Public Events + + /// + /// Evento toggle + /// + public event EventHandler ehToggle; + + #endregion Public Events + + #region Public Properties + + /// + /// Classe x toggle OFF + /// + public string classOff + { + get + { + return lbtToggleOff.CssClass; + } + set + { + lbtToggleOff.CssClass = value; + } + } + + /// + /// Classe x toggle ON + /// + public string classOn + { + get + { + return lbtToggleOn.CssClass; + } + set + { + lbtToggleOn.CssClass = value; + } + } + + /// + /// valore toggle + /// + public bool toggleValue + { + get + { + bool answ = false; + bool.TryParse(hfValue.Value, out answ); + return answ; + } + set + { + hfValue.Value = value.ToString(); + fixDisplay(); + if (ehToggle != null) + { + ehToggle(this, new EventArgs()); + } + } + } + + /// + /// Tooltip x toggle OFF + /// + public string tooltipOff + { + get + { + return lbtToggleOff.ToolTip; + } + set + { + lbtToggleOff.ToolTip = value; + } + } + + /// + /// Tooltip x toggle ON + /// + public string tooltipOn + { + get + { + return lbtToggleOn.ToolTip; + } + set + { + lbtToggleOn.ToolTip = value; + } + } + + #endregion Public Properties + + #region Private Methods + + /// + /// sistema visualizzazione + /// + private void fixDisplay() + { + // sistemo buttons & display... + bool doShow = toggleValue; + lbtToggleOn.Visible = doShow; + lbtToggleOff.Visible = !doShow; + } + + #endregion Private Methods + + #region Protected Methods + + protected void lbtToggleOff_Click(object sender, EventArgs e) + { + toggleValue = !toggleValue; + } + + protected void lbtToggleOn_Click(object sender, EventArgs e) + { + toggleValue = !toggleValue; + } + + /// + /// caricamento apgina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + fixDisplay(); + } + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/cmp_toggle.ascx.designer.cs b/GPW_Admin/WebUserControls/cmp_toggle.ascx.designer.cs new file mode 100644 index 0000000..c79b40f --- /dev/null +++ b/GPW_Admin/WebUserControls/cmp_toggle.ascx.designer.cs @@ -0,0 +1,44 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace GPW_Admin.WebUserControls +{ + + + public partial class cmp_toggle + { + + /// + /// Controllo hfValue. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.HiddenField hfValue; + + /// + /// Controllo lbtToggleOn. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtToggleOn; + + /// + /// Controllo lbtToggleOff. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtToggleOff; + } +}