176 lines
3.8 KiB
C#
176 lines
3.8 KiB
C#
using System;
|
|
using System.Web.UI;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class cmp_toggle : System.Web.UI.UserControl
|
|
{
|
|
#region Public Events
|
|
|
|
/// <summary>
|
|
/// Evento toggle
|
|
/// </summary>
|
|
public event EventHandler ehToggle;
|
|
|
|
#endregion Public Events
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Classe x toggle OFF
|
|
/// </summary>
|
|
public string classOff
|
|
{
|
|
get
|
|
{
|
|
return lbtToggleOff.CssClass;
|
|
}
|
|
set
|
|
{
|
|
lbtToggleOff.CssClass = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe x toggle ON
|
|
/// </summary>
|
|
public string classOn
|
|
{
|
|
get
|
|
{
|
|
return lbtToggleOn.CssClass;
|
|
}
|
|
set
|
|
{
|
|
lbtToggleOn.CssClass = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Messaggio toggle Off
|
|
/// </summary>
|
|
public string messageOff
|
|
{
|
|
get
|
|
{
|
|
return hfMessageOff.Value;
|
|
}
|
|
set
|
|
{
|
|
hfMessageOff.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Messaggio toggle ON
|
|
/// </summary>
|
|
public string messageOn
|
|
{
|
|
get
|
|
{
|
|
return hfMessageOn.Value;
|
|
}
|
|
set
|
|
{
|
|
hfMessageOn.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// valore toggle
|
|
/// </summary>
|
|
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());
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tooltip x toggle OFF
|
|
/// </summary>
|
|
public string tooltipOff
|
|
{
|
|
get
|
|
{
|
|
return lbtToggleOff.ToolTip;
|
|
}
|
|
set
|
|
{
|
|
lbtToggleOff.ToolTip = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tooltip x toggle ON
|
|
/// </summary>
|
|
public string tooltipOn
|
|
{
|
|
get
|
|
{
|
|
return lbtToggleOn.ToolTip;
|
|
}
|
|
set
|
|
{
|
|
lbtToggleOn.ToolTip = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// sistema visualizzazione
|
|
/// </summary>
|
|
private void fixDisplay()
|
|
{
|
|
// sistemo buttons & display...
|
|
bool doShow = toggleValue;
|
|
lbtToggleOn.Visible = doShow;
|
|
lbtToggleOff.Visible = !doShow;
|
|
lblMessage.Text = doShow ? messageOn : messageOff;
|
|
}
|
|
|
|
#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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// caricamento apgina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
fixDisplay();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |