Exemplo n.º 1
0
 public void Replace(ZWindow child, ZWindow newChild)
 {
     if (child1 == child)
     {
         child1           = newChild;
         this.Children[0] = newChild;
         newChild.SetWindowParent(this);
     }
     else if (child2 == child)
     {
         child2           = newChild;
         this.Children[1] = newChild;
         newChild.SetWindowParent(this);
     }
 }
Exemplo n.º 2
0
        public void Close(ZWindow window)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            var parentGrid = (Grid)window.Parent;

            parentGrid.Children.Remove(window);

            var parent = window.WindowParent;

            if (parent == null) // root window...
            {
                root = null;
            }
            else
            {
                ZWindow sibling = parent.Child1 == window
                    ? parent.Child2
                    : parent.Child1;

                parentGrid.Children.Remove(sibling);

                var grandparentGrid = (Grid)parent.Parent;
                grandparentGrid.Children.Remove(parent);

                var grandParent = parent.WindowParent;
                if (grandParent == null) // root window...
                {
                    root = sibling;
                    sibling.SetWindowParent(null);
                }
                else
                {
                    grandParent.Replace(parent, sibling);
                }

                grandparentGrid.Children.Add(sibling);
            }
        }
Exemplo n.º 3
0
        internal ZPairWindow(ZWindowManager manager, ZWindow child1, ZWindow child2, ZWindowPosition child2Position, GridLength child2Size)
            : base(manager)
        {
            if (child1 == null)
            {
                throw new ArgumentNullException("child1");
            }

            if (child2 == null)
            {
                throw new ArgumentNullException("child2");
            }

            this.child1 = child1;
            this.child2 = child2;

            switch (child2Position)
            {
            case ZWindowPosition.Left:
            {
                var col1 = new ColumnDefinition();
                col1.Width = child2Size;
                var col2 = new ColumnDefinition();
                this.ColumnDefinitions.Add(col1);
                this.ColumnDefinitions.Add(col2);
                Grid.SetColumn(child2, 0);
                Grid.SetColumn(child1, 1);
                break;
            }

            case ZWindowPosition.Right:
            {
                var col1 = new ColumnDefinition();
                var col2 = new ColumnDefinition();
                col2.Width = child2Size;
                this.ColumnDefinitions.Add(col1);
                this.ColumnDefinitions.Add(col2);
                Grid.SetColumn(child1, 0);
                Grid.SetColumn(child2, 1);
                break;
            }

            case ZWindowPosition.Above:
            {
                var row1 = new RowDefinition();
                row1.Height = child2Size;
                var row2 = new RowDefinition();
                this.RowDefinitions.Add(row1);
                this.RowDefinitions.Add(row2);
                Grid.SetRow(child2, 0);
                Grid.SetRow(child1, 1);
                break;
            }

            case ZWindowPosition.Below:
            {
                var row1 = new RowDefinition();
                var row2 = new RowDefinition();
                row2.Height = child2Size;
                this.RowDefinitions.Add(row1);
                this.RowDefinitions.Add(row2);
                Grid.SetRow(child1, 0);
                Grid.SetRow(child2, 1);
                break;
            }

            default:
                throw new ArgumentException("Invalid ZWindowPosition: " + child2Position, "child2Position");
            }

            child1.SetWindowParent(this);
            child2.SetWindowParent(this);

            this.Children.Add(child1);
            this.Children.Add(child2);
        }