public void WriteConfigurationToSettings(DevCore.Settings.SettingsNode parentNode, DevCore.ModuleConfiguration configuration) { DevCore.Settings.SettingsNode configurationNode = default(DevCore.Settings.SettingsNode); // Create the node for the configuration configurationNode = parentNode.GetOrAddNode("Configuration"); // Clear any previous data configurationNode.Nodes.Clear(); configurationNode.Values.Clear(); if (configuration.Count == 0) { // Remove the node parentNode.RemoveNode(configurationNode.Key); } else { // Add the items from the configuration foreach (DevCore.ModuleConfigurationItem item in configuration) { configurationNode.SetOrAddValue(item.Key, item.Value); } } }
public void AddWorkspaceLayoutPanel(DevDesktop.Workspace.WorkspacePanelBase panel, DevCore.Settings.SettingsNode parentNode, int parentPanelCount, ref int groupCounter) { DevDesktop.Workspace.WorkspacePalettePanel palettePanel = default(DevDesktop.Workspace.WorkspacePalettePanel); DevDesktop.Workspace.WorkspaceLayoutGroup layoutGroup = default(DevDesktop.Workspace.WorkspaceLayoutGroup); if (panel is DevDesktop.Workspace.WorkspaceLayoutGroup) { layoutGroup = (DevDesktop.Workspace.WorkspaceLayoutGroup)panel; groupCounter += 1; DevCore.Settings.SettingsNode groupNode = default(DevCore.Settings.SettingsNode); groupNode = parentNode.GetOrAddNode(string.Format("group:{0}", groupCounter)); groupNode.SetOrAddValue("IsTabbed", layoutGroup.IsTabbed); groupNode.SetOrAddValue("RelativeExtent", panel.InitialExtents.RelativeExtent); foreach (DevDesktop.Workspace.WorkspacePanelBase groupPanel in layoutGroup.Panels) { if (groupPanel is DevDesktop.Workspace.WorkspaceLayoutGroup) { this.AddWorkspaceLayoutPanel(groupPanel, groupNode, layoutGroup.Panels.Count, ref groupCounter); } else if (groupPanel is DevDesktop.Workspace.WorkspacePalettePanel) { palettePanel = (DevDesktop.Workspace.WorkspacePalettePanel)groupPanel; DevCore.Settings.SettingsNode panelNode = default(DevCore.Settings.SettingsNode); if (palettePanel.Index == 0) { panelNode = groupNode.GetOrAddNode("palette:canvas"); } else { panelNode = groupNode.GetOrAddNode(string.Format("palette:{0}", palettePanel.Index)); } WriteConfigurationToSettings(panelNode, palettePanel.PaletteConfiguration); panelNode.SetOrAddValue("PaletteGuid", palettePanel.PaletteGuid); if (palettePanel.HasGlobalName) { panelNode.SetOrAddValue("GlobalName", palettePanel.GlobalName); } if (layoutGroup.Panels.Count > 1) { panelNode.SetOrAddValue("RelativeExtent", groupPanel.InitialExtents.RelativeExtent); } } } } else if (panel is DevDesktop.Workspace.WorkspacePalettePanel) { palettePanel = (DevDesktop.Workspace.WorkspacePalettePanel)panel; DevCore.Settings.SettingsNode panelNode = default(DevCore.Settings.SettingsNode); if (((DevDesktop.Workspace.WorkspacePalettePanel)panel).Index == 0) { panelNode = parentNode.GetOrAddNode("palette:canvas"); } else { panelNode = parentNode.GetOrAddNode(string.Format("palette:{0}", palettePanel.Index)); } WriteConfigurationToSettings(panelNode, palettePanel.PaletteConfiguration); panelNode.SetOrAddValue("PaletteGuid", palettePanel.PaletteGuid); if (palettePanel.HasGlobalName) { panelNode.SetOrAddValue("GlobalName", palettePanel.GlobalName); } if (parentPanelCount > 1) { panelNode.SetOrAddValue("RelativeExtent", panel.InitialExtents.RelativeExtent); } } }
public void PersistWorkspaceLayout(DevDesktop.Frame.ApplicationWorkspace applicationWorkspace) { DevDesktop.Workspace.FreeWorkspaceLayout layout = null; DevCore.Settings.ApplicationSettings appSettings = default(DevCore.Settings.ApplicationSettings); // Bail out if we are resetting the workspace //if (_resettingWorkspace) //{ // return; //} // Get the current layout applicationWorkspace.TryGetCurrentLayout(ref layout); layout.ReIndex(); //Don't persist if the layout is empty if (layout.Areas.Count > 0) { // Get the application settings appSettings = DevCore.Application.Settings; DevCore.Settings.SettingsNode workspacesNode = default(DevCore.Settings.SettingsNode); workspacesNode = appSettings.Nodes.GetOrAdd("Workspaces"); workspacesNode.Location = "Workspaces\\User.index"; DevCore.Settings.SettingsNode workspaceNode = default(DevCore.Settings.SettingsNode); workspaceNode = workspacesNode.Nodes.GetOrAdd(layout.ModuleGuid.ToString()); workspaceNode.Location = string.Format("User.{0}", layout.ModuleName.ToLower()); workspaceNode.SetOrAddValue("WorkspaceName", layout.ModuleName); DevCore.Settings.SettingsNode namedLayoutNode = default(DevCore.Settings.SettingsNode); if (layout.HasLayoutName) { namedLayoutNode = workspaceNode.Nodes.GetOrAdd(layout.LayoutName); } else { namedLayoutNode = workspaceNode.Nodes.GetOrAdd("Default"); } // Clear any previous definitions namedLayoutNode.Values.Clear(); namedLayoutNode.Nodes.Clear(); int areaCounter = 0; int groupCounter = 0; foreach (DevDesktop.Workspace.FreeWorkspaceArea area in layout.Areas) { DevCore.Settings.SettingsNode areaNode = default(DevCore.Settings.SettingsNode); if (area.IsCanvasArea) { areaNode = namedLayoutNode.GetOrAddNode("area:canvas"); } else { areaCounter += 1; areaNode = namedLayoutNode.GetOrAddNode("area:" + areaCounter); areaNode.SetOrAddValue("RelativeExtent", area.InitialExtents.RelativeExtent); } areaNode.SetOrAddValue("Location", area.Location.ToString()); areaNode.SetOrAddValue("IsStacked", area.IsStacked); // Add the panels foreach (DevDesktop.Workspace.WorkspacePanelBase panel in area.Panels) { this.AddWorkspaceLayoutPanel(panel, areaNode, area.Panels.Count, ref groupCounter); } } } }