📄 toolbaritem.cs
字号:
//------------------------------------------------------------------------------
// Copyright (c) 2000-2003 Microsoft Corporation. All Rights Reserved.
//------------------------------------------------------------------------------
namespace Microsoft.Web.UI.WebControls
{
using System;
using System.Web.UI;
using System.ComponentModel;
/// <summary>
/// Base class for Toolbar child nodes.
/// </summary>
[ToolboxItem(false)]
public abstract class ToolbarItem : BaseChildNode
{
private Toolbar _Parent;
private CssCollection _DefaultStyle;
/// <summary>
/// Initializes a new instance of a ToolbarItem.
/// </summary>
public ToolbarItem() : base()
{
_DefaultStyle = new CssCollection();
}
/// <summary>
/// Returns a String that represents the current Object.
/// </summary>
/// <returns>A String that represents the current Object.</returns>
public override string ToString()
{
string name = this.GetType().Name;
if (ID != String.Empty)
{
name += " - " + ID;
}
return name;
}
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>A new object that is a copy of this instance.</returns>
public override object Clone()
{
ToolbarItem copy = (ToolbarItem)base.Clone();
copy._DefaultStyle = (CssCollection)this._DefaultStyle.Clone();
return copy;
}
/// <summary>
/// The Toolbar control that contains this item.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual Toolbar ParentToolbar
{
get { return _Parent; }
}
/// <summary>
/// Returns the parent object.
/// </summary>
public override object Parent
{
get { return ParentToolbar; }
}
/// <summary>
/// Sets the parent of this item.
/// </summary>
/// <param name="parent">The parent Toolbar.</param>
internal void SetParentToolbar(Toolbar parent)
{
_Parent = parent;
}
/// <summary>
/// Sets all items within the StateBag to be dirty
/// </summary>
protected internal override void SetViewStateDirty()
{
base.SetViewStateDirty();
DefaultStyle.Dirty = true;
}
/// <summary>
/// Sets all items within the StateBag to be clean
/// </summary>
protected internal override void SetViewStateClean()
{
base.SetViewStateClean();
DefaultStyle.Dirty = false;
}
/// <summary>
/// Gets or sets the keyboard shortcut key (AccessKey) for setting focus to the item.
/// </summary>
[DefaultValue("")]
[Category("Behavior")]
[ResDescription("BaseAccessKey")]
public virtual string AccessKey
{
get
{
object obj = ViewState["AccessKey"];
return (obj == null) ? String.Empty : (string)obj;
}
set { ViewState["AccessKey"] = value; }
}
/// <summary>
/// Gets or sets a value indicating whether the item is enabled.
/// </summary>
[DefaultValue(true)]
[Category("Behavior")]
[ResDescription("BaseEnabled")]
public virtual bool Enabled
{
get
{
object obj = ViewState["Enabled"];
return (obj == null) ? true : (bool)obj;
}
set { ViewState["Enabled"] = value; }
}
/// <summary>
/// Gets or sets the tab index of the item.
/// </summary>
[DefaultValue((short)0)]
[Category("Behavior")]
[ResDescription("BaseTabIndex")]
public virtual short TabIndex
{
get
{
object obj = ViewState["TabIndex"];
return (obj == null) ? (short)0 : (short)obj;
}
set { ViewState["TabIndex"] = value; }
}
/// <summary>
/// Gets or sets the tool tip for the item to be displayed when the mouse cursor is over the control.
/// </summary>
[DefaultValue("")]
[Category("Appearance")]
[ResDescription("BaseToolTip")]
public virtual string ToolTip
{
get
{
object obj = ViewState["ToolTip"];
return (obj == null) ? String.Empty : (string)obj;
}
set { ViewState["ToolTip"] = value; }
}
/// <summary>
/// Retrieves the orientation from the ParentToolbar.
/// </summary>
protected Orientation Orientation
{
get { return (ParentToolbar == null) ? Orientation.Horizontal : ParentToolbar.Orientation; }
}
/// <summary>
/// The style of the ToolbarItem when in the default state.
/// </summary>
[
Category("Styles"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("ChildDefaultStyle"),
]
public CssCollection DefaultStyle
{
get { return _DefaultStyle; }
set
{
_DefaultStyle = value;
if (((IStateManager)this).IsTrackingViewState)
{
((IStateManager)_DefaultStyle).TrackViewState();
_DefaultStyle.Dirty = true;
}
}
}
/// <summary>
/// The product of merging local and global styles.
/// </summary>
protected virtual CssCollection CurrentStyle
{
get
{
CssCollection style = new CssCollection();
// Built-in style
style.Add("padding", "2px");
style.Add("border-style", "solid");
style.Add("border-color", "#D0D0D0");
style.Add("border-width", "1px");
// Global style
if (ParentToolbar != null)
{
style.Merge(ParentToolbar.DefaultStyle, true);
}
// Local style
style.Merge(DefaultStyle, true);
return style;
}
}
/// <summary>
/// The index of the the toolbar item within the parent toolbar.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual int Index
{
get { return (ParentToolbar == null) ? -1 : ParentToolbar.Items.IndexOf(this); }
}
/// <summary>
/// The flat index of the toolbar item.
/// </summary>
protected virtual int ClientIndex
{
get { return (ParentToolbar == null) ? -1 : ParentToolbar.Items.FlatIndexOf(this); }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -