Event arguments for the PageCloseRequest event.
Inheritance: UniqueNameEventArgs
Example #1
0
        /// <summary>
        /// Perform the close request for a set of named pages.
        /// </summary>
        /// <param name="uniqueNames">Array of unique names that need action performed.</param>
        public virtual void CloseRequest(string[] uniqueNames)
        {
            // Cannot action a null reference
            if (uniqueNames == null)
                throw new ArgumentNullException("uniqueNames");

            // Cannot action an empty array
            if (uniqueNames.Length == 0)
                throw new ArgumentOutOfRangeException("uniqueNames", "array cannot be empry");

            // Cannot action a null or zero length unique name
            foreach (string uniqueName in uniqueNames)
            {
                if (uniqueName == null)
                    throw new ArgumentNullException("uniqueNames array contains a null string reference");

                if (uniqueName.Length == 0)
                    throw new ArgumentException("uniqueNames array contains a zero length string");
            }

            using (DockingMultiUpdate update = new DockingMultiUpdate(this))
            {
                CloseRequestEventArgs e;
                foreach (string uniqueName in uniqueNames)
                {
                    // Raise event that allows the action to be defined by handlers
                    e = new CloseRequestEventArgs(uniqueName, DefaultCloseRequest);
                    OnPageCloseRequest(e);

                    switch (e.CloseRequest)
                    {
                        case DockingCloseRequest.None:
                            // Nothing to do!
                            break;
                        case DockingCloseRequest.RemovePage:
                        case DockingCloseRequest.RemovePageAndDispose:
                            PropogateAction(e.CloseRequest == DockingCloseRequest.RemovePageAndDispose ?
                                                DockingPropogateAction.RemoveAndDisposePages :
                                                DockingPropogateAction.RemovePages,
                                            new string[] { uniqueName });
                            break;
                        case DockingCloseRequest.HidePage:
                            PropogateAction(DockingPropogateAction.HidePages, new string[] { uniqueName });
                            break;
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Raises the PageCloseRequest event.
 /// </summary>
 /// <param name="e">An CloseActionEventArgs containing the event args.</param>
 protected virtual void OnPageCloseRequest(CloseRequestEventArgs e)
 {
     if (PageCloseRequest != null)
         PageCloseRequest(this, e);
 }