本文整理汇总了C#中TaskDialog.AddCommandLink方法的典型用法代码示例。如果您正苦于以下问题:C# TaskDialog.AddCommandLink方法的具体用法?C# TaskDialog.AddCommandLink怎么用?C# TaskDialog.AddCommandLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskDialog
的用法示例。
在下文中一共展示了TaskDialog.AddCommandLink方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
var dialog = new TaskDialog( "Create DirectShape" )
{
MainInstruction = "Select the way you want to create shape"
};
dialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink1, "Initial shape builder" );
dialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink2, "Jeremy's shape builder" );
dialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink3, "Simple shape builder" );
switch( dialog.Show() )
{
case TaskDialogResult.CommandLink1:
CreateDirectShapeInitial.Execute1( commandData );
break;
case TaskDialogResult.CommandLink2:
CreateDirectShape.Execute( commandData );
break;
case TaskDialogResult.CommandLink3:
CreateDirectShapeSimple.Execute( commandData );
break;
}
return Result.Succeeded;
}
示例2: ShowMessage
/// <summary>
/// Ask User
/// </summary>
/// <returns></returns>
internal static bool ShowMessage()
{
using (TaskDialog td = new TaskDialog("Explanation"))
{
td.TitleAutoPrefix = false;
td.MainInstruction = "Update 'CurveOrientation' Parameters";
td.MainContent += "This command requires that an instance text parameter named 'CurveOrientation' exist on all elements of the target category.\n\n";
td.MainContent += "A text string of HORIZONTAL, VERTICAL, or SLOPED will then get placed into each element's 'CurveOrientation' parameter for the primary purpose of clash detection filtering in an external program.";
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Update 'CurveOrientation' Parameters");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Cancel and Do Nothing");
if (td.Show() == TaskDialogResult.CommandLink1)
return true;
else
return false;
}
}
示例3: Execute
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message, Autodesk.Revit.DB.ElementSet elements)
{
TaskDialog dlg = new TaskDialog(@"Hello Revit");
dlg.MainContent = @"Hello Revit";
dlg.MainInstruction = @"Say hello!";
dlg.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, @"Hello");
dlg.Show();
return Autodesk.Revit.UI.Result.Succeeded;
}
示例4: ModifyObjects
//.........这里部分代码省略.........
// Assign the parameters
SetParameters(fi, obj.Parameters, doc);
}
}
}
#endregion
#region Closed Curve Family
else
{
bool replace = false;
if (supress)
{
if (supressedReplace)
{
replace = true;
}
else
{
replace = false;
}
}
if (profileWarning && !supress)
{
TaskDialog warningDlg = new TaskDialog("Warning")
{
MainInstruction = "Profile based Elements warning",
MainContent =
"Elements that require updates to a profile sketch may not be updated if the number of curves in the sketch differs from the incoming curves." +
" In such cases the element and will be deleted and replaced with new elements." +
" Doing so will cause the loss of any elements hosted to the original instance. How would you like to proceed"
};
warningDlg.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Replace the existing elements, understanding hosted elements may be lost");
warningDlg.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Only updated parameter information and not profile or location information");
warningDlg.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "Cancel");
//warningDlg.VerificationText = "Supress similar warnings";
TaskDialogResult result = warningDlg.Show();
if (result == TaskDialogResult.CommandLink1)
{
replace = true;
supressedReplace = true;
supressedModify = true;
//supress = warningDlg.WasVerificationChecked();
}
if (result == TaskDialogResult.CommandLink2)
{
supressedReplace = false;
supressedModify = true;
//supress = warningDlg.WasVerificationChecked();
}
if (result == TaskDialogResult.CommandLink3)
{
supressedReplace = false;
supressedModify = false;
//supress = warningDlg.WasVerificationChecked();
}
}
// A list of curves. These should equate a closed planar curve from GH.
// Determine category and create based on that.
#region walls
if (obj.CategoryId == -2000011)
{
// Create line based wall
// Find the level
示例5: lock
//.........这里部分代码省略.........
i++;
}
try
{
ModifyObjects(incomingObjs, modObjects, uiApp.ActiveUIDocument.Document, uniqueId, true, nickName, runId);
DeleteExisting(uiApp.ActiveUIDocument.Document, removeObjects);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
else if (existingRunEID.Count < incomingObjs.Count)
{
// modify and create
// create and modify
List<RevitObject> existingObjects = new List<RevitObject>();
List<RevitObject> newObjects = new List<RevitObject>();
int i = 0;
Debug.Assert(existing != null, "existing != null");
while (i < existingRunEID.Count)
{
existingObjects.Add(incomingObjs[i]);
i++;
}
while (i < incomingObjs.Count)
{
newObjects.Add(incomingObjs[i]);
i++;
}
try
{
ModifyObjects(existingObjects, existingRunEID, uiApp.ActiveUIDocument.Document, uniqueId, true, nickName, runId);
CreateObjects(newObjects, uiApp.ActiveUIDocument.Document, uniqueId, runId, nickName);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
// modBehavior = 1, Create a new run
else if (modBehavior == 1)
{
// Just send everything to create a new Run.
try
{
CreateObjects(incomingObjs, uiApp.ActiveUIDocument.Document, uniqueId, lastId + 1, nickName);
}
catch (Exception ex)
{
Debug.WriteLine("Error", ex.Message);
}
}
// modBehavior = 3, cancel/ignore
}
else
{
TaskDialog dlg = new TaskDialog("Warning") { MainInstruction = "Incoming Data" };
RevitObject existingObj1 = incomingObjs[0];
bool profileWarning1 = (existingObj1.CategoryId == -2000011 && existingObj1.Curves.Count > 1) || existingObj1.CategoryId == -2000032 || existingObj1.CategoryId == -2000035;
if (existing == null || existing.Count == 0)
{
dlg.MainContent = "Data is being sent to Revit from another application using Lyrebird." +
" This data will be used to create " + incomingObjs.Count.ToString(CultureInfo.InvariantCulture) + " elements. How would you like to proceed?";
dlg.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Create new elements");
dlg.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Cancel");
}
TaskDialogResult result1 = dlg.Show();
if (result1 == TaskDialogResult.CommandLink1)
{
// Create new
try
{
CreateObjects(incomingObjs, uiApp.ActiveUIDocument.Document, uniqueId, 0, nickName);
}
catch (Exception ex)
{
TaskDialog.Show("Error", ex.Message);
}
}
}
}
catch (Exception ex)
{
TaskDialog.Show("Test", ex.Message);
Debug.WriteLine(ex.Message);
}
finally
{
Monitor.Pulse(_locker);
}
});
Monitor.Wait(_locker, Properties.Settings.Default.infoTimeout);
}
return true;
}
示例6: Execute
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="commandData">An object that is passed to the external application
/// which contains data related to the command,
/// such as the application object and active view.</param>
/// <param name="message">A message that can be set by the external application
/// which will be displayed if a failure or cancellation is returned by
/// the external command.</param>
/// <param name="elements">A set of elements to which the external application
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
/// <returns>Return the status of the external command.
/// A result of Succeeded means that the API external method functioned as expected.
/// Cancelled can be used to signify that the user cancelled the external operation
/// at some point. Failure should be returned if the application is unable to proceed with
/// the operation.</returns>
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message, Autodesk.Revit.DB.ElementSet elements)
{
// NOTES: Anything can be done in this method, such as create a message box,
// a task dialog or fetch some information from revit and so on.
// We mainly use the task dialog for example.
// Get the application and document from external command data.
Application app = commandData.Application.Application;
Document activeDoc = commandData.Application.ActiveUIDocument.Document;
#region Task Dialog Sample
// Study how to create a revit style dialog using task dialog API by following
// code snippet.
// Creates a Revit task dialog to communicate information to the interactive user.
TaskDialog mainDialog = new TaskDialog("Hello, Revit!");
mainDialog.MainInstruction = "Hello, Revit!";
mainDialog.MainContent =
"This sample shows how a basic ExternalCommand can be added to the Revit user interface."
+ " It uses a Revit task dialog to communicate information to the interactive user.\n"
+ "The command links below open additional task dialogs with more information.";
// Add commmandLink to task dialog
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
"View information about the Revit installation");
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
"View information about the active document");
// Set common buttons and default button. If no CommonButton or CommandLink is added,
// task dialog will show a Close button by default.
mainDialog.CommonButtons = TaskDialogCommonButtons.Close;
mainDialog.DefaultButton = TaskDialogResult.Close;
// Set footer text. Footer text is usually used to link to the help document.
mainDialog.FooterText =
"<a href=\"http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 \">"
+ "Click here for the Revit API Developer Center</a>";
TaskDialogResult tResult = mainDialog.Show();
// If the user clicks the first command link, a simple Task Dialog
// with only a Close button shows information about the Revit installation.
if (TaskDialogResult.CommandLink1 == tResult)
{
TaskDialog dialog_CommandLink1 = new TaskDialog("Revit Build Information");
dialog_CommandLink1.MainInstruction =
"Revit Version Name is: " + app.VersionName + "\n"
+ "Revit Version Number is: " + app.VersionNumber + "\n"
+ "Revit Version Build is: " + app.VersionBuild;
dialog_CommandLink1.Show();
}
// If the user clicks the second command link, a simple Task Dialog
// created by static method shows information about the active document.
else if (TaskDialogResult.CommandLink2 == tResult)
{
TaskDialog.Show("Active Document Information",
"Active document: " + activeDoc.Title + "\n"
+ "Active view name: " + activeDoc.ActiveView.Name);
}
#endregion
return Autodesk.Revit.UI.Result.Succeeded;
}
示例7: DealNotUpdate
/// <summary>
/// Deal with the case that the project status wasn't updated.
/// If the event is Cancellable, cancel it and inform user else just inform user the status.
/// </summary>
/// <param name="args">Event arguments that contains the event data.</param>
private static void DealNotUpdate(RevitAPIPreDocEventArgs args)
{
string mainMessage;
string additionalText;
TaskDialog taskDialog = new TaskDialog("CancelSave Sample");
if (args.Cancellable)
{
args.Cancel(); // cancel this event if it is cancellable.
mainMessage = "CancelSave sample detected that the Project Status parameter on Project Info has not been updated. The file will not be saved."; // prompt to user.
}
else
{
// will not cancel this event since it isn't cancellable.
mainMessage = "The file is about to save. But CancelSave sample detected that the Project Status parameter on Project Info has not been updated."; // prompt to user.
}
// taskDialog will not show when do regression test.
if (!LogManager.RegressionTestNow)
{
additionalText = "You can disable this permanently by uninstaling the CancelSave sample from Revit. Remove or rename CancelSave.addin from the addins directory.";
// use one taskDialog to inform user current situation.
taskDialog.MainInstruction = mainMessage;
taskDialog.MainContent = additionalText;
taskDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Open the addins directory");
taskDialog.CommonButtons = TaskDialogCommonButtons.Close;
taskDialog.DefaultButton = TaskDialogResult.Close;
TaskDialogResult tResult = taskDialog.Show();
if (TaskDialogResult.CommandLink1 == tResult)
{
System.Diagnostics.Process.Start("explorer.exe", DetectAddinFileLocation(args.Document.Application));
}
}
// write log file.
LogManager.WriteLog(" Project Status is not updated, taskDialog informs user: " + mainMessage);
}
示例8: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements )
{
// Get access to the top most objects. (we may not use them all in this specific lab.)
_uiApp = commandData.Application;
_uiDoc = _uiApp.ActiveUIDocument;
// (1) create an instance of task dialog to set more options.
TaskDialog houseDialog = new TaskDialog( "Revit UI Labs - Create House Dialog" );
houseDialog.MainInstruction = "Create a house";
houseDialog.MainContent = "There are two options to create a house.";
houseDialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink1, "Interactive", "You will pick two corners of rectangular footprint of a house, and choose where you want to add a front door." );
houseDialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink2, "Automatic", "This is will automatically place a house with a default settings." );
houseDialog.CommonButtons = TaskDialogCommonButtons.Cancel;
houseDialog.DefaultButton = TaskDialogResult.CommandLink1;
// Show the dialog to the user.
TaskDialogResult res = houseDialog.Show();
//TaskDialog.Show( "Create house dialog", "The last action was: " + res.ToString());
// (2) pause the result and create a house with the method that use has chosen.
//
// Create a house interactively.
if( res == TaskDialogResult.CommandLink1 )
{
UICreateHouse.CreateHouseInteractive( _uiDoc );
return Result.Succeeded;
}
// Create a house automatically with the default settings.
if( res == TaskDialogResult.CommandLink2 )
{
IntroCs.ModelCreationExport.CreateHouse( _uiDoc.Document );
return Result.Succeeded;
}
// Request canceled.
if( res == TaskDialogResult.Cancel )
{
return Result.Cancelled;
}
return Result.Succeeded;
}
示例9: ShowTaskDialogInstance
/// <summary>
/// Task Dialog - create an instance of task dialog gives you more options.
/// cf. Developer guide, Figure 223 (on pp 405) has a image of all the components visible.
/// This function is to visulize what kind of contents you can add with TaskDialog.
/// Note: actual interpretation of
/// </summary>
public void ShowTaskDialogInstance( bool stepByStep )
{
// (0) create an instance of task dialog to set more options.
TaskDialog myDialog = new TaskDialog( "Revit UI Labs - Task Dialog Options" );
if( stepByStep ) myDialog.Show();
// (1) set the main area. these appear at the upper portion of the dialog.
myDialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
// or TaskDialogIcon.TaskDialogIconNone.
if( stepByStep ) myDialog.Show();
myDialog.MainInstruction = "Main instruction: This is Revit UI Lab 3 Task Dialog";
if( stepByStep ) myDialog.Show();
myDialog.MainContent = "Main content: You can add detailed description here.";
if( stepByStep ) myDialog.Show();
// (2) set the bottom area
myDialog.CommonButtons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No | TaskDialogCommonButtons.Cancel;
myDialog.DefaultButton = TaskDialogResult.Yes;
if( stepByStep ) myDialog.Show();
myDialog.ExpandedContent = "Expanded content: the visibility of this portion is controled by Show/Hide button.";
if( stepByStep ) myDialog.Show();
myDialog.VerificationText = "Verification: Do not show this message again comes here";
if( stepByStep ) myDialog.Show();
myDialog.FooterText = "Footer: <a href=\"http://www.autodesk.com/developrevit\">Revit Developer Center</a>";
if( stepByStep ) myDialog.Show();
// (4) add command links. you can add up to four links
myDialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink1, "Command Link 1", "description 1" );
if( stepByStep ) myDialog.Show();
myDialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink2, "Command Link 2", "description 2" );
if( stepByStep ) myDialog.Show();
myDialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink3, "Command Link 3", "you can add up to four command links" );
if( stepByStep ) myDialog.Show();
myDialog.AddCommandLink( TaskDialogCommandLinkId.CommandLink4, "Command Link 4", "Can also have URLs e.g. Revit Product Online Help" );
//if (stepByStep) myDialog.Show();
// Show it.
TaskDialogResult res = myDialog.Show();
if( TaskDialogResult.CommandLink4 == res )
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
// process.StartInfo.FileName = "http://docs.autodesk.com/REVIT/2011/ENU/landing.html";
//process.StartInfo.FileName = "http://wikihelp.autodesk.com/Revit/enu/2012";
process.StartInfo.FileName = "http://wikihelp.autodesk.com/Revit/enu/2013";
process.Start();
}
TaskDialog.Show("Show task dialog", "The last action was: " + res.ToString());
}
示例10: QuestionMsg
/// <summary>
/// MessageBox wrapper for question message.
/// </summary>
public static bool QuestionMsg( string msg )
{
Debug.WriteLine( msg );
//bool rc = WinForms.DialogResult.Yes
// == WinForms.MessageBox.Show( msg, Caption, WinForms.MessageBoxButtons.YesNo, WinForms.MessageBoxIcon.Question );
//Debug.WriteLine( rc ? "Yes" : "No" );
//return rc;
TaskDialog d = new TaskDialog( Caption );
d.MainIcon = TaskDialogIcon.TaskDialogIconNone;
d.MainInstruction = msg;
//d.CommonButtons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
d.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Instance parameters");
d.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Type parameters");
//d.DefaultButton = TaskDialogResult.Yes;
//return TaskDialogResult.Yes == d.Show();
return d.Show() == TaskDialogResult.CommandLink1;
}