📄 tabstrip.cs
字号:
//------------------------------------------------------------------------------
// 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.Drawing;
using System.Drawing.Design;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
/// <summary>
/// Specifies the orientation that a control can be in.
/// </summary>
public enum Orientation
{
/// <summary>
/// Indicates a horizontal orientation.
/// </summary>
Horizontal,
/// <summary>
/// Indicates a vertical orientation.
/// </summary>
Vertical
};
/// <summary>
/// Represents a control that contains a row of tabs and separators.
/// </summary>
[
ParseChildren(true, "Items"),
DefaultEvent("SelectedIndexChange"),
Designer(typeof(Microsoft.Web.UI.WebControls.Design.TabStripDesigner)),
ToolboxBitmap(typeof(Microsoft.Web.UI.WebControls.TabStrip)),
ToolboxData(@"<{0}:TabStrip runat=""server""
TabDefaultStyle=""background-color:#000000;font-family:verdana;font-weight:bold;font-size:8pt;color:#ffffff;width:79;height:21;text-align:center""
TabHoverStyle=""background-color:#777777""
TabSelectedStyle=""background-color:#ffffff;color:#000000"">
<{0}:Tab Text=""Tab 1"" />
<{0}:Tab Text=""Tab 2"" />
<{0}:Tab Text=""Tab 3"" />
</{0}:TabStrip>"),
]
public class TabStrip : BasePostBackControl
{
/// <summary>
/// The namespace for the TabStrip and its children.
/// </summary>
public const string TagNamespace = "TSNS";
/// <summary>
/// The TabStrip's tag name.
/// </summary>
public const string TabStripTagName = "TabStrip";
/// <summary>
/// The Tab's tag name.
/// </summary>
public const string TabTagName = "Tab";
/// <summary>
/// The TabSeparator's tag name.
/// </summary>
public const string TabSeparatorTagName = "TabSeparator";
/// <summary>
/// Event fired when the SelectedIndex property changes.
/// </summary>
[ResDescription("TabStripSelectedIndexChange")]
public event EventHandler SelectedIndexChange;
private TabItemCollection _Items;
private int _CachedSelectedIndex;
private int _OldMultiPageIndex;
private CssCollection _TabDefaultStyle;
private CssCollection _TabHoverStyle;
private CssCollection _TabSelectedStyle;
private CssCollection _SepDefaultStyle;
private CssCollection _SepHoverStyle;
private CssCollection _SepSelectedStyle;
// Constant to indicate that there is no selection
private const int NoSelection = -1;
// Constant to indicate that the value is not set
private const int NotSet = -2;
/// <summary>
/// Initializes a new instance of a TabStrip.
/// </summary>
public TabStrip() : base()
{
_Items = new TabItemCollection(this);
_CachedSelectedIndex = NotSet;
_OldMultiPageIndex = -1;
_TabDefaultStyle = new CssCollection();
_TabHoverStyle = new CssCollection();
_TabSelectedStyle = new CssCollection();
_SepDefaultStyle = new CssCollection();
_SepHoverStyle = new CssCollection();
_SepSelectedStyle = new CssCollection();
}
/// <summary>
/// Gets the collection of items in the control.
/// </summary>
[
Category("Data"),
DefaultValue(null),
MergableProperty(false),
PersistenceMode(PersistenceMode.InnerDefaultProperty),
ResDescription("TabStripItems"),
]
public virtual TabItemCollection Items
{
get { return _Items; }
}
/// <summary>
/// The ID of the MultiPage whose pages will change when the SelectedIndex changes.
/// </summary>
[
Category("Behavior"),
DefaultValue(""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("TabStripTargetID"),
]
public string TargetID
{
get
{
object obj = ViewState["TargetID"];
return (obj == null) ? String.Empty : (string)obj;
}
set { ViewState["TargetID"] = value; }
}
/// <summary>
/// The target MultiPage whose pages will change when the SelectedIndex changes.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public MultiPage Target
{
get
{
string id = TargetID;
if (id == String.Empty)
{
return null;
}
Control ctrl = null;
Control container = NamingContainer;
Control page = Page;
if (container != null)
{
ctrl = container.FindControl(id);
}
if ((ctrl == null) && (page != null))
{
ctrl = page.FindControl(id);
}
if ((ctrl != null) && (ctrl is MultiPage))
{
return (MultiPage)ctrl;
}
return null;
}
}
/// <summary>
/// The default image url for separators.
/// </summary>
[
Category("Separator Defaults"),
DefaultValue(""),
Editor(typeof(System.Web.UI.Design.ImageUrlEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SepDefaultImageUrl"),
]
public string SepDefaultImageUrl
{
get
{
Object obj = ViewState["SepDefaultImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set { ViewState["SepDefaultImageUrl"] = value; }
}
/// <summary>
/// The default image url for separators when they are next to
/// a hovered tab but not next to a selected tab.
/// </summary>
[
Category("Separator Defaults"),
DefaultValue(""),
Editor(typeof(System.Web.UI.Design.ImageUrlEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SepHoverImageUrl"),
]
public string SepHoverImageUrl
{
get
{
Object obj = ViewState["SepHoverImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set { ViewState["SepHoverImageUrl"] = value; }
}
/// <summary>
/// The default image url for separators when they are next to a selected tab.
/// </summary>
[
Category("Separator Defaults"),
DefaultValue(""),
Editor(typeof(System.Web.UI.Design.ImageUrlEditor), typeof(UITypeEditor)),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SepSelectedImageUrl"),
]
public string SepSelectedImageUrl
{
get
{
Object obj = ViewState["SepSelectedImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set { ViewState["SepSelectedImageUrl"] = value; }
}
/// <summary>
/// The default style for tabs.
/// </summary>
[
Category("Tab Defaults"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("TabDefaultStyle"),
]
public CssCollection TabDefaultStyle
{
get { return _TabDefaultStyle; }
set
{
_TabDefaultStyle = value;
if (IsTrackingViewState)
{
((IStateManager)_TabDefaultStyle).TrackViewState();
_TabDefaultStyle.Dirty = true;
}
}
}
/// <summary>
/// The default style for tabs when they are hovered.
/// </summary>
[
Category("Tab Defaults"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("TabHoverStyle"),
]
public CssCollection TabHoverStyle
{
get { return _TabHoverStyle; }
set
{
_TabHoverStyle = value;
if (IsTrackingViewState)
{
((IStateManager)_TabHoverStyle).TrackViewState();
_TabHoverStyle.Dirty = true;
}
}
}
/// <summary>
/// The default style for tabs when they are selected.
/// </summary>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -