public override void OnApplyTemplate() { if (_templateSubscription != null) { _templateSubscription.Dispose(); } _templateSubscription = Disposable.Empty; _dragablzItemsControl = GetTemplateChild(HeaderItemsControlPartName) as DragablzItemsControl; if (_dragablzItemsControl != null) { _dragablzItemsControl.ItemContainerGenerator.StatusChanged += ItemContainerGeneratorOnStatusChanged; _templateSubscription = Disposable.Create( () => _dragablzItemsControl.ItemContainerGenerator.StatusChanged -= ItemContainerGeneratorOnStatusChanged); if (_dragablzItemsControl.ItemContainerStyleSelector == null) { _dragablzItemsControl.ItemContainerStyleSelector = new TabablzItemStyleSelector(DefaultHeaderItemStyle, CustomHeaderItemStyle); } } if (SelectedItem == null) { SetCurrentValue(SelectedItemProperty, Items.OfType <object>().FirstOrDefault()); } _itemsHolder = GetTemplateChild(ItemsHolderPartName) as Panel; UpdateSelectedItem(); MarkInitialSelection(); base.OnApplyTemplate(); }
public virtual void OrganiseOnDrag(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem) { if (siblingItems == null) { throw new ArgumentNullException(nameof(siblingItems)); } if (dragItem == null) { throw new ArgumentNullException(nameof(dragItem)); } var currentLocations = siblingItems .Select(GetLocationInfo) .Union(new[] { GetLocationInfo(dragItem) }) .OrderBy(loc => loc.Item == dragItem ? loc.Start : _siblingItemLocationOnDragStart[loc.Item].Start); var currentCoord = 0.0; var zIndex = int.MaxValue; foreach (var location in currentLocations) { if (!Equals(location.Item, dragItem)) { SendToLocation(location.Item, currentCoord); Panel.SetZIndex(location.Item, --zIndex); } currentCoord += _getDesiredSize(location.Item) + _itemOffset; } Panel.SetZIndex(dragItem, int.MaxValue); }
public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem) { if (siblingItems == null) { throw new ArgumentNullException("siblingItems"); } var currentLocations = siblingItems .Select(GetLocationInfo) .Union(new[] { GetLocationInfo(dragItem) }) .OrderBy(loc => loc.Item == dragItem ? loc.Start : _siblingItemLocationOnDragStart[loc.Item].Start); var currentCoord = 0.0; var z = int.MaxValue; var logicalIndex = 0; foreach (var location in currentLocations) { SetLocation(location.Item, currentCoord); currentCoord += _getDesiredSize(location.Item) + _itemOffset; Panel.SetZIndex(location.Item, --z); location.Item.LogicalIndex = logicalIndex++; } Panel.SetZIndex(dragItem, int.MaxValue); }
public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List <DragablzItem> siblingItems, DragablzItem dragablzItem) { var zIndex = int.MaxValue; foreach (var source in siblingItems.OrderByDescending(Panel.GetZIndex)) { Panel.SetZIndex(source, --zIndex); } Panel.SetZIndex(dragablzItem, int.MaxValue); }
public void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List<DragablzItem> siblingItems, DragablzItem dragablzItem) { var zIndex = int.MaxValue; foreach (var source in siblingItems.OrderByDescending(Panel.GetZIndex)) { Panel.SetZIndex(source, --zIndex); } Panel.SetZIndex(dragablzItem, int.MaxValue); }
public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items) { if (items == null) { throw new ArgumentNullException("items"); } OrganiseInternal( requestor, measureBounds, items); }
public Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize) { //we will stop it pushing beyond the bounds...unless it's already beyond... var reduceBoundsWidth = itemCurrentLocation.X + itemCurrentSize.Width > measureBounds.Width ? 0 : itemDesiredSize.Width; var reduceBoundsHeight = itemCurrentLocation.Y + itemCurrentSize.Height > measureBounds.Height ? 0 : itemDesiredSize.Height; return new Point( Math.Min(Math.Max(itemDesiredLocation.X, 0), measureBounds.Width - reduceBoundsWidth), Math.Min(Math.Max(itemDesiredLocation.Y, 0), measureBounds.Height - reduceBoundsHeight)); }
public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize) { //we will stop it pushing beyond the bounds...unless it's already beyond... var reduceBoundsWidth = itemCurrentLocation.X + itemCurrentSize.Width > measureBounds.Width ? 0 : itemDesiredSize.Width; var reduceBoundsHeight = itemCurrentLocation.Y + itemCurrentSize.Height > measureBounds.Height ? 0 : itemDesiredSize.Height; return(new Point( Math.Min(Math.Max(itemDesiredLocation.X, 0), measureBounds.Width - reduceBoundsWidth), Math.Min(Math.Max(itemDesiredLocation.Y, 0), measureBounds.Height - reduceBoundsHeight))); }
public virtual void OrganiseOnDragStarted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem) { if (siblingItems == null) { throw new ArgumentNullException("siblingItems"); } if (dragItem == null) { throw new ArgumentNullException("dragItem"); } _siblingItemLocationOnDragStart = siblingItems.Select(GetLocationInfo).ToDictionary(loc => loc.Item); }
public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> items) { if (items == null) { throw new ArgumentNullException("items"); } OrganiseInternal( requestor, measureBounds, items.Select((di, idx) => new Tuple <int, DragablzItem>(idx, di)) .OrderBy(tuple => tuple, MultiComparer <Tuple <int, DragablzItem> > .Ascending(tuple => _getLocation(tuple.Item2)) .ThenAscending(tuple => tuple.Item1)) .Select(tuple => tuple.Item2)); }
private void OrganiseInternal(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> items) { var currentCoord = 0.0; var z = int.MaxValue; var logicalIndex = 0; foreach (var newItem in items) { Panel.SetZIndex(newItem, newItem.IsSelected ? int.MaxValue : --z); SetLocation(newItem, currentCoord); newItem.LogicalIndex = logicalIndex++; newItem.Measure(measureBounds); currentCoord += _getDesiredSize(newItem) + _itemOffset; } }
public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize) { var fixedItems = requestor.FixedItemCount; var lowerBound = fixedItems == 0 ? -1d : GetLocationInfo(requestor.DragablzItems() .Take(fixedItems) .Last()).End + _itemOffset - 1; return new Point( _orientation == Orientation.Vertical ? 0 : Math.Min(Math.Max(lowerBound, itemDesiredLocation.X), (measureBounds.Width) + 1), _orientation == Orientation.Horizontal ? 0 : Math.Min(Math.Max(lowerBound, itemDesiredLocation.Y), (measureBounds.Height) + 1) ); }
public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize) { var fixedItems = requestor.FixedItemCount; var lowerBound = fixedItems == 0 ? -1d : GetLocationInfo(requestor.DragablzItems() .Take(fixedItems) .Last()).End + _itemOffset - 1; return(new Point( _orientation == Orientation.Vertical ? 0 : Math.Min(Math.Max(lowerBound, itemDesiredLocation.X), (measureBounds.Width) + 1), _orientation == Orientation.Horizontal ? 0 : Math.Min(Math.Max(lowerBound, itemDesiredLocation.Y), (measureBounds.Height) + 1) )); }
public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items) { if (items == null) { throw new ArgumentNullException("items"); } var size = new Size(double.PositiveInfinity, double.PositiveInfinity); double width = 0, height = 0; var isFirst = true; foreach (var dragablzItem in items) { dragablzItem.Measure(size); if (_orientation == Orientation.Horizontal) { width += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth; if (!isFirst) { width += _itemOffset; } height = Math.Max(height, !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight); } else { width = Math.Max(width, !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth); height += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight; if (!isFirst) { height += _itemOffset; } } isFirst = false; } return(new Size(Math.Max(width, 0), Math.Max(height, 0))); }
private void OrganiseInternal(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> items) { var currentCoord = 0.0; var z = int.MaxValue; var logicalIndex = 0; foreach (var newItem in items) { Panel.SetZIndex(newItem, newItem.IsSelected ? int.MaxValue : --z); SetLocation(newItem, newItem.IsDropTargetFound ? _getLocation(newItem) : currentCoord); newItem.LogicalIndex = logicalIndex++; newItem.Measure(measureBounds); var desiredSize = _getDesiredSize(newItem); if (desiredSize == 0.0) { desiredSize = 1.0; //no measure? create something to help sorting } currentCoord += desiredSize + _itemOffset; } }
public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List<DragablzItem> siblingItems, DragablzItem dragablzItem) { }
public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem) { }
public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List <DragablzItem> siblingItems, DragablzItem dragablzItem) { }
public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items) { return(availableSize); }
public void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable<DragablzItem> items) { }
internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl) { return(LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl))); }
private bool ShouldDragWindow(DragablzItemsControl sourceOfDragItemsControl) { return(Items.Count == 1 && (InterTabController == null || InterTabController.MoveWindowWithSolitaryTabs) && !Layout.IsContainedWithinBranch(sourceOfDragItemsControl)); }
public void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem) { }
public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> items) { if (items == null) throw new ArgumentNullException("items"); OrganiseInternal( requestor, measureBounds, items.Select((di, idx) => new Tuple<int, DragablzItem>(idx, di)) .OrderBy(tuple => tuple, MultiComparer<Tuple<int, DragablzItem>>.Ascending(tuple => _getLocation(tuple.Item2)) .ThenAscending(tuple => tuple.Item1)) .Select(tuple => tuple.Item2)); }
public Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable<DragablzItem> items) { return availableSize; }
public override void OnApplyTemplate() { if (_templateSubscription != null) _templateSubscription.Dispose(); _templateSubscription = Disposable.Empty; _dragablzItemsControl = GetTemplateChild(HeaderItemsControlPartName) as DragablzItemsControl; if (_dragablzItemsControl != null) { _dragablzItemsControl.ItemContainerGenerator.StatusChanged += ItemContainerGeneratorOnStatusChanged; _templateSubscription = Disposable.Create( () => _dragablzItemsControl.ItemContainerGenerator.StatusChanged -= ItemContainerGeneratorOnStatusChanged); _dragablzItemsControl.ContainerCustomisations = new ContainerCustomisations(null, PrepareChildContainerForItemOverride); } if (SelectedItem == null) SetCurrentValue(SelectedItemProperty, Items.OfType<object>().FirstOrDefault()); _itemsHolder = GetTemplateChild(ItemsHolderPartName) as Panel; UpdateSelectedItem(); MarkWrappedTabItems(); MarkInitialSelection(); base.OnApplyTemplate(); }
public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable<DragablzItem> items) { if (items == null) throw new ArgumentNullException("items"); OrganiseInternal( requestor, measureBounds, items); }
private void OrganiseInternal(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> items) { var currentCoord = 0.0; var z = int.MaxValue; var logicalIndex = 0; foreach (var newItem in items) { Panel.SetZIndex(newItem, newItem.IsSelected ? int.MaxValue : --z); SetLocation(newItem, currentCoord); newItem.LogicalIndex = logicalIndex++; newItem.Measure(measureBounds); var desiredSize = _getDesiredSize(newItem); if (desiredSize == 0.0) desiredSize = 1.0; //no measure? create something to help sorting currentCoord += desiredSize + _itemOffset; } }
public virtual void OrganiseOnDragStarted(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem) { if (siblingItems == null) throw new ArgumentNullException("siblingItems"); if (dragItem == null) throw new ArgumentNullException("dragItem"); _siblingItemLocationOnDragStart = siblingItems.Select(GetLocationInfo).ToDictionary(loc => loc.Item); }
public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem) { if (siblingItems == null) throw new ArgumentNullException("siblingItems"); var currentLocations = siblingItems .Select(GetLocationInfo) .Union(new[] {GetLocationInfo(dragItem)}) .OrderBy(loc => loc.Item == dragItem ? loc.Start : _siblingItemLocationOnDragStart[loc.Item].Start); var currentCoord = 0.0; var z = int.MaxValue; var logicalIndex = 0; foreach (var location in currentLocations) { SetLocation(location.Item, currentCoord); currentCoord += _getDesiredSize(location.Item) + _itemOffset; Panel.SetZIndex(location.Item, --z); location.Item.LogicalIndex = logicalIndex++; } Panel.SetZIndex(dragItem, int.MaxValue); }
private bool ShouldDragWindow(DragablzItemsControl sourceOfDragItemsControl) { return (Items.Count == 1 && (InterTabController == null || InterTabController.MoveWindowWithSolitaryTabs) && !Layout.IsContainedWithinBranch(sourceOfDragItemsControl)); }
public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable<DragablzItem> items) { if (items == null) throw new ArgumentNullException("items"); var size = new Size(double.PositiveInfinity, double.PositiveInfinity); double width = 0, height = 0; var isFirst = true; foreach (var dragablzItem in items) { dragablzItem.Measure(size); if (_orientation == Orientation.Horizontal) { width += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth; if (!isFirst) width += _itemOffset; height = Math.Max(height, !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight); } else { width = Math.Max(width, !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth); height += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight; if (!isFirst) height += _itemOffset; } isFirst = false; } return new Size(Math.Max(width, 0), Math.Max(height, 0)); }
internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl) { return LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl)); }
public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items) { }