/// <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> /// Sets this page to be the selected page. /// </summary> public virtual void Activate() { MultiPage multiPage = ParentMultiPage; if (multiPage != null) { multiPage.SelectedIndex = Index; } }
/// <summary> /// Clears the collection. /// </summary> public override void Clear() { if (Count > 0) { // This is to prepare for new items later. // When a new item is added later, we want the SelectedIndex to reset to 0. MultiPage mpParent = (MultiPage)Owner; mpParent.SelectedIndex = 0; } base.Clear(); }
/// <summary> /// After removing an index, adjust the selected index. /// </summary> /// <param name="index">The index of the element that was removed.</param> private void RemovedIndex(int index) { MultiPage mpParent = (MultiPage)Owner; int curIndex = mpParent.SelectedIndex; if ((index >= 0) && (index < curIndex)) { mpParent.SelectedIndex = curIndex - 1; } else if ((index == curIndex) && (curIndex > 0) && (Count <= curIndex)) { mpParent.SelectedIndex = Count - 1; } }
/// <summary> /// Adds a control to the collection at a specific index. /// </summary> /// <param name="index">The index where the control should be added.</param> /// <param name="child">The child control.</param> public override void AddAt(int index, Control child) { VerifyChild(child); base.AddAt(index, child); MultiPage mpParent = (MultiPage)Owner; int curIndex = mpParent.SelectedIndex; if (index <= curIndex) { curIndex++; if (curIndex < Count) { mpParent.SelectedIndex = curIndex; } } }
/// <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; if (target != null) { if (_OldMultiPageIndex < 0) { SetTargetSelectedIndex(); } if ((_OldMultiPageIndex >= 0) && (target.SelectedIndex != _OldMultiPageIndex)) { target.FireSelectedIndexChangeEvent(); } } }
/// <summary> /// Initializes a new instance of a PageViewCollection. /// </summary> /// <param name="owner">The parent MultiPage control.</param> public PageViewCollection(MultiPage owner) : base(owner) { }