public void AddTool2(TabModel item, Dock targetDock, GridLength defaultSize) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (item.Usage == TabItemType.Document) { throw new InvalidOperationException(); } var well = AllTabs.Where(t => (t.Parent as ToolWellModel)?.Dock == targetDock) .Select(t => t.Parent as ToolWellModel) .FirstOrDefault(); if (well == null) { well = new ToolWellModel { Dock = targetDock }; var branch = new SplitPanelModel(targetDock, well); well.PanelSize = defaultSize; var temp = content; Content = branch; branch.Add(temp); } well.Children.Add(item); well.SelectedItem = item; well.IsActive = true; }
public void AddTool(TabModel item, TabOwnerModelBase target, Dock dock) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var group = new ToolWellModel() { Width = item.Width, Height = item.Height, Dock = dock }; group.Children.Add(item); var container = new SplitPanelModel(dock, group); if (target == null) { target = Content; Content = container; } else if (target.ParentBranch != null) { target.ParentBranch.Replace(target, container); } else { System.Diagnostics.Debugger.Break(); throw new InvalidOperationException(); } container.Add(target); }
private void OuterDock(DockEventArgs e) { var groups = e.SourceContent.OfType <TabWellModelBase>().ToList(); var newGroup = new ToolWellModel() { Dock = (Dock)((int)e.TargetDock - 5) }; foreach (var group in groups) { var allChildren = group.Children.ToList(); foreach (var item in allChildren) { group.Children.Remove(item); item.IsPinned = false; item.IsActive = false; newGroup.Children.Add(item); } } var newSplit = new SplitPanelModel(); newSplit.Orientation = e.TargetDock == DockTarget.DockLeft || e.TargetDock == DockTarget.DockRight ? Orientation.Horizontal : Orientation.Vertical; if (ParentPanel.ParentBranch == null) { ParentContainer.Content = newSplit; } else { ParentPanel.ParentBranch.Replace(ParentPanel, newSplit); } if (e.TargetDock == DockTarget.DockTop || e.TargetDock == DockTarget.DockLeft) { newSplit.Item1 = newGroup; newSplit.Item2 = ParentPanel; newSplit.Item1.PanelSize = new GridLength(e.DesiredSize); } else { newSplit.Item1 = ParentPanel; newSplit.Item2 = newGroup; newSplit.Item2.PanelSize = new GridLength(e.DesiredSize); } newGroup.IsActive = true; newGroup.SelectedItem = newGroup.Children.First(); e.SourceWindow.Close(); }
protected override void DockExecuted(DockEventArgs e) { if (e.TargetDock == DockTarget.Center) { base.DockExecuted(e); return; } var groups = e.SourceContent.OfType <TabWellModelBase>().ToList(); var newGroup = new ToolWellModel() { Dock = Dock }; foreach (var group in groups) { var allChildren = group.Children.ToList(); foreach (var item in allChildren) { group.Children.Remove(item); item.IsPinned = false; item.IsActive = false; newGroup.Children.Add(item); } } var newSplit = new SplitPanelModel(); double remainingSize; if (e.TargetDock == DockTarget.SplitLeft || e.TargetDock == DockTarget.SplitRight) { newSplit.Orientation = Orientation.Horizontal; remainingSize = Width - e.DesiredSize; } else { newSplit.Orientation = Orientation.Vertical; remainingSize = Height - e.DesiredSize; } ParentBranch.Replace(this, newSplit); if (e.TargetDock == DockTarget.SplitTop || e.TargetDock == DockTarget.SplitLeft) { newSplit.Item1 = newGroup; newSplit.Item2 = this; newSplit.Item1.PanelSize = new GridLength(e.DesiredSize, GridUnitType.Star); newSplit.Item2.PanelSize = new GridLength(remainingSize, GridUnitType.Star); } else { newSplit.Item1 = this; newSplit.Item2 = newGroup; newSplit.Item1.PanelSize = new GridLength(remainingSize, GridUnitType.Star); newSplit.Item2.PanelSize = new GridLength(e.DesiredSize, GridUnitType.Star); } newGroup.IsActive = true; newGroup.SelectedItem = newGroup.Children.First(); e.SourceWindow.Close(); }