public void Restore(MainWindowControl mainWindowControl, MainWindowControl.ToolWindowUI ui)
        {
            if (Groups.Count == 0)
            {
                return;
            }

            var mgr = ui.ToolWindowGroupService;

            mgr.IsHorizontal = IsHorizontal;

            foreach (var gs in Groups)
            {
                if (gs.Contents.Count == 0)
                {
                    continue;
                }
                var g = mgr.Create();
                foreach (var cs in gs.Contents)
                {
                    mainWindowControl.TryAdd(ui, g, cs.Guid);
                }
                var cl = g.TabContents.ToList();
                if ((uint)gs.Index < (uint)cl.Count)
                {
                    g.ActiveTabContent = cl[gs.Index];
                }
                else if (cl.Count > 0)
                {
                    g.ActiveTabContent = cl[0];
                }
            }
            mainWindowControl.Show(ui);

            var groups = mgr.TabGroups.ToList();

            if ((uint)Index < (uint)groups.Count)
            {
                mgr.ActiveTabGroup = groups[Index];
            }
            else if (groups.Count > 0)
            {
                mgr.ActiveTabGroup = groups[0];
            }
            ((ToolWindowGroupService)mgr).StackedContentState = this.StackedContentState;
            foreach (var g in groups)
            {
                if (!g.TabContents.Any())
                {
                    mgr.Close(g);
                }
            }
        }
Exemple #2
0
        public ToolWindowUIState Save(AppToolWindowLocation location, MainWindowControl.ToolWindowUI ui)
        {
            this.Location            = location;
            this.StackedContentState = ((ToolWindowGroupManager)ui.ToolWindowGroupManager).StackedContentState;
            var groups = ui.ToolWindowGroupManager.TabGroups.ToList();

            this.Index        = groups.IndexOf(ui.ToolWindowGroupManager.ActiveTabGroup);
            this.IsHorizontal = ui.ToolWindowGroupManager.IsHorizontal;
            foreach (var g in groups)
            {
                Groups.Add(new ToolWindowGroupState().Save(g));
            }
            return(this);
        }