public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence
{
// default constructor
public AddOnFrameworkWindow()
{
// set Caption property (not Title), since Title is managed internally to properly combine selected Tab Header and Caption for display in the Windows taskbar
// This is the name displayed in the top-left of the window
Caption = "AddOn Framework";
// Set the default dimensions of the window
Width = 1085;
Height = 900;
// TabControl should be created for window content if tab features are wanted
TabControl tc = new TabControl();
// Attached properties defined in the TabControlManager class should be set to achieve adding, removing, and moving tabs
TabControlManager.SetIsMovable(tc, true);
TabControlManager.SetCanAddTabs(tc, true);
TabControlManager.SetCanRemoveTabs(tc, true);
// if ability to add new tabs is desired, TabControl has to have attached property "Factory" set.
TabControlManager.SetFactory(tc, new AddOnFrameworkWindowFactory());
Content = tc;
/* In order to have link buttons functionality, tab control items must be derived from Tools.NTTabPage
They can be added using extension method AddNTTabPage(NTTabPage page) */
tc.AddNTTabPage(new AddOnFrameworkTab());
// WorkspaceOptions property must be set
Loaded += (o, e) =>
{
if (WorkspaceOptions == null)
WorkspaceOptions = new WorkspaceOptions("AddOnFramework-" + Guid.NewGuid().ToString("N"), this);
};
}
// IWorkspacePersistence member. Required for restoring window from workspace
public void Restore(XDocument document, XElement element)
{
if (MainTabControl != null)
MainTabControl.RestoreFromXElement(element);
}
// IWorkspacePersistence member. Required for saving window to workspace
public void Save(XDocument document, XElement element)
{
if (MainTabControl != null)
MainTabControl.SaveToXElement(element);
}
// IWorkspacePersistence member
public WorkspaceOptions WorkspaceOptions { get; set; }
}