private void DockContainer_Unloaded(object sender, RoutedEventArgs e) { DockManager.Unregister(this); }
private void DocumentContainer_Loaded(object sender, RoutedEventArgs e) { DockManager.Register(this); }
private IEnumerable <UIElement> GetItemsOnRow(Size constraint, int rowIndex) { var host = GetAncestorControl(); int rowNum = 0; double currentOffset = 0; var pinned = InternalChildren.OfType <UIElement>().Where(t => DockManager.GetIsPinned(t)); var notPinned = InternalChildren.OfType <UIElement>().Except(pinned); foreach (var item in pinned) { if (currentOffset > 0 && currentOffset + item.DesiredSize.Width > constraint.Width) { currentOffset = 0; rowNum++; } currentOffset += item.DesiredSize.Width; if (rowNum == rowIndex) { yield return(item); } } if (pinned.Any() && host?.PinOnSeparateRow == true) { rowNum++; currentOffset = 0; } foreach (var item in notPinned) { if (currentOffset > 0 && currentOffset + item.DesiredSize.Width > constraint.Width) { if (host != null) { SetHasOverflowItems(host, true); } if (rowIndex == -1) { yield return(item); continue; } else { yield break; } } currentOffset += item.DesiredSize.Width; if (rowNum == rowIndex) { yield return(item); } } if (host != null) { SetHasOverflowItems(host, false); } }
private void PinTabCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var container = (e.OriginalSource as FrameworkElement)?.FindVisualAncestor <TabItem>(); DockManager.SetIsPinned(container, !DockManager.GetIsPinned(container)); }
protected override void OnPreviewMouseDown(MouseButtonEventArgs e) { DockManager.SetIsActive(this, true); base.OnPreviewMouseDown(e); }
private void TabWellBase_Unloaded(object sender, RoutedEventArgs e) { DockManager.Unregister(this); }
//internal command - OriginalSource is TabWellItem, Parameter is MouseEventArgs private void TabMouseMoveCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var tab = (TabWellItem)e.OriginalSource; var mouseArgs = (MouseEventArgs)e.Parameter; if (!tab.IsMouseCaptured || !tab.IsLoaded) { return; } var item = ItemContainerGenerator.ItemFromContainer(tab); var index = Items.IndexOf(item); var pos = mouseArgs.GetPosition(tab); var offset = mouseArgs.GetPosition(this); var floatBounds = new Rect( pos.X - offset.X, -floatThreshold, this.ActualWidth, tab.ActualHeight + floatThreshold * 2 ); if (!floatBounds.Contains(pos)) { var args = new FloatEventArgs(this, tab, mouseArgs); tab.ReleaseMouseCapture(); DockManager.SetIsPinned(tab, false); FloatTabCommand?.TryExecute(args); return; } if (pos.X > 0 && pos.X < tab.ActualWidth) { swapThreshold = 0; } var isPinned = DockManager.GetIsPinned(tab); var grouped = Items.OfType <object>() .Select(i => ItemContainerGenerator.ContainerFromItem(i)) .Where(c => DockManager.GetIsPinned(c) == isPinned); var collection = ItemsSource as IList ?? Items as IList; if (pos.X < -swapThreshold && index > 0) { var prevTab = grouped.TakeWhile(c => c != tab).LastOrDefault() as FrameworkElement; if (prevTab != null) { swapThreshold = (int)Math.Ceiling(Math.Max(0, prevTab.ActualWidth - tab.ActualWidth)); floatThreshold = maxFloatThreshold; collection.Remove(item); collection.Insert(index - 1, item); tab = (TabWellItem)ItemContainerGenerator.ContainerFromIndex(index - 1); } } else if (pos.X > tab.ActualWidth + swapThreshold && index < Items.Count - 1) { var nextTab = grouped.SkipWhile(c => c != tab).Skip(1).FirstOrDefault() as FrameworkElement; if (nextTab != null) { swapThreshold = (int)Math.Ceiling(Math.Max(0, nextTab.ActualWidth - tab.ActualWidth)); floatThreshold = maxFloatThreshold; collection.Remove(item); collection.Insert(index + 1, item); tab = (TabWellItem)ItemContainerGenerator.ContainerFromIndex(index + 1); } } SelectedItem = item; tab.CaptureMouse(); }
private void TabWellItem_Loaded(object sender, RoutedEventArgs e) { DockManager.Register(this); }