public void SetParentWindow(ZPairWindow newParentWindow) { this.parentWindow = newParentWindow; }
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); }
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; }