internal void SetWindowParent(ZPairWindow windowParent) { this.windowParent = windowParent; }
public ZWindow Open( ZWindowType windowType, ZWindow split = null, ZWindowPosition position = ZWindowPosition.Left, ZWindowSizeType sizeType = ZWindowSizeType.Fixed, int size = 0) { if (windowType == ZWindowType.Pair) { throw new InvalidOperationException("ZWindows of type Pair cannot be created directly."); } if (root == null) { if (split != null) { throw new ArgumentException("'split' must be null if Root has not yet been created.", "split"); } root = CreateNewWindow(windowType); return(root); } else { if (split == null) { throw new ArgumentNullException("split", "'split' cannot be null if the Root has already been created."); } var newWindow = CreateNewWindow(windowType); var parent = split.WindowParent; GridLength splitSize; switch (sizeType) { case ZWindowSizeType.Fixed: var pixels = position == ZWindowPosition.Above || position == ZWindowPosition.Below ? size * newWindow.RowHeight : size * newWindow.ColumnWidth; splitSize = new GridLength(pixels, GridUnitType.Pixel); break; case ZWindowSizeType.Proportional: splitSize = new GridLength((double)size / 100, GridUnitType.Star); break; default: throw new ArgumentException("Invalid ZWindowSizeType: " + sizeType, "sizeType"); } var parentGrid = (Grid)split.Parent; parentGrid.Children.Remove(split); var newPair = new ZPairWindow(this, split, newWindow, position, splitSize); if (parent != null) { parent.Replace(split, newPair); } else { root = newPair; } parentGrid.Children.Add(newPair); return(newWindow); } }