/*
* Box Social™
* http://boxsocial.net/
* Copyright © 2007, David Lachlan Smith
*
* $Id:$
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace BoxSocial.Forms
{
public class RadioListItem : FormField
{
private new string name;
private string key;
private string text;
private string icon;
private bool selectable;
internal bool selected;
///
/// The radio button name.
///
public new string Name
{
get
{
return name;
}
set
{
name = value;
}
}
///
/// The radio button key.
///
public string Key
{
get
{
return key;
}
set
{
key = value;
}
}
///
/// The radio button caption.
///
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
///
/// The radio button icon.
///
public string Icon
{
get
{
return icon;
}
set
{
icon = value;
}
}
///
/// True if the radio button is selectable.
///
public bool Selectable
{
get
{
return selectable;
}
set
{
selectable = value;
}
}
///
/// Radio button constructor.
///
/// Item key
/// Item caption
public RadioListItem(string name, string key, string text)
{
this.name = name;
this.key = key;
this.text = text;
selectable = true;
}
///
/// Select box item constructor.
///
/// Item key
/// Item caption
/// Item icon
public RadioListItem(string name, string key, string text, string icon)
{
this.name = name;
this.key = key;
this.text = text;
this.icon = icon;
selectable = true;
}
///
/// Select box item constructor.
///
/// Item key
/// Item caption
/// Item selectable
public RadioListItem(string name, string key, string text, bool selectable)
{
this.name = name;
this.key = key;
this.text = text;
this.selectable = selectable;
}
///
/// Select box item constructor.
///
/// Item key
/// Item caption
/// Item icon
/// Item selectable
public RadioListItem(string name, string key, string text, string icon, bool selectable)
{
this.name = name;
this.key = key;
this.text = text;
this.icon = icon;
this.selectable = selectable;
}
///
/// Creates a string representing the XHTML syntax for the item.
///
/// Returns XHTML
public override string ToString()
{
if (selected && (!selectable))
{
return string.Format(" {2}",
HttpUtility.HtmlEncode(name), HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text));
}
else if (selected)
{
return string.Format(" {2}",
HttpUtility.HtmlEncode(name), HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text));
}
else if (!selectable)
{
return string.Format(" {2}",
HttpUtility.HtmlEncode(name), HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text));
}
else
{
return string.Format(" {2}",
HttpUtility.HtmlEncode(name), HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text));
}
}
}
}