Пример #1
0
 /// <summary>
 /// Invoke <cref="Change" /> event.
 /// </summary>
 /// <param name="e">The <cref="ChangeOccurredEventArgs" /> type event arguments.</param>
 protected virtual void OnChange(ChangeOccurredEventArgs e)
 {
     if (Change != null)
     {
         Change(this, e);
     }
 }
Пример #2
0
        /// <summary>
        /// Check whether form should be closed.
        /// </summary>
        /// <param name="sender">The form or dialog to close.</param>
        /// <returns>Returns true if <cref="sender" /> should be closed, false otherwise.</returns>
        public bool CancelFormClosing(object sender)
        {
            ChangeDetectingEventArgs e = new ChangeDetectingEventArgs(sender, false);

            OnChangeDetecting(e);
            if (!e.Cancel)
            {
                ChangeOccurredEventArgs changedOccurredEvent = new ChangeOccurredEventArgs(sender, false);
                OnChange(changedOccurredEvent);
                if (changedOccurredEvent.ChangedOccurred)
                {
                    DialogResult result = MessageBox.Show(this.InformationMessage, this.InformationCaption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (!result.Equals(BoxCancel))
                    {
                        OnChangeDetected(new ConfirmationActionEventArgs(sender, result));
                        return(false);
                    }

                    return(true);
                }
            }
            return(e.Cancel);
        }