/* * 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 { /// /// Represents a select box item on an XHTML form. /// public sealed class SelectBoxItem { private string key; private string text; private string icon; private bool selectable; internal bool selected; /// /// The select box item key. /// public string Key { get { return key; } set { key = value; } } /// /// The select box item caption. /// public string Text { get { return text; } set { text = value; } } /// /// The select box item icon. /// public string Icon { get { return icon; } set { icon = value; } } /// /// True if the select box item is selectable. /// public bool Selectable { get { return selectable; } set { selectable = value; } } /// /// Select box item constructor. /// /// Item key /// Item caption public SelectBoxItem(string key, string text) { this.key = key; this.text = text; selectable = true; } /// /// Select box item constructor. /// /// Item key /// Item caption /// Item icon public SelectBoxItem(string key, string text, string icon) { this.key = key; this.text = text; this.icon = icon; selectable = true; } /// /// Select box item constructor. /// /// Item key /// Item caption /// Item selectable public SelectBoxItem(string key, string text, bool selectable) { this.key = key; this.text = text; this.selectable = selectable; } /// /// Select box item constructor. /// /// Item key /// Item caption /// Item icon /// Item selectable public SelectBoxItem(string key, string text, string icon, bool selectable) { 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("", HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text)); } else if (selected) { return string.Format("", HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text)); } else if (!selectable) { return string.Format("", HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text)); } else { return string.Format("", HttpUtility.HtmlEncode(key), HttpUtility.HtmlEncode(text)); } } } }