/// <summary>
        /// Simulate the action of a button click in the TaskDialog. This can be a DialogResult value
        /// or the ButtonID set on a TasDialogButton set on TaskDialog.Buttons.
        /// </summary>
        /// <param name="buttonId">Indicates the button ID to be clicked.</param>
        public void ClickButton(int buttonId)
        {
            ButtonClickedArgs buttonClickedArgs = new ButtonClickedArgs(buttonId);

            if (InvokeButtonClicked(this, buttonClickedArgs))
            {
                return;
            }
            _commandButtonClicked = buttonId;
            DialogResult          = DialogResult.OK;
            return;

            /*
             * IEnumerable<Button> commonButtons = commonButtonPanel.Controls.OfType<Button>();
             * foreach( Button button in commonButtons.Where( button => (int)button.Tag == buttonId ) ) {
             * InvokeButtonClicked( this, new ButtonClickedArgs( (int)button.Tag ) );
             * return;
             * }
             * IEnumerable<CommandButton> buttons = commandButtonsPanel.Controls.OfType<CommandButton>();
             * foreach( CommandButton button in buttons.Where( button => (int)button.Tag == buttonId ) ) {
             * InvokeButtonClicked( this, new ButtonClickedArgs( (int)button.Tag ) );
             * return;
             * }
             */
        }
 private void InvokeRadioButtonClicked(ITaskDialog sender, ButtonClickedArgs e)
 {
     if (RadioButtonClicked != null)
     {
         RadioButtonClicked(sender, e);
     }
 }
Exemple #3
0
        private static void InvokeButtonClicked(ITaskDialog sender, ButtonClickedArgs e)
        {
            TaskDialogEventHandler <ButtonClickedArgs> handler = ButtonClicked;

            if (handler != null)
            {
                handler(sender, e);
            }
        }
        private void CommandButton_Click(object sender, EventArgs e)
        {
            int commandButtonClicked            = (int)((CommandButton)sender).Tag;
            ButtonClickedArgs buttonClickedArgs = new ButtonClickedArgs(commandButtonClicked);

            if (InvokeButtonClicked(this, buttonClickedArgs))
            {
                return;
            }
            _commandButtonClicked = commandButtonClicked;
            DialogResult          = DialogResult.OK;
        }
        private bool InvokeButtonClicked(ITaskDialog sender, ButtonClickedArgs e)
        {
            if (ButtonClicked != null)
            {
                ButtonClicked(sender, e);
            }
            if (e.PreventClosing)
            {
                return(true);
            }

            return(false);
        }
 private void EmulatedTaskDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing)
     {
         // The close button has the same button id as the Yes common button.
         // Kinda weird, but that's how it seems to be.
         ButtonClickedArgs buttonClickedArgs = new ButtonClickedArgs(2);
         if (!TaskConfig.Flags.AllowDialogCancellation || InvokeButtonClicked(this, buttonClickedArgs))
         {
             e.Cancel = true;
         }
         DialogResult = DialogResult.Cancel;
     }
 }
        private void CommonButtonClick(object sender, EventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                ButtonClickedArgs buttonClickedArgs = new ButtonClickedArgs((int)button.Tag);
                if (InvokeButtonClicked(this, buttonClickedArgs))
                {
                    return;
                }

                // Close button pressed?
                if ((int)button.Tag == 8)
                {
                    DialogResult = DialogResult.Cancel;
                }
                else
                {
                    DialogResult = (DialogResult)button.Tag;
                }
            }
        }