- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys,
We have a plug in that loads buttons into the main ribbon of civil 3D, each of which open dockable windows.
We load our plugin in the following way:
public class Civil3DPlugin : IExtensionApplication
{
internal static string VERSION = "4.11.3";
private List<AutoHidePaletteSet> paletteSets = new List<AutoHidePaletteSet>();
public void Initialize()
{
if (ComponentManager.Ribbon == null)
{
ComponentManager.ItemInitialized +=
new EventHandler<RibbonItemEventArgs>
(RibbonLoadedHandler);
}
else
{
InitializeRibbonMenu();
}
}
private void RibbonLoadedHandler(object sender, RibbonItemEventArgs e)
{
ComponentManager.ItemInitialized -=
new EventHandler<RibbonItemEventArgs>
(RibbonLoadedHandler);
InitializeRibbonMenu();
}
public void Terminate()
{
}
private void InitializeRibbonMenu()
{
RibbonTab tab = new RibbonTab { Title = " ", Id = " " };
RibbonPanelSource collabPanel = new RibbonPanelSource() { Title = Utility.CollaborationPanelName };
RibbonPanelSource modelSharingPanel = new RibbonPanelSource() { Title = Utility.ModelSharingPanelName };
RibbonPanelSource generalPanel = new RibbonPanelSource() { Title = Utility.GeneralPanelName };
tab.Panels.Add(new RibbonPanel { Source = collabPanel });
tab.Panels.Add(new RibbonPanel { Source = modelSharingPanel });
tab.Panels.Add(new RibbonPanel { Source = generalPanel });
ICommand issuesCommand = new RelayCommand((x) => ShowDockPane(Utility.IssuesPaneTitle));
RibbonButton issuesButton = GenerateRibbonButton(Utility.IssuesButtonName, Utility.IssuesButtonDescription, Utility.IssuesButtonTooltip, issuesCommand, Utility.Resource.ISSUES_ICON);
collabPanel.Items.Add(issuesButton);
InitialiseDockPane(Utility.IssuesPaneTitle, Utility.issuesId, new IssueViewerApplicationViewModel(cim, VERSION));
// More buttons added here in the same way
ComponentManager.Ribbon.Tabs.Add(tab);
}
private RibbonButton GenerateRibbonButton(string text, string description, string tooltip, ICommand command, Utility.Resource icon)
{
RibbonButton button = new RibbonButton
{
Size = RibbonItemSize.Large,
ShowText = true,
ShowImage = true,
IsToolTipEnabled = true,
Orientation = System.Windows.Controls.Orientation.Vertical
};
button.Text = text;
button.Description = description;
button.ToolTip = tooltip;
button.CommandHandler = command;
System.IO.Stream stream = Utility.GetResourceStream(icon);
PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
button.LargeImage = decoder.Frames[0];
return button;
}
private void InitialiseDockPane(string paletteName, Guid appId, PluginViewModelBase avm)
{
var pluginView = new MainView { DataContext = avm };
var ps = new AutoHidePaletteSet(paletteName, appId)
{
Style = PaletteSetStyles.ShowCloseButton,
TitleBarLocation = PaletteSetTitleBarLocation.Right
};
paletteSets.Add(ps);
ps.AddVisual("Content", pluginView);
}
private void ShowDockPane(string paletteName)
{
AutoHidePaletteSet paletteSet = paletteSets.FirstOrDefault(p => p.Name == paletteName);
if (paletteSet != null && !paletteSet.Visible)
{
paletteSet.Visible = true;
}
}
}
What is the best way to remember the visual state of the plugins (were they visible, where they were docked, sizes etc) so that the next time a user opens civil 3D, the plugins tabs are where they were last?
Solved! Go to Solution.
Link copied