tabitem.cs
来自「浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果」· CS 代码 · 共 811 行 · 第 1/2 页
CS
811 行
//------------------------------------------------------------------------------
// Copyright (c) 2000-2003 Microsoft Corporation. All Rights Reserved.
//------------------------------------------------------------------------------
namespace Microsoft.Web.UI.WebControls
{
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Drawing.Design;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
/// <summary>
/// Base class for child nodes of a TabStrip.
/// </summary>
[ToolboxItem(false)]
public abstract class TabItem : BaseChildNode
{
private TabStrip _Parent;
private CssCollection _DefaultStyle;
private CssCollection _HoverStyle;
private CssCollection _SelectedStyle;
/// <summary>
/// Initializes a new instance of a TabItem.
/// </summary>
public TabItem() : base()
{
_DefaultStyle = new CssCollection();
_HoverStyle = new CssCollection();
_SelectedStyle = 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()
{
TabItem copy = (TabItem)base.Clone();
copy._DefaultStyle = (CssCollection)this._DefaultStyle.Clone();
copy._HoverStyle = (CssCollection)this._HoverStyle.Clone();
copy._SelectedStyle = (CssCollection)this._SelectedStyle.Clone();
return copy;
}
/// <summary>
/// The TabStrip control that contains this item.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TabStrip ParentTabStrip
{
get { return _Parent; }
}
/// <summary>
/// Returns the parent object.
/// </summary>
public override object Parent
{
get { return ParentTabStrip; }
}
/// <summary>
/// Sets the parent of this item.
/// </summary>
/// <param name="parent">The parent TabStrip.</param>
internal void SetParentTabStrip(TabStrip parent)
{
_Parent = parent;
}
/// <summary>
/// Sets all items within the StateBag to be dirty
/// </summary>
protected internal override void SetViewStateDirty()
{
base.SetViewStateDirty();
DefaultStyle.Dirty = true;
HoverStyle.Dirty = true;
SelectedStyle.Dirty = true;
}
/// <summary>
/// Sets all items within the StateBag to be clean
/// </summary>
protected internal override void SetViewStateClean()
{
base.SetViewStateClean();
DefaultStyle.Dirty = false;
HoverStyle.Dirty = false;
SelectedStyle.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 ParentTabStrip.
/// </summary>
protected Orientation Orientation
{
get { return (ParentTabStrip == null) ? Orientation.Horizontal : ParentTabStrip.Orientation; }
}
/// <summary>
/// The text string that will appear within a tab item.
/// </summary>
[
Category("Appearance"),
DefaultValue(""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("ItemText"),
]
public string Text
{
get
{
string szText = (string)ViewState["Text"];
return (szText == null) ? String.Empty : szText;
}
set
{
ViewState["Text"] = value;
}
}
/// <summary>
/// Url of the image to display within the tab item.
/// </summary>
[
Category("Appearance"),
DefaultValue(""),
Editor(typeof(Microsoft.Web.UI.WebControls.Design.ObjectImageUrlEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("DefaultImageUrl"),
]
public string DefaultImageUrl
{
get
{
Object obj = ViewState["DefaultImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set
{
ViewState["DefaultImageUrl"] = value;
}
}
/// <summary>
/// Url of the image to display within the tab item when in a hover state.
/// </summary>
[
Category("Appearance"),
DefaultValue(""),
Editor(typeof(Microsoft.Web.UI.WebControls.Design.ObjectImageUrlEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("HoverImageUrl"),
]
public string HoverImageUrl
{
get
{
Object obj = ViewState["HoverImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set
{
ViewState["HoverImageUrl"] = value;
}
}
/// <summary>
/// Url of the image to display within the tab item when in a selected state.
/// </summary>
[
Category("Appearance"),
DefaultValue(""),
Editor(typeof(Microsoft.Web.UI.WebControls.Design.ObjectImageUrlEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SelectedImageUrl"),
]
public string SelectedImageUrl
{
get
{
Object obj = ViewState["SelectedImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set
{
ViewState["SelectedImageUrl"] = value;
}
}
/// <summary>
/// The style of the tab item.
/// </summary>
[
Category("Appearance"),
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 style of the tab item when in a hover state.
/// </summary>
[
Category("Appearance"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("ChildHoverStyle"),
]
public CssCollection HoverStyle
{
get { return _HoverStyle; }
set
{
_HoverStyle = value;
if (((IStateManager)this).IsTrackingViewState)
{
((IStateManager)_HoverStyle).TrackViewState();
_HoverStyle.Dirty = true;
}
}
}
/// <summary>
/// The style of the tab item when in a selected state.
/// </summary>
[
Category("Appearance"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("ChildSelectedStyle"),
]
public CssCollection SelectedStyle
{
get { return _SelectedStyle; }
set
{
_SelectedStyle = value;
if (((IStateManager)this).IsTrackingViewState)
{
((IStateManager)_SelectedStyle).TrackViewState();
_SelectedStyle.Dirty = true;
}
}
}
/// <summary>
/// The product of merging local and global image urls.
/// </summary>
protected virtual string CurrentImageUrl
{
get
{
TabStrip parent = ParentTabStrip;
bool isSep = this is TabSeparator;
if (Active && (SelectedImageUrl != String.Empty))
{
return SelectedImageUrl;
}
else if (Active && isSep && (parent != null) && (parent.SepSelectedImageUrl != String.Empty))
{
return parent.SepSelectedImageUrl;
}
else if (DefaultImageUrl != String.Empty)
{
return DefaultImageUrl;
}
else if (isSep && (parent != null) && (parent.SepDefaultImageUrl != String.Empty))
{
return parent.SepDefaultImageUrl;
}
return String.Empty;
}
}
/// <summary>
/// The product of merging local and global styles.
/// </summary>
protected CssCollection CurrentStyle
{
get
{
CssCollection style = new CssCollection();
bool isTab = (this is Tab);
bool isSep = !isTab && (this is TabSeparator);
CssCollection globalDefault = null, globalSelected = null,
builtinDefault = null, builtinSelected = null;
TabStrip parent = ParentTabStrip;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?