示例#1
0
        private void WriteDock(IDock root, string indent = "")
        {
            string id = $"view{_viewCount}";

            _viewCount++;

            if (!_idViews.ContainsKey(root))
            {
                _idViews[root] = id;
            }

            Output($"{indent}var {id} = new {root.GetType().Name}()");
            Output($"{indent}{{");
            Output($"{indent}    Id = \"{root.Id}\",");
            Output($"{indent}    Title = \"{root.Title}\",");
            Output($"{indent}    Proportion = {FormatDouble(root.Proportion)},");
            Output($"{indent}    IsActive = {FormatBool(root.IsActive)},");
            Output($"{indent}    IsCollapsable = {FormatBool(root.IsCollapsable)},");

            if (root is ILayoutDock layoutDock)
            {
                Output($"{indent}    Orientation = Orientation.{layoutDock.Orientation},");
            }

            //if (root is IRootDock rootDock)
            //{
            //    WriteWindow(rootDock.Window, indent);
            //}

            Output($"{indent}}};");

            if (root.Views != null)
            {
                foreach (var view in root.Views)
                {
                    if (view is IDock dock)
                    {
                        WriteDock(dock, indent);
                    }
                    else
                    {
                        WriteView(view, indent);
                    }
                }
            }

            if (root.Windows != null)
            {
                foreach (var window in root.Windows)
                {
                    WriteWindow(window, indent);
                }
            }
        }
示例#2
0
        private void WriteDock(IDock root, string indent = "")
        {
            string id = $"view{_viewCount}";

            _viewCount++;

            if (!_idViews.ContainsKey(root))
            {
                _idViews[root] = id;
            }

            Output($"{indent}var {id} = new {root.GetType().Name}()");
            Output($"{indent}{{");
            Output($"{indent}    Id = \"{root.Id}\",");
            Output($"{indent}    Width = {FormatDouble(root.Width)},");
            Output($"{indent}    Height = {FormatDouble(root.Height)},");
            Output($"{indent}    Title = \"{root.Title}\",");
            Output($"{indent}    Dock = \"{root.Dock}\",");
            Output($"{indent}}};");

            if (root.Views != null)
            {
                foreach (var view in root.Views)
                {
                    if (view is IDock dock)
                    {
                        WriteDock(dock, indent);
                    }
                    else
                    {
                        WriteView(view, indent);
                    }
                }
            }

            if (root.Windows != null)
            {
                foreach (var window in root.Windows)
                {
                    WriteWindow(window, indent);
                }
            }
        }
示例#3
0
        public static bool Equal(IDock dock1, IDock dock2)
        {
            if (dock1.GetType() != dock2.GetType())
            {
                return(false);
            }
            if (dock1.Id != dock2.Id)
            {
                return(false);
            }

            if (!Enumerable.SequenceEqual(dock1.VisibleDockables, dock2.VisibleDockables, dockableComparer))
            {
                return(false);
            }
            if (!Enumerable.SequenceEqual(dock1.HiddenDockables, dock2.HiddenDockables, dockableComparer))
            {
                return(false);
            }
            if (dock1.PinnedDockables != null && dock2.PinnedDockables != null)
            {
                if (!Enumerable.SequenceEqual(dock1.PinnedDockables, dock2.PinnedDockables, dockableComparer))
                {
                    return(false);
                }
            }
            if (!Equal(dock1.ActiveDockable, dock2.ActiveDockable))
            {
                return(false);
            }
            if (!Equal(dock1.FocusedDockable, dock2.FocusedDockable))
            {
                return(false);
            }
            if (dock1.IsActive != dock2.IsActive)
            {
                return(false);
            }

            return(true);
        }