Message 1 of 6
How to link the BasicDockPanePlugin to the command ID of CustomRibbon?
Not applicable
08-06-2012
06:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I want to link a HelloWorldDockPane to a command button in CustomRibbon,like button_3. Then the dockpane will show in the NW windows when I click the button_3. However, the following codes can't work successfully。 I have no idea about the reason. Thx. ____________________________________________________________________________ using System; using System.Windows.Forms; using Autodesk.Navisworks.Api.Plugins; using BasicDockPanePlugin; namespace CustomRibbon { [Plugin("CustomRibbonCommandHandler", "ADSK", DisplayName = "Custom Ribbon")] [Strings("CustomRibbon.name")] [RibbonLayout("CustomRibbon.xaml")] [RibbonTab("ID_CustomTab_1", DisplayName = "Custom Tab 1 - non-localised")] [Command("ID_Button_3", CanToggle = true, Shortcut = "Shift+Z")] public class CustomRibbonCommandHandler : CommandHandlerPlugin { public CustomRibbonCommandHandler() { m_button3_on = false; } public override int ExecuteCommand(string commandId, params string[] parameters) { if (commandId == "ID_Button_3") { m_button3_on = !m_button3_on; } return 0; } public override CommandState CanExecuteCommand(String commandId) { CommandState state = new CommandState(); if (commandId == "ID_Button_3") { state.IsEnabled = true; state.IsChecked = m_button3_on; } return state; } public bool m_button3_on; public Control CreateControlPane() { HelloWorldControl control = new HelloWorldControl(); control.Dock = DockStyle.Fill; //localisation control.Text = this.TryGetString("HelloWorldText"); if (m_button3_on) { control.CreateControl(); } return control; } public void DestroyControlPane(Control pane) { pane.Dispose(); } } }