Example #1
0
        public DevDesktop.Workspace.WorkspacePanelBase AddPanelToWorkspace(DevCore.Settings.SettingsNode panelNode)
        {
            DevDesktop.Workspace.WorkspaceLayoutGroup  layoutGroup      = default(DevDesktop.Workspace.WorkspaceLayoutGroup);
            DevDesktop.Workspace.WorkspacePanelBase    layoutPanel      = default(DevDesktop.Workspace.WorkspacePanelBase);
            DevDesktop.Workspace.WorkspacePalettePanel layoutPalette    = default(DevDesktop.Workspace.WorkspacePalettePanel);
            DevCore.Settings.SettingsGuidValue         paletteGuidValue = null;


            if (panelNode.Key.StartsWith("group:"))
            {
                // Create the layout group
                layoutGroup = new DevDesktop.Workspace.WorkspaceLayoutGroup(panelNode.GetIntegerValue("RelativeExtent", 100).Value);

                layoutGroup.IsTabbed = panelNode.GetBooleanValue("IsTabbed", false).Value;


                foreach (DevCore.Settings.SettingsNode groupPanelNode in panelNode.Nodes)
                {
                    layoutPanel = this.AddPanelToWorkspace(groupPanelNode);

                    if (layoutPanel != null)
                    {
                        layoutGroup.Panels.Add(layoutPanel);
                    }
                }

                // Return the group
                return(layoutGroup);
            }
            else
            {
                if (panelNode.TryGetGuidValue("PaletteGuid", ref paletteGuidValue))
                {
                    layoutPalette = new DevDesktop.Workspace.WorkspacePalettePanel(panelNode.GetIntegerValue("RelativeExtent", 100).Value, paletteGuidValue.Value, panelNode.GetStringValue("GlobalName", string.Empty).Value);

                    GetConfigurationFromSettings(panelNode).Copy(layoutPalette.PaletteConfiguration);

                    return(layoutPalette);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #2
0
        public DevDesktop.Workspace.FreeWorkspaceLayout GetWorkspaceLayout(Guid workspaceGuid, string workspaceLayoutName)
        {
            DevDesktop.Workspace.FreeWorkspaceLayout layout           = null;
            DevCore.Settings.SettingsGuidValue       paletteGuidValue = null;
            DevCore.Settings.SettingsNode            workspaceNode    = null;
            DevCore.Settings.ApplicationSettings     appSettings      = default(DevCore.Settings.ApplicationSettings);
            bool isCanvas  = false;
            bool isStacked = false;

            appSettings = DevCore.Application.Settings;
            //// Resolve the layout name
            //if (!e.WorkspaceConfiguration.TryGetValue("LAYOUTNAME", e.WorkspaceLayoutName))
            //{
            //    e.WorkspaceLayoutName = "Default";
            //}

            // Resolve the stored layout

            if (appSettings.TryGetNode(string.Format("Workspaces\\{0}\\{1}", workspaceGuid, workspaceLayoutName), ref workspaceNode))
            {
                if (workspaceNode.Nodes.Count > 0)
                {
                    layout = new DevDesktop.Workspace.FreeWorkspaceLayout(workspaceGuid, workspaceNode.GetStringValue("WorkspaceName", string.Empty).Value);


                    foreach (DevCore.Settings.SettingsNode areaNode in workspaceNode.Nodes)
                    {
                        DevDesktop.Workspace.FreeWorkspaceArea         layoutArea  = default(DevDesktop.Workspace.FreeWorkspaceArea);
                        DevDesktop.Workspace.WorkspacePanelBase        layoutPanel = default(DevDesktop.Workspace.WorkspacePanelBase);
                        DevDesktop.Workspace.WorkspaceComponentExtents extents     = default(DevDesktop.Workspace.WorkspaceComponentExtents);
                        DevDesktop.Workspace.WorkspaceAreaLocation     location    = default(DevDesktop.Workspace.WorkspaceAreaLocation);

                        // Do we have the canvas area?
                        if (areaNode.Key == "area:canvas")
                        {
                            isCanvas = true;
                        }
                        else
                        {
                            isCanvas = false;
                        }

                        // Do we have a stacked area
                        isStacked = areaNode.GetBooleanValue("IsStacked", false).Value;

                        // Resolve the extents
                        if (isCanvas)
                        {
                            extents = new DevDesktop.Workspace.WorkspaceComponentExtents(0);
                        }
                        else
                        {
                            extents = new DevDesktop.Workspace.WorkspaceComponentExtents(areaNode.GetIntegerValue("RelativeExtent", 100).Value);
                        }

                        // Resolve the location
                        switch (areaNode.GetStringValue("Location", string.Empty).Value)
                        {
                        case "Left":
                            location = DevDesktop.Workspace.WorkspaceAreaLocation.Left;
                            break;

                        case "Right":
                            location = DevDesktop.Workspace.WorkspaceAreaLocation.Right;
                            break;

                        case "Bottom":
                            location = DevDesktop.Workspace.WorkspaceAreaLocation.Bottom;
                            break;

                        case "Top":
                            location = DevDesktop.Workspace.WorkspaceAreaLocation.Top;
                            break;

                        default:
                            location = DevDesktop.Workspace.WorkspaceAreaLocation.Undefined;
                            break;
                        }

                        layoutArea = new DevDesktop.Workspace.FreeWorkspaceArea(extents, location);
                        layout.AddArea(layoutArea, isCanvas, isStacked);

                        // Add the panels to the area

                        foreach (DevCore.Settings.SettingsNode panelNode in areaNode.Nodes)
                        {
                            layoutPanel = this.AddPanelToWorkspace(panelNode);

                            if (layoutPanel != null)
                            {
                                layoutArea.Panels.Add(layoutPanel);
                            }
                        }
                    }
                }
            }
            return(layout);
        }