Пример #1
0
        public void CloseWindow(ZWindow window)
        {
            var parentGrid = (Grid)window.Parent;
            parentGrid.Children.Remove(window);

            var parent = window.ParentWindow;
            if (parent == null) // root window
            {
                this.rootWindow = null;
            }
            else
            {
                var sibling = parent.Child1 == window
                    ? parent.Child2
                    : parent.Child1;

                parentGrid.Children.Remove(sibling);

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

                var grandParent = parent.ParentWindow;
                if (grandParent == null) // root window
                {
                    this.rootWindow = sibling;
                    sibling.SetParentWindow(null);
                }
                else
                {
                    grandParent.Replace(parent, sibling);
                }

                grandParent.Children.Add(sibling);
            }
        }
Пример #2
0
        public ZPairWindow(
            ZWindowManager manager,
            FontAndColorService fontAndColorService,
            ZWindow child1,
            ZWindow child2,
            ZWindowPosition child2Position,
            GridLength child2Size)
            : base(manager, fontAndColorService)
        {
            this.child1 = child1;
            this.child2 = child2;

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

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

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

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

            child1.SetParentWindow(this);
            child2.SetParentWindow(this);

            this.Children.Add(child1);
            this.Children.Add(child2);
        }
Пример #3
0
 public void Replace(ZWindow child, ZWindow newChild)
 {
     if (this.child1.Equals(child))
     {
         this.child1 = newChild;
         this.child1.SetParentWindow(null);
         this.Children[0] = newChild;
         newChild.SetParentWindow(this);
     }
     else if (this.child2.Equals(child))
     {
         this.child2 = newChild;
         this.child2.SetParentWindow(null);
         this.Children[0] = newChild;
         newChild.SetParentWindow(this);
     }
 }
Пример #4
0
        public ZPairWindow(
            ZWindowManager manager,
            FontAndColorService fontAndColorService,
            ZWindow child1,
            ZWindow child2,
            ZWindowPosition child2Position,
            GridLength child2Size)
            : base(manager, fontAndColorService)
        {
            this.child1 = child1;
            this.child2 = child2;

            switch (child2Position)
            {
                case ZWindowPosition.Left:
                    this.ColumnDefinitions.Add(new ColumnDefinition { Width = child2Size });
                    this.ColumnDefinitions.Add(new ColumnDefinition());
                    SetColumn(this.child1, 1);
                    SetColumn(this.child2, 0);
                    break;
                case ZWindowPosition.Right:
                    this.ColumnDefinitions.Add(new ColumnDefinition());
                    this.ColumnDefinitions.Add(new ColumnDefinition { Width = child2Size });
                    SetColumn(this.child1, 0);
                    SetColumn(this.child2, 1);
                    break;
                case ZWindowPosition.Above:
                    this.RowDefinitions.Add(new RowDefinition { Height = child2Size });
                    this.RowDefinitions.Add(new RowDefinition());
                    SetRow(this.child1, 1);
                    SetRow(this.child2, 0);
                    break;
                case ZWindowPosition.Below:
                    this.RowDefinitions.Add(new RowDefinition());
                    this.RowDefinitions.Add(new RowDefinition { Height = child2Size });
                    SetRow(this.child1, 0);
                    SetRow(this.child2, 1);
                    break;
            }

            child1.SetParentWindow(this);
            child2.SetParentWindow(this);

            this.Children.Add(child1);
            this.Children.Add(child2);
        }
Пример #5
0
 public void Replace(ZWindow child, ZWindow newChild)
 {
     if (this.child1.Equals(child))
     {
         this.child1 = newChild;
         this.child1.SetParentWindow(null);
         this.Children[0] = newChild;
         newChild.SetParentWindow(this);
     }
     else if (this.child2.Equals(child))
     {
         this.child2 = newChild;
         this.child2.SetParentWindow(null);
         this.Children[0] = newChild;
         newChild.SetParentWindow(this);
     }
 }
Пример #6
0
        public void CloseWindow(ZWindow window)
        {
            var parentGrid = (Grid)window.Parent;

            parentGrid.Children.Remove(window);

            var parent = window.ParentWindow;

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

                parentGrid.Children.Remove(sibling);

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

                var grandParent = parent.ParentWindow;
                if (grandParent == null) // root window
                {
                    this.rootWindow = sibling;
                    sibling.SetParentWindow(null);
                }
                else
                {
                    grandParent.Replace(parent, sibling);
                }

                grandParent.Children.Add(sibling);
            }
        }
Пример #7
0
        public ZWindow OpenWindow(
            ZWindowKind kind,
            ZWindow splitWindow      = null,
            ZWindowPosition position = ZWindowPosition.Left,
            ZWindowSizeKind sizeKind = ZWindowSizeKind.Fixed,
            int size = 0)
        {
            if (kind == ZWindowKind.Pair)
            {
                throw new InvalidOperationException("ZPairWindows can't be creatted directly");
            }

            if (rootWindow == null && splitWindow != null)
            {
                throw new InvalidOperationException("Cannot open a split window if the root window has not yet been created.");
            }

            if (rootWindow != null && splitWindow == null)
            {
                throw new InvalidOperationException("Cannot open a new root window if the root window has already bee created.");
            }

            var newWindow = CreateNewWindow(kind);

            if (rootWindow == null)
            {
                rootWindow = newWindow;
            }
            else
            {
                GridLength splitSize;
                switch (sizeKind)
                {
                case ZWindowSizeKind.Fixed:
                    var pixels = IsVertical(position)
                            ? size * newWindow.RowHeight
                            : size * newWindow.ColumnWidth;
                    splitSize = new GridLength(pixels, GridUnitType.Pixel);
                    break;

                case ZWindowSizeKind.Proportional:
                    splitSize = new GridLength(size / 100.0, GridUnitType.Star);
                    break;

                default:
                    throw new InvalidOperationException("Invalid size kind: " + sizeKind.ToString());
                }

                Debug.Assert(splitWindow != null, "splitWindow != null");

                var parentGrid = (Grid)splitWindow.Parent;
                parentGrid.Children.Remove(splitWindow);

                var oldParentWindow = splitWindow.ParentWindow as ZPairWindow;
                var newParentWindow = new ZPairWindow(this, this.fontAndColorService, splitWindow, newWindow, position, splitSize);

                if (oldParentWindow != null)
                {
                    oldParentWindow.Replace(splitWindow, newParentWindow);
                }
                else
                {
                    rootWindow = newParentWindow;
                }

                parentGrid.Children.Add(newParentWindow);
            }

            return(newWindow);
        }
Пример #8
0
 public void ActivateWindow(ZWindow window)
 {
     this.activeWindow = window;
 }
Пример #9
0
        public ZWindow OpenWindow(
            ZWindowKind kind,
            ZWindow splitWindow = null,
            ZWindowPosition position = ZWindowPosition.Left,
            ZWindowSizeKind sizeKind = ZWindowSizeKind.Fixed,
            int size = 0)
        {
            if (kind == ZWindowKind.Pair)
            {
                throw new InvalidOperationException("ZPairWindows can't be creatted directly");
            }

            if (rootWindow == null && splitWindow != null)
            {
                throw new InvalidOperationException("Cannot open a split window if the root window has not yet been created.");
            }

            if (rootWindow != null && splitWindow == null)
            {
                throw new InvalidOperationException("Cannot open a new root window if the root window has already bee created.");
            }

            var newWindow = CreateNewWindow(kind);

            if (rootWindow == null)
            {
                rootWindow = newWindow;
            }
            else
            {
                GridLength splitSize;
                switch (sizeKind)
                {
                    case ZWindowSizeKind.Fixed:
                        var pixels = IsVertical(position)
                            ? size * newWindow.RowHeight
                            : size * newWindow.ColumnWidth;
                        splitSize = new GridLength(pixels, GridUnitType.Pixel);
                        break;
                    case ZWindowSizeKind.Proportional:
                        splitSize = new GridLength(size / 100.0, GridUnitType.Star);
                        break;
                    default:
                        throw new InvalidOperationException("Invalid size kind: " + sizeKind.ToString());
                }

                Debug.Assert(splitWindow != null, "splitWindow != null");

                var parentGrid = (Grid)splitWindow.Parent;
                parentGrid.Children.Remove(splitWindow);

                var oldParentWindow = splitWindow.ParentWindow as ZPairWindow;
                var newParentWindow = new ZPairWindow(this, this.fontAndColorService, splitWindow, newWindow, position, splitSize);

                if (oldParentWindow != null)
                {
                    oldParentWindow.Replace(splitWindow, newParentWindow);
                }
                else
                {
                    rootWindow = newParentWindow;
                }

                parentGrid.Children.Add(newParentWindow);
            }

            return newWindow;
        }
Пример #10
0
 public void ActivateWindow(ZWindow window)
 {
     this.activeWindow = window;
 }