コード例 #1
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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);
        }
コード例 #2
0
ファイル: CanvasOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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);
        }
コード例 #3
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            OrganiseInternal(
                requestor,
                measureBounds,
                items);
        }
コード例 #4
0
ファイル: CanvasOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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)));
        }
コード例 #5
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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);
        }
コード例 #6
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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));
        }
コード例 #7
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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)
                       ));
        }
コード例 #8
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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)));
        }
コード例 #9
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
        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;
            }
        }
コード例 #10
0
ファイル: CanvasOrganiser.cs プロジェクト: zjamt/SimpleRemote
 public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items)
 {
     return(availableSize);
 }
コード例 #11
0
ファイル: CanvasOrganiser.cs プロジェクト: zjamt/SimpleRemote
 public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
 {
 }
コード例 #12
0
ファイル: CanvasOrganiser.cs プロジェクト: zjamt/SimpleRemote
 public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items)
 {
 }
コード例 #13
0
ファイル: StackOrganiser.cs プロジェクト: zjamt/SimpleRemote
 public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds,
                                               List <DragablzItem> siblingItems, DragablzItem dragablzItem)
 {
 }