private void kryptonNavigator1_CloseAction(object sender, CloseActionEventArgs e) { // If deleting the last page before the 'new page' then need to switch the // selection before the close actually gets processed. Otherwise removing the // second to last page will causing the last 'new page' page to be selected. // But that would cause a new page to be created! So manually set selection // to the previous page to prevent this behavior. if (e.Index == (kryptonNavigator1.Pages.Count - 2)) kryptonNavigator1.SelectedIndex = kryptonNavigator1.Pages.Count - 3; // You cannot delete the last document page. As the 'new page' page at the end of // the collection should always be there, we insist that 2 pages must be present. As // we are now removing a page that means that if there are 3 pages then after the // remove has completed we should not allow any more removes. if (kryptonNavigator1.Pages.Count == 3) kryptonNavigator1.Button.CloseButtonDisplay = ButtonDisplay.ShowDisabled; }
/// <summary> /// Raises and processes the CloseAction event. /// </summary> /// <param name="page">Page that is requested to be closed.</param> /// <returns>Returns the action that was performed.</returns> protected virtual CloseButtonAction OnCloseAction(KryptonPage page) { CloseButtonAction cba = CloseButtonAction.None; // Ignore call as view builder is already destructed if (!IsDisposed && (_viewBuilder != null)) { // Do not perform any action at design time if (!DesignMode) { if (Pages.Contains(page)) { // Create the event arguments CloseActionEventArgs e = new CloseActionEventArgs(page, Pages.IndexOf(page), Button.CloseButtonAction); if (CloseAction != null) CloseAction(this, e); // Return the action we processed cba = e.Action; // Process the requested action switch (e.Action) { case CloseButtonAction.None: // Do nothing break; case CloseButtonAction.RemovePage: // If the page still exists after the event then remove it if (Pages.Contains(e.Item)) Pages.Remove(e.Item); break; case CloseButtonAction.RemovePageAndDispose: // If the page still exists after the event if (Pages.Contains(e.Item)) { // Remove it from the page collection Pages.Remove(e.Item); // Dispose of its resources e.Item.Dispose(); } break; case CloseButtonAction.HidePage: // If the page still exists after the event then hide it if (Pages.Contains(e.Item)) e.Item.Hide(); break; default: // Should never happen! Debug.Assert(false); break; } } } } return cba; }
/// <summary> /// Raises athe CloseAction event. /// </summary> /// <param name="e">An CloseActionEventArgs containing the event args.</param> protected virtual void OnCloseAction(CloseActionEventArgs e) { if (CloseAction != null) CloseAction(this, e); }
private void OnCellCloseAction(object sender, CloseActionEventArgs e) { OnPageCloseClicked(new UniqueNameEventArgs(e.Item.UniqueName)); }
private void kryptonNavigator1_CloseAction(object sender, CloseActionEventArgs e) { AddOutput("CloseAction"); }
private void kryptonCell_PageCloseAction(object sender, CloseActionEventArgs e) { // Tell the cell instance to not perform any actions with the page, we will remove it if we need to e.Action = CloseButtonAction.None; // Use our own routine to close the page, so user is asked to save changes if required CloseMemoPage(e.Item); }