Ejemplo n.º 1
0
        public void StorePanelLayout(Dictionary <string, Control> modules, string filename)
        {
            var moduleNames = modules.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
            var layout      = new PanelLayout();

            foreach (var floatPanel in Application.OpenForms.OfType <FloatPanel>().Where(p => p.Visible))
            {
                // TODO: Maintain a list of all FloatPanels handled by this LayoutHandler
                var panelLayout = new StoredFloatPanel
                {
                    Width  = floatPanel.Width,
                    Height = floatPanel.Height,
                    Left   = floatPanel.Left,
                    Top    = floatPanel.Top
                };
                layout.FloatPanels.Add(panelLayout);
                AddPanelNamesToGroup(moduleNames, floatPanel.ChildPanel, panelLayout.Panels);
            }
            foreach (var container in DockContainers)
            {
                var splitLayout = new StoredSplitPanelLayout
                {
                    Name = container.Name,
                    Size = (container.Horizontal ? container.Height : container.Width) + 2
                };
                layout.SplitPanels.Add(splitLayout);
                for (var i = 0; i < container.Panels.Count; i++)
                {
                    var group = new PanelGroup {
                        Size = container.Splits[i]
                    };
                    splitLayout.PanelGroups.Add(group);
                    AddPanelNamesToGroup(moduleNames, container.Panels[i].ContainedControl as IdePanel, group.Panels);
                }
            }

            try
            {
                var parentPath = Directory.GetParent(filename);
                if (!parentPath.Exists)
                {
                    parentPath.Create();
                }
                var xmlDocument = new XmlDocument();
                var serializer  = new XmlSerializer(typeof(PanelLayout));
                using (var stream = new MemoryStream())
                {
                    serializer.Serialize(stream, layout);
                    stream.Position = 0;
                    xmlDocument.Load(stream);
                    xmlDocument.Save(filename);
                }
            }
            catch (Exception ex)
            {
                Program.Error("Error saving layout: " + ex.Message, ex);
            }
        }
Ejemplo n.º 2
0
        private PanelLayout GetDefaultLayout()
        {
            var layout = new PanelLayout();

            layout.SplitPanels.AddRange(new[]
            {
                new StoredSplitPanelLayout
                {
                    Name        = "west",
                    Size        = 250,
                    PanelGroups = new []
                    {
                        new PanelGroup {
                            Panels = new [] { "Project Explorer" }.ToList()
                        },
                        new PanelGroup {
                            Panels = new [] { "Opcodes", "Commands", "Number Formats" }.ToList()
                        }
                    }.ToList()
                },
                new StoredSplitPanelLayout
                {
                    Name        = "south",
                    Size        = 250,
                    PanelGroups = new []
                    {
                        new PanelGroup {
                            Panels = new [] { "Output", "Build Errors" }.ToList()
                        },
                        new PanelGroup {
                            Panels = new [] { "Watch", "Breakpoints" }.ToList()
                        },
                        new PanelGroup {
                            Panels = new [] { "Memory Viewer", "Sprite List" }.ToList()
                        }
                    }.ToList()
                },
                new StoredSplitPanelLayout
                {
                    Name        = "east",
                    Size        = 300,
                    PanelGroups = new []
                    {
                        new PanelGroup {
                            Panels = new [] { "Chr", "Nametables", "Sprites", "Palette" }.ToList()
                        },
                        new PanelGroup {
                            Panels = new [] { "Console Status" }.ToList()
                        },
                        new PanelGroup {
                            Panels = new [] { "Mesen" }.ToList()
                        }
                    }.ToList()
                }
            });
            return(layout);
        }