📄 toolbardropdownlist.cs
字号:
using System;
using System.Drawing;
using FreeTextBoxControls.Common;
namespace FreeTextBoxControls
{
/// <summary>
/// A DropDownList for a Toolbar
/// </summary>
public class ToolbarDropDownList : ToolbarItem
{
public ToolbarDropDownList() {}
public ToolbarDropDownList(string title, string name, string function)
{
this.Title = title;
this.Name = name;
this.Function = function;
}
//ADD: Ethan J. Brown -- private state variables
private bool resetOnSelect = true;
private bool showTitle = true;
private bool showLabel = false;
private ToolbarListItem selectedItem = null;
/// <summary>
/// Collection of ToolbarListItems
/// </summary>
public ToolbarDropDownListItems Items = new ToolbarDropDownListItems();
//ADD: Ethan J. Brown
/// <summary>
/// A value indicating whether or not a drop-down remains on the last selected item
/// </summary>
public bool ResetOnSelect
{
get
{
return resetOnSelect;
}
set
{
resetOnSelect = value;
}
}
//ADD: Ethan J. Brown
/// <summary>
/// A value indicating whether or not a title shows as the first item in the drop-down
/// </summary>
public bool ShowTitle
{
get
{
return showTitle;
}
set
{
showTitle = value;
}
}
//ADD: Ethan J. Brown
/// <summary>
/// A value indicating whether or not a label shows for the drop-down
/// </summary>
public bool ShowLabel
{
get
{
return showLabel;
}
set
{
showLabel = value;
}
}
//ADD: Ethan J. Brown
/// <summary>
/// The ToolbarListItem that is currently selected
/// </summary>
public ToolbarListItem SelectedItem
{
get
{
return selectedItem;
}
set
{
bool found = false;
if (null != value)
{
for (int i = 0; i < Items.Count; ++i)
{
if (value == Items[i])
{
found = true;
}
}
if (!found) throw new ArgumentException("The current DropDownList does not contain that item.");
}
selectedItem = value;
}
}
}
/// <summary>
/// A DropDownList Item for a Toolbar
/// </summary>
public class ToolbarListItem
{
public ToolbarListItem() {}
public ToolbarListItem(string name, string theValue)
{
this.Name = name;
this.Value = theValue;
this.BackColor = new Color();
}
public ToolbarListItem(string name, string theValue, Color backColor)
{
this.Name = name;
this.Value = theValue;
this.BackColor = backColor;
}
private string name = "";
private string _value = "";
private Color backColor = new Color();
/// <summary>
/// The name displayed for the DropDown Item
/// </summary>
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
/// <summary>
/// The value of the DropDown item
/// </summary>
public string Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
/// <summary>
/// The backcolor of the DropDown item
/// </summary>
public Color BackColor
{
get
{
return backColor;
}
set
{
backColor = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -