void ComponentManager_UIElementActivated(object sender, Autodesk.Windows.UIElementActivatedEventArgs e) { if (e == null || e.Item == null || e.Item.Id == null) { return; } if (e.Item.Id == "ID_DYN_BUTTON") { TaskDialog.Show("Dynamic Command", "Dynamic command clicked"); } }
/// <summary> /// React to UI element activation, /// e.g. button click. We have absolutely /// no access to the Revit PI in this method! /// </summary> void OnUiElementActivated( object sender, Autodesk.Windows.UIElementActivatedEventArgs e) { if (e.Item != null) { // We could just remember the button id here // and use one single Idling event handler // for both. if (e.Item.Id == "ID_MYBUTTON1" || e.Item.Id == "ID_MYBUTTON2" || e.Item.Id == "ID_MYBUTTON3") { _button_nr = int.Parse( e.Item.Id.Substring(11)); _controlledApp.Idling += new EventHandler <IdlingEventArgs>( OnButtonIdling); } } }