Get IOrder in ToolWindow

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
roteague
Posts: 292
Joined: Thu Sep 25, 2008 4:49 pm
Location: Honolulu, Hawaii

Get IOrder in ToolWindow

Post by roteague »

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
jbright

Re: Get IOrder in ToolWindow

Post by jbright »

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;
}
roteague
Posts: 292
Joined: Thu Sep 25, 2008 4:49 pm
Location: Honolulu, Hawaii

Re: Get IOrder in ToolWindow

Post by roteague »

Thanks Jason, that looks like a winner. I'll give it a try.
Robert
Post Reply