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 SplitViewModel(); newSplit.Orientation = e.TargetDock == DockTarget.DockLeft || e.TargetDock == DockTarget.DockRight ? Orientation.Horizontal : Orientation.Vertical; if (ParentModel == null) { ParentViewModel.Content = newSplit; } else { ParentModel.Replace(Parent, newSplit); } if (e.TargetDock == DockTarget.DockTop || e.TargetDock == DockTarget.DockLeft) { newSplit.Item1 = newGroup; newSplit.Item2 = Parent; newSplit.Item1Size = new GridLength(e.DesiredSize); } else { newSplit.Item1 = Parent; newSplit.Item2 = newGroup; newSplit.Item2Size = new GridLength(e.DesiredSize); } newGroup.IsActive = true; newGroup.SelectedItem = newGroup.Children.First(); e.SourceWindow.Close(); }
private void OnItemChanged(ModelBase prev, ModelBase next) { prev?.SetParent(null, null); next?.SetParent(this, ParentViewModel); if (next == null) { var remaining = Item1 ?? Item2; if (remaining == null) { return; } Item1 = Item2 = null; if (ParentModel != null) { ParentModel.Replace(this, remaining); } else if (ParentViewModel != null) { ParentViewModel.Content = remaining; } } }
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 SplitViewModel(); 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; } ParentModel.Replace(this, newSplit); if (e.TargetDock == DockTarget.SplitTop || e.TargetDock == DockTarget.SplitLeft) { newSplit.Item1 = newGroup; newSplit.Item2 = this; newSplit.Item1Size = new GridLength(e.DesiredSize, GridUnitType.Star); newSplit.Item2Size = new GridLength(remainingSize, GridUnitType.Star); } else { newSplit.Item1 = this; newSplit.Item2 = newGroup; newSplit.Item1Size = new GridLength(remainingSize, GridUnitType.Star); newSplit.Item2Size = new GridLength(e.DesiredSize, GridUnitType.Star); } newGroup.IsActive = true; newGroup.SelectedItem = newGroup.Children.First(); e.SourceWindow.Close(); }