Get IOrder in ToolWindow
Moderator: Phil Barton
Get IOrder in ToolWindow
Is it possible to get the current order from within a Tool Window? I realize that the window is available when no order is loaded.
Robert
Re: Get IOrder in ToolWindow
Here's one way to do it. This is in the ZipCodePackage SDK sampe in Select 2.3.
Code: Select all
/// <summary>
/// If an order is open and active in select, return it. Otherwise return null.
/// </summary>
private IOrder GetActiveOrder( )
{
IWindowManager windowManager = GetService<IWindowManager>();
IWindowFrame activeDocument = windowManager.ActiveDocument;
if ( activeDocument == null )
{
return null;
}
IRunningDocumentsManager runningDocumentsManager = GetService<IRunningDocumentsManager>();
IRunningDocumentInformation runningDocumentInformation = runningDocumentsManager.FindDocument(activeDocument.DocumentHandle);
if ( runningDocumentInformation == null )
{
return null;
}
EditorPane p = runningDocumentInformation.Data as EditorPane;
if ( p == null )
{
return null;
}
return p.GetProperty("Order") as IOrder;
}