| 1 | public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence |
| 2 | { |
| 3 | // default constructor |
| 4 | public AddOnFrameworkWindow() |
| 5 | { |
| 6 | // set Caption property (not Title), since Title is managed internally to properly combine selected Tab Header and Caption for display in the Windows taskbar |
| 7 | // This is the name displayed in the top-left of the window |
| 8 | Caption = "AddOn Framework"; |
| 9 | |
| 10 | // Set the default dimensions of the window |
| 11 | Width = 1085; |
| 12 | Height = 900; |
| 13 | |
| 14 | // TabControl should be created for window content if tab features are wanted |
| 15 | TabControl tc = new TabControl(); |
| 16 | |
| 17 | // Attached properties defined in the TabControlManager class should be set to achieve adding, removing, and moving tabs |
| 18 | TabControlManager.SetIsMovable(tc, true); |
| 19 | TabControlManager.SetCanAddTabs(tc, true); |
| 20 | TabControlManager.SetCanRemoveTabs(tc, true); |
| 21 | |
| 22 | // if ability to add new tabs is desired, TabControl has to have attached property "Factory" set. |
| 23 | TabControlManager.SetFactory(tc, new AddOnFrameworkWindowFactory()); |
| 24 | Content = tc; |
| 25 | |
| 26 | /* In order to have link buttons functionality, tab control items must be derived from Tools.NTTabPage |
| 27 | They can be added using extension method AddNTTabPage(NTTabPage page) */ |
| 28 | tc.AddNTTabPage(new AddOnFrameworkTab()); |
| 29 | |
| 30 | // WorkspaceOptions property must be set |
| 31 | Loaded += (o, e) => |
| 32 | { |
| 33 | if (WorkspaceOptions == null) |
| 34 | WorkspaceOptions = new WorkspaceOptions("AddOnFramework-" + Guid.NewGuid().ToString("N"), this); |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | // IWorkspacePersistence member. Required for restoring window from workspace |
| 39 | public void Restore(XDocument document, XElement element) |
| 40 | { |
| 41 | if (MainTabControl != null) |
| 42 | MainTabControl.RestoreFromXElement(element); |
| 43 | } |
| 44 | |
| 45 | // IWorkspacePersistence member. Required for saving window to workspace |
| 46 | public void Save(XDocument document, XElement element) |
| 47 | { |
| 48 | if (MainTabControl != null) |
| 49 | MainTabControl.SaveToXElement(element); |
| 50 | } |
| 51 | |
| 52 | // IWorkspacePersistence member |
| 53 | public WorkspaceOptions WorkspaceOptions { get; set; } |
| 54 | } |