public void Activate(ZWindow window) { if (window == null) { throw new ArgumentNullException("window"); } activeWindow = window; }
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); } }
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); } }
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); }
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); } }