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 virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items) { if (items == null) { throw new ArgumentNullException("items"); } OrganiseInternal( requestor, measureBounds, items); }
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)); }
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, 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 Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items) { return(availableSize); }
public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem) { }
public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items) { }
public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List <DragablzItem> siblingItems, DragablzItem dragablzItem) { }