We talked about creating various TaskDialog instances before. Now let’s see how TaskDialoger of RevitAddinCoder can assist us to achieve the same goal in a configurable and flexible way. The TaskDialoger can be found from either the Revit Addin Coder sub-menu under the Tools or from Revit Addin Coder toolbar.
When the menu item or button is clicked, the TaskDialoger window will show up:
After it’s filled out like the following:
and the OK button is clicked, the following TaskDialoger code will be created and added into the chosen class:
public static TaskDialogResult TaskDialoger(out bool VerificationCheckBoxOn)
{
// Constructor stuff
TaskDialog td = new TaskDialog("AAAAAAAA");
// Nice to set stuffs
td.Id = "7e72bc0c-44cb-49c9-8618-e1094aa8fa69";
td.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
td.Title = "AAAAAAAA";
td.TitleAutoPrefix = true;
td.AllowCancellation = true;
// Message related stuffs
td.MainInstruction = "BBBBBBBBBBBB";
td.MainContent = "CCCCCCCCCCCCCCCCCCC";
td.FooterText = "DDDDDDDDDDDDD";
td.ExpandedContent = "EEEEEEEEEEEE\nFFFFFFFFFFFFFFFFFFF\nGGGGGGGGGGGGG\n\nHHHHHHHHHHHH\n";
// VerificationText stuff
td.VerificationText = "VVVVVVVVVVVV";
// Command link stuffs
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "11111111111111111");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "2222222222222222");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "3333333333333333");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink4, "44444444444444444444444");
// Common button stuffs
td.CommonButtons =
TaskDialogCommonButtons.Cancel |
TaskDialogCommonButtons.Ok |
TaskDialogCommonButtons.Close |
TaskDialogCommonButtons.No;
td.DefaultButton = TaskDialogResult.Close;
// Dialog showup stuffs
TaskDialogResult tdRes = td.Show();
VerificationCheckBoxOn = td.WasVerificationChecked();
return tdRes;
}
If the following test code is created and called by an external command:
bool verificationChecked;
MessageBox.Show(TaskDialoger(out verificationChecked).ToString() + " Checked: " + verificationChecked.ToString());
and the external command is run inside Revit, a TaskDialog like the following screenshot shows will appear:
The TaskDialog has been expanded so as to show every detail as can be noticed. If the verification box is checked and any link or button is pressed, the message box coming next will show what has been pressed and whether the check box is on.
Give TaskDialoger of RevitAddinWizard a try and you will get all these in no time.
Recent Comments