コード例 #1
0
        // Gives event subscriber a chance to prevent
        // the dialog from closing, based on
        // the current state of the app and the button
        // used to commit. Note that we don't
        // have full access at this stage to
        // the full dialog state.
        internal int RaiseClosingEvent(int id)
        {
            EventHandler <TaskDialogClosingEventArgs> handler = Closing;

            if (handler != null)
            {
                TaskDialogButtonBase       customButton = null;
                TaskDialogClosingEventArgs e            = new TaskDialogClosingEventArgs();

                // Try to identify the button - is it a standard one?
                e.StandardButton = MapButtonIdToStandardButton(id);

                // If not, it had better be a custom button...
                if (e.StandardButton == TaskDialogStandardButton.None)
                {
                    customButton = GetButtonForId(id);

                    // ... or we have a problem.
                    if (customButton == null)
                    {
                        throw new InvalidOperationException("Bad button ID in closing event.");
                    }
                    e.CustomButton = customButton.Name;
                }

                // Raise the event and determine how to proceed.
                handler(this, e);
                if (e.Cancel)
                {
                    return((int)HRESULT.S_FALSE);
                }
            }
            // It's okay to let the dialog close.
            return((int)HRESULT.S_OK);
        }
コード例 #2
0
ファイル: window1.xaml.cs プロジェクト: kyzmitch/Cip
 private void OnDialogClosing(object sender, TaskDialogClosingEventArgs e)
 {
     // Can check e.CustomButton and e.StandardButton properties
     // to determine whether or not to cancel this Close event.
 }
コード例 #3
0
ファイル: TaskDialog.cs プロジェクト: ssickles/archive
        // Gives event subscriber a chance to prevent the dialog from closing, based on 
        // the current state of the app and the button used to commit. Note that we don't 
        // have full access at this stage to the full dialog state - particularly
        internal int RaiseClosingEvent(int id)
        {
            EventHandler<TaskDialogClosingEventArgs> handler = Closing;
            if (handler != null)
            {

                TaskDialogButtonBase customButton = null;
                TaskDialogClosingEventArgs e = new TaskDialogClosingEventArgs();

                // Try to identify the button - is it a standard one?
                e.StandardButton = MapButtonIdToStandardButton(id);

                // If not, it had better be a custom button ...
                if (e.StandardButton == TaskDialogStandardButton.None)
                {
                    customButton = GetButtonForId(id);

                    // ... or we have a problem
                    if (customButton == null)
                        throw new InvalidOperationException("Bad button ID in closing event");
                    e.CustomButton = customButton.Name;
                }

                // Raise the event and determine how to proceed
                handler(this, e);
                if (e.Cancel)
                    return (int)HRESULT.S_FALSE;
            }
            // It's okay to let the dialog close
            return (int)HRESULT.S_OK;
        }
コード例 #4
0
ファイル: Window1.xaml.cs プロジェクト: ssickles/archive
 private void OnDialogClosing(object sender, TaskDialogClosingEventArgs e)
 {
     // Any button clicks are considered a "commit" by the dialog, unless
     // closing is explicitly cancelled
     if (e.CustomButton == "increaseButton" || e.CustomButton == "decreaseButton")
         e.Cancel = true;
 }