示例#1
0
 private List<NativeMethods.TASKDIALOG_BUTTON> SetupRadioButtons()
 {
     _radioButtonsById = new Dictionary<int, TaskDialogRadioButton>();
     List<NativeMethods.TASKDIALOG_BUTTON> radioButtons = new List<NativeMethods.TASKDIALOG_BUTTON>();
     _config.nDefaultRadioButton = 0;
     foreach( TaskDialogRadioButton radioButton in RadioButtons )
     {
         if( string.IsNullOrEmpty(radioButton.Text) )
             throw new InvalidOperationException(Properties.Resources.TaskDialogEmptyButtonLabelError);
         if( radioButton.Id < 1 )
             throw new InvalidOperationException(Properties.Resources.InvalidTaskDialogItemIdError);
         _radioButtonsById.Add(radioButton.Id, radioButton);
         if( radioButton.Checked )
             _config.nDefaultRadioButton = radioButton.Id;
         NativeMethods.TASKDIALOG_BUTTON taskDialogButton = new NativeMethods.TASKDIALOG_BUTTON();
         taskDialogButton.nButtonID = radioButton.Id;
         taskDialogButton.pszButtonText = radioButton.Text;
         radioButtons.Add(taskDialogButton);
     }
     SetFlag(NativeMethods.TaskDialogFlags.NoDefaultRadioButton, _config.nDefaultRadioButton == 0);
     return radioButtons;
 }
示例#2
0
 private List<NativeMethods.TASKDIALOG_BUTTON> SetupButtons()
 {
     _buttonsById = new Dictionary<int, TaskDialogButton>();
     List<NativeMethods.TASKDIALOG_BUTTON> buttons = new List<NativeMethods.TASKDIALOG_BUTTON>();
     _config.nDefaultButton = 0;
     foreach( TaskDialogButton button in Buttons )
     {
         if( button.Id < 1 )
             throw new InvalidOperationException(Properties.Resources.InvalidTaskDialogItemIdError);
         _buttonsById.Add(button.Id, button);
         if( button.Default )
             _config.nDefaultButton = button.Id;
         if( button.ButtonType == ButtonType.Custom )
         {
             if( string.IsNullOrEmpty(button.Text) )
                 throw new InvalidOperationException(Properties.Resources.TaskDialogEmptyButtonLabelError);
             NativeMethods.TASKDIALOG_BUTTON taskDialogButton = new NativeMethods.TASKDIALOG_BUTTON();
             taskDialogButton.nButtonID = button.Id;
             taskDialogButton.pszButtonText = button.Text;
             if( ButtonStyle == TaskDialogButtonStyle.CommandLinks || ButtonStyle == TaskDialogButtonStyle.CommandLinksNoIcon && !string.IsNullOrEmpty(button.CommandLinkNote) )
                 taskDialogButton.pszButtonText += "\n" + button.CommandLinkNote;
             buttons.Add(taskDialogButton);
         }
         else
         {
             _config.dwCommonButtons |= button.ButtonFlag;
         }
     }
     return buttons;
 }