@mwillia1: I am sorry, I misunderstood, and hope that the following proven approach matches your objective: Let's say, your dockpanel has a grid control, which should be initialized with Vault UI theme support, context menu, and cached information retrieved from Vault server one time instead of on selection changed events.
I implemented this likewise:
- The dock panel is registered during startup (<UserControl> = myPanelGrid in later code snippets):
IEnumerable<DockPanel> IExplorerExtension.DockPanels()
{
List<DockPanel> dockPanels = new List<DockPanel>();
DockPanel myPanel = new DockPanel(
Guid.Parse("<GUID>"),
"My Panel's DisplayName",
typeof(<UserControl>));
myPanel.SelectionChanged += myPanel_SelectionChanged;
dockPanels.Add(myPanel);
return dockPanels;
}
- The UserControl's constructor adds the theme support, context menu, and variables to preload data:
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="myPanelGrid"/> class.
/// </summary>
public myPanelGrid()
{
InitializeComponent();
_dataGrid = gridControl1;
_currentTheme = VaultmyPanel.mCurrentTheme.ToString();
ApplyTheme(_currentTheme);
UpdateTheme(_currentTheme);
}
#endregion
#region Overrides
/// <summary>
/// Raises the <see cref="Control.Load"/> event.
/// </summary>
/// <param name="e">An <see cref="EventArgs"/> that contains the event data.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
InitializeBarManager();
InitializeContextMenu();
SetupEventHandlers();
}
#endregion
Finally, the OnLogOn activates the theme and preloads data:
void IExplorerExtension.OnLogOn(IApplication application)
{
VaultApplication = application;
connection = application.Connection;
// Load property definitions for both FILE and ITEM entity classes
mFilePropDefs = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId(EntityClassFile);
mItemPropDefs = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId(EntityClassItem);
// do more stuff that myPanelGrid needs
//...
// Register theme support
mCurrentTheme = VDF.Forms.Library.CurrentTheme;
VDF.Forms.Library.ThemeChanged += Library_ThemeChanged;
myPanelGrid.UpdateTheme(VDF.Forms.Library.CurrentTheme.ToString());
}
Does this resonate with your objective?
Markus Koechl
Solutions Engineer PDM, Autodesk Central Europe