/// <summary> /// Adds Command Links to a Task Dialog given a dictionary specification. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="CommandLinks">A dictionary of specificed command links.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask AddCommandLinks(DialogRevitTask TaskDialog, SynthDict CommandLinks) { if (CommandLinks != null) { foreach (KeyValuePair <string, object> cmdLink in SynthDict.UnwrapDictionary(CommandLinks)) { if ((string)cmdLink.Value != "" || cmdLink.Value != null) { switch (cmdLink.Key) { case "CommandLink1": TaskDialog.dialog.AddCommandLink(RevitUi.TaskDialogCommandLinkId.CommandLink1, (string)cmdLink.Value); break; case "CommandLink2": TaskDialog.dialog.AddCommandLink(RevitUi.TaskDialogCommandLinkId.CommandLink2, (string)cmdLink.Value); break; case "CommandLink3": TaskDialog.dialog.AddCommandLink(RevitUi.TaskDialogCommandLinkId.CommandLink3, (string)cmdLink.Value); break; case "CommandLink4": TaskDialog.dialog.AddCommandLink(RevitUi.TaskDialogCommandLinkId.CommandLink4, (string)cmdLink.Value); break; default: break; } } } } return(TaskDialog); }
/// <summary> /// Displays the task dialog box. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="Toggle">A toggle used to re-display the Task Dialog.</param> /// <returns name="DialogResult">A TaskDialogResult based on the button or command link that was chosen.</returns> public static RevitUi.TaskDialogResult Show(DialogRevitTask TaskDialog, [DefaultArgument("true")] bool Toggle) { RevitUi.TaskDialogResult tResult = TaskDialog.dialog.Show(); TaskDialog.dialog.Dispose(); return(tResult); }
/// <summary> /// Resets all the Task Dialogs properties and settings. /// </summary> /// <param name="TaskDialog">A task dialog.</param> /// <param name="toggle">Resets the node.</param> /// <returns name="TaskDialog">The task dialog with a new Revit dialog.</returns> public static DialogRevitTask ResetDialog(DialogRevitTask TaskDialog, bool toggle) { string title = TaskDialog.dialog.Title; TaskDialog.dialog.Dispose(); TaskDialog = new DialogRevitTask(new RevitUi.TaskDialog(title)); return(TaskDialog); }
/// <summary> /// Adds commmon buttons to a Task Dialog given a dictionary specification. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="Buttons">A dictionary of specificed buttons.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask AddCommonButtons(DialogRevitTask TaskDialog, [DefaultArgument("null")] SynthDict Buttons) { RevitUi.TaskDialogCommonButtons commonButtons = RevitUi.TaskDialogCommonButtons.None; if (Buttons != null) { // Set common buttons and default button. If no CommonButton or CommandLink is added, // task dialog will show a Close button by default foreach (KeyValuePair <string, object> button in SynthDict.UnwrapDictionary(Buttons)) { if ((bool)button.Value) { switch (button.Key) { case "Yes": commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.Yes; break; case "No": commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.No; break; case "Cancel": commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.Cancel; break; case "Ok": commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.Ok; break; case "Retry": commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.Retry; break; case "None": commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.None; break; case "Close": default: commonButtons = commonButtons | RevitUi.TaskDialogCommonButtons.Close; break; } } } } else { commonButtons = RevitUi.TaskDialogCommonButtons.Close; } TaskDialog.dialog.CommonButtons = commonButtons; return(TaskDialog); }
/// <summary> /// Creates a Revit Task Dialog. The dialog can be configured in a variety of ways. Additional options are available if you use the ByTitle method. /// </summary> /// <param name="Title">The Title of the dialog box.</param> /// <param name="Instructions">Instructions are written in a large font at the top of the dialog.</param> /// <param name="Content">Detailed content to be included.</param> /// <param name="FooterText">Footer text. Useful for providing links to help content.</param> /// <param name="Buttons">A dictionary of the desired buttons. Use the SpecifyButtons method to create the dictionary.</param> /// <param name="CommandLinks">A dictionary of the desired CommandLinks and associated text. Use the SpecifyCommandLinks to create the dictionary.</param> /// <param name="Results">A dictionary of the possible results of the dialog. Use the SpecifyResults method to create the dictionary.</param> /// <param name="Toggle">Resets the node so the dialog will reopen.</param> /// <returns name="Result">Returns the corresponding result based on the command link or button selected. Will return null if the chosen button or command link has no result. If now Results are input, the TaskDialogResult from the choice will be returned.</returns> public static object ByAllProperties( [DefaultArgument("\"Title\"")] string Title, [DefaultArgument("\"\"")] string Instructions, [DefaultArgument("\"\"")] string Content, [DefaultArgument("\"\"")] string FooterText, [DefaultArgument("null")] SynthDict Buttons, [DefaultArgument("null")] SynthDict CommandLinks, [DefaultArgument("null")] SynthDict Results, [DefaultArgument("true")] bool Toggle ) { // Creates a Revit task dialog to communicate information to the user. DialogRevitTask dialog = new DialogRevitTask(Title); // Set the content areas of the dialog if (Instructions != "") { DialogRevitTask.SetInstructions(dialog, Instructions); } if (Content != "") { DialogRevitTask.SetContent(dialog, Content); } if (FooterText != "") { DialogRevitTask.SetFooterText(dialog, FooterText); } // Set the common buttons. The default button will be the first button on the list. if (Buttons != null) { DialogRevitTask.AddCommonButtons(dialog, Buttons); } // If there are command links, add them to the dialog if (CommandLinks != null) { DialogRevitTask.AddCommandLinks(dialog, CommandLinks); } RevitUi.TaskDialogResult tResult = DialogRevitTask.Show(dialog, true); if (Results != null) { return(FilterResults(tResult, Results)); } else { return(tResult); } }
/// <summary> /// Sets the ExtraCheckBox text of the Task dialog. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="ExtraCheckBoxText">ExtraCheckBox text to be included.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetExtraCheckBoxText(DialogRevitTask TaskDialog, string ExtraCheckBoxText) { TaskDialog.dialog.ExtraCheckBoxText = ExtraCheckBoxText; return(TaskDialog); }
/// <summary> /// Sets whether the dialog box can be canceled or not. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="AllowCancellation">If true, the dialog can be canceled, else it can not.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask AllowCancellation(DialogRevitTask TaskDialog, bool AllowCancellation) { TaskDialog.dialog.AllowCancellation = AllowCancellation; return(TaskDialog); }
/// <summary> /// Set the Verification text of the Task dialog. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="VerificationText">The verification text to be included.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetVerificationText(DialogRevitTask TaskDialog, string VerificationText) { TaskDialog.dialog.VerificationText = VerificationText; return(TaskDialog); }
/// <summary> /// Sets the Expanded Content of the Task dialog. Expanded content is the portion at the bottom with an arrow to display more information. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="ExpandedContent">Expanded content to be included.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetExpandedContent(DialogRevitTask TaskDialog, string ExpandedContent) { TaskDialog.dialog.ExpandedContent = ExpandedContent; return(TaskDialog); }
/// <summary> /// Sets the Footer text of the Task dialog. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="FooterText">Footer text to be included.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetFooterText(DialogRevitTask TaskDialog, string FooterText) { TaskDialog.dialog.FooterText = FooterText; return(TaskDialog); }
/// <summary> /// Sets whether to include the name of the add-in as a prefix to the title. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="prefix">If true, show the prefix, else do not.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetTitleAutoPrefix(DialogRevitTask TaskDialog, bool prefix) { TaskDialog.dialog.TitleAutoPrefix = prefix; return(TaskDialog); }
/// <summary> /// Sets the Title of the Task dialog. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="title">The titl to be included.</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetTitle(DialogRevitTask TaskDialog, string title) { TaskDialog.dialog.Title = title; return(TaskDialog); }
/// <summary> /// Sets the instructions portion of the task dialog. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="instructions">The instructions to be included</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetInstructions(DialogRevitTask TaskDialog, string instructions) { TaskDialog.dialog.MainInstruction = instructions; return(TaskDialog); }
/// <summary> /// Sets the content section of the task dialog. /// </summary> /// <param name="TaskDialog">A Task dialog.</param> /// <param name="content">The content to be included</param> /// <returns name="TaskDialog">The modified Task dialog.</returns> public static DialogRevitTask SetContent(DialogRevitTask TaskDialog, string content) { TaskDialog.dialog.MainContent = content; return(TaskDialog); }