📄 tabstrip.cs
字号:
[
Category("Tab Defaults"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("TabSelectedStyle"),
]
public CssCollection TabSelectedStyle
{
get { return _TabSelectedStyle; }
set
{
_TabSelectedStyle = value;
if (IsTrackingViewState)
{
((IStateManager)_TabSelectedStyle).TrackViewState();
_TabSelectedStyle.Dirty = true;
}
}
}
/// <summary>
/// The default style for separators.
/// </summary>
[
Category("Separator Defaults"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SepDefaultStyle"),
]
public CssCollection SepDefaultStyle
{
get { return _SepDefaultStyle; }
set
{
_SepDefaultStyle = value;
if (IsTrackingViewState)
{
((IStateManager)_SepDefaultStyle).TrackViewState();
_SepDefaultStyle.Dirty = true;
}
}
}
/// <summary>
/// The default style for separators when they are next
/// to a hovered tab but not next to a selected tab.
/// </summary>
[
Category("Separator Defaults"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SepHoverStyle"),
]
public CssCollection SepHoverStyle
{
get { return _SepHoverStyle; }
set
{
_SepHoverStyle = value;
if (IsTrackingViewState)
{
((IStateManager)_SepHoverStyle).TrackViewState();
_SepHoverStyle.Dirty = true;
}
}
}
/// <summary>
/// The default style for separators when they are next to a selected tab.
/// </summary>
[
Category("Separator Defaults"),
DefaultValue(typeof(CssCollection), ""),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("SepSelectedStyle"),
]
public CssCollection SepSelectedStyle
{
get { return _SepSelectedStyle; }
set
{
_SepSelectedStyle = value;
if (IsTrackingViewState)
{
((IStateManager)_SepSelectedStyle).TrackViewState();
_SepSelectedStyle.Dirty = true;
}
}
}
/// <summary>
/// Gets or sets a value indicating whether an automatic postback to the server
/// will occur whenever the user changes the selected index.
/// </summary>
[
Category("Behavior"),
DefaultValue(false),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("AutoPostBack"),
]
public bool AutoPostBack
{
get
{
Object obj = ViewState["AutoPostBack"];
return ((obj == null) ? false : (bool)obj);
}
set { ViewState["AutoPostBack"] = value; }
}
/// <summary>
/// Gets or sets the horizontal or vertical orientation of the TabStrip.
/// </summary>
[
Category("Appearance"),
DefaultValue(Orientation.Horizontal),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("TabStripOrientation"),
]
public Orientation Orientation
{
get
{
object obj = ViewState["Orientation"];
return (obj == null) ? Orientation.Horizontal : (Orientation)obj;
}
set { ViewState["Orientation"] = value; }
}
/// <summary>
/// Gets or sets the zero-based index of the selected tab.
/// The index is based on the order of tabs and excludes separators.
/// Example: A TabStrip has a Tab, a TabSeparator, and a Tab.
/// When the first Tab is selected, SelectedIndex is 0.
/// When the second Tab is selected, SelectedIndex is 1.
/// The default is -1, which indicates that nothing is selected.
/// </summary>
[
Category("Behavior"),
DefaultValue(0),
PersistenceMode(PersistenceMode.Attribute),
ResDescription("TabStripSelectedIndex"),
]
public int SelectedIndex
{
get
{
// If the collection is empty, then return NoSelection
int numTabs = Items.NumTabs;
if (numTabs == 0)
{
return NoSelection;
}
// Pull the index out of ViewState, if there is nothing in ViewState,
// then index defaults to 0.
int index = 0;
object obj = ViewState["SelectedIndex"];
if (obj != null)
{
index = (int)obj;
}
else if (_CachedSelectedIndex == NoSelection)
{
// There is no set value in ViewState, but the cached
// value has been set to NoSelection.
return NoSelection;
}
// Verify that the index is valid. If not, then return NoSelection.
if ((index < 0) || (index >= numTabs))
{
return NoSelection;
}
return index;
}
set
{
if ((Items.NumTabs == 0) && (value > NotSet))
{
_CachedSelectedIndex = value;
}
else if ((value > NotSet) && (value < Items.NumTabs))
{
ViewState["SelectedIndex"] = value;
if (value >= 0)
{
_OldMultiPageIndex = -1;
SetTargetSelectedIndex();
}
}
else
{
// Invalid value
throw new ArgumentOutOfRangeException();
}
}
}
/// <summary>
/// Allows the collection to reset the selected index when cleared.
/// </summary>
internal void ResetSelectedIndex()
{
if (ViewState["SelectedIndex"] != null)
{
ViewState.Remove("SelectedIndex");
}
}
/// <summary>
/// Activates the targetted PageView within a MultiPage control.
/// </summary>
private void SetTargetSelectedIndex()
{
int arrayIndex = Items.ToArrayIndex(SelectedIndex);
if (arrayIndex >= 0)
{
Tab tab = (Tab)Items[arrayIndex];
MultiPage multiPage = Target;
if (multiPage != null)
{
PageView page = (tab == null) ? null : tab.Target;
if ((page != null) && !page.Selected)
{
if (_OldMultiPageIndex < 0)
{
_OldMultiPageIndex = multiPage.SelectedIndex;
}
// Activate the PageView
page.Activate();
}
}
}
}
/// <summary>
/// Raises the SelectedIndexChange event.
/// </summary>
/// <param name="e">Contains the event data</param>
protected virtual void OnSelectedIndexChange(EventArgs e)
{
if (SelectedIndexChange != null)
{
SelectedIndexChange(this, e);
}
}
/// <summary>
/// This control always needs a hidden helper.
/// </summary>
protected override bool NeedHelper
{
get { return true; }
}
/// <summary>
/// Processes post back data for the server control given the data from the hidden helper.
/// </summary>
/// <param name="szData">The data from the hidden helper</param>
/// <returns>true if the server control's state changes as a result of the post back; otherwise false.</returns>
protected override bool ProcessData(string szData)
{
try
{
int newIndex = Convert.ToInt32(szData);
if (SelectedIndex != newIndex)
{
SelectedIndex = newIndex;
return true;
}
}
catch
{
// Ignore
}
return false;
}
/// <summary>
/// Signals the server control object to notify the ASP.NET application that the state of the control has changed.
/// </summary>
protected override void RaisePostDataChangedEvent()
{
OnSelectedIndexChange(new EventArgs());
MultiPage target = Target;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -