private void LayoutItems() { PART_ItemsHost.ColumnDefinitions.Clear(); for (int i = 0; i < Items.Count; i++) { PART_ItemsHost.ColumnDefinitions.Add(new ColumnDefinition()); DockedWindow item = Items[i] as DockedWindow; item.DockLocation = DockLocation; Grid.SetColumn(item, i); } if (_originalColumn == null) { _originalColumn = Grid.GetColumn(this); } if (_originalColumnSpan == null) { _originalColumnSpan = Grid.GetColumnSpan(this); } Grid.SetColumnSpan(this, (Parent as Grid).ColumnDefinitions.Count); Grid.SetColumn(this, 0); HorizontalAlignment = DockLocation == DockLocation.Right ? HorizontalAlignment.Right : HorizontalAlignment.Left; DoubleAnimation anim = new DoubleAnimation(HasItems ? 0 : ActualWidth, HasItems ? (_newItems[0] as DockedWindow).Width : 0, AnimationHelpers.AnimationDuration); anim.Completed += anim_Completed; anim.EasingFunction = AnimationHelpers.EasingFunction; BeginAnimation(WidthProperty, anim); }
private void DockContent_Loaded(object sender, RoutedEventArgs e) { object container = DockTarget.GetDockContainer(this); if (container is Window) { Window window = container as Window; window.Closed -= DockContent_Closed; window.Closed += DockContent_Closed; } else if (container is DockedWindow) { DockedWindow docked = container as DockedWindow; docked.Closed -= DockContent_Closed; docked.Closed += DockContent_Closed; } }
private void PART_Caption_MouseMove(object sender, MouseEventArgs e) { if (Mouse.Captured == PART_Caption) { Point MousePos = e.GetPosition(PART_Caption); Left += MousePos.X - DragStart.X; Top += MousePos.Y - DragStart.Y; foreach (DockTarget each in DockTarget.LiveDockTargets) { Point dockPos = Mouse.GetPosition(each); if ((each.DockLocation == DockLocation.Right && Math.Abs(dockPos.X - each.ActualWidth) < 2 && dockPos.Y >= 0 && dockPos.Y <= each.ActualHeight) || (each.DockLocation == DockLocation.Left && Math.Abs(dockPos.X) < 2 && dockPos.Y >= 0 && dockPos.Y <= each.ActualHeight)) { Mouse.Capture(null); DockedWindow docked = new DockedWindow(DragStart); docked.Width = DockedWidth; docked.UndockedWidth = ActualWidth; docked.UndockedHeight = ActualHeight; DockContent content = Content as DockContent; content.SuppressCloseEvent(); Content = null; docked.Content = content; if (each.DockLocation == DockLocation.Right) { each.Items.Add(docked); } else { each.Items.Insert(0, docked); } Close(); break; } } } }