protected override void OnPreviewDragDrop(RadDropEventArgs e) { base.OnPreviewDragDrop(e); this.scrollTimer.Stop(); if (!this.owner.ShowGroups) { this.HandleUngroupedDragDrop(e); } else { this.HandleGroupedDragDrop(e); } RadTileElement context = this.Context as RadTileElement; RadElement hitTarget = e.HitTarget as RadElement; Point point = e.DropLocation; if (context == null) { return; } if (hitTarget != null) { point = hitTarget.PointToControl(point); } Point location = context.ControlBoundingRectangle.Location; SizeF sizeF = new SizeF((float)(point.X - location.X), (float)(point.Y - location.Y)); context.Visibility = ElementVisibility.Visible; new AnimatedPropertySetting(RadElement.PositionOffsetProperty, (object)sizeF, (object)SizeF.Empty, 5, 10) { RemoveAfterApply = true }.ApplyValue((RadObject)context); ControlTraceMonitor.TrackAtomicFeature(hitTarget, "Reordering"); }
protected virtual void HandleUngroupedDragDrop(RadDropEventArgs e) { RadElement hitTarget = e.HitTarget as RadElement; RadTileElement context = this.Context as RadTileElement; Point point = e.DropLocation; point.Offset(-(int)this.owner.TileLayout.PositionOffset.Width, -(int)this.owner.TileLayout.PositionOffset.Height); if (hitTarget != null) { point = hitTarget.PointToControl(point); } if (context == null || hitTarget == null) { return; } Point targetCell = this.GetTargetCell(context, point); if (targetCell.X == -1) { return; } targetCell.X = Math.Min(targetCell.X, this.owner.RowsCount - context.RowSpan); context.Row = targetCell.X; context.Column = targetCell.Y; int colSpan = context.ColSpan; context.ColSpan = 0; this.OffsetTiles(context, colSpan); context.ColSpan = colSpan; context.Column -= colSpan; this.owner.InvalidateMeasure(true); this.owner.UpdateLayout(); }
protected bool OffsetHoveredTile(Point clientPoint) { if (this.owner.ShowGroups) { clientPoint.Offset(-this.xOutlineFormOffset, -this.yOutlineFormOffset); RadTileElement context = this.Context as RadTileElement; if (context == null) { return(true); } TileGroupElement targetGroup = this.GetTargetGroup(new RectangleF((PointF)clientPoint, (SizeF)context.Size)); if (targetGroup == null) { return(true); } Point targetCell = this.GetTargetCell(targetGroup, clientPoint); if (targetCell.X == -1) { return(true); } foreach (RadTileElement radTileElement in (RadItemCollection)targetGroup.Items) { if (radTileElement != context && radTileElement.Row == targetCell.X && radTileElement.Column == targetCell.Y) { radTileElement.PositionOffset = new SizeF(15f, 0.0f); this.previousHoveredTile = radTileElement; break; } } } else { clientPoint.Offset(-this.xOutlineFormOffset, -this.yOutlineFormOffset); clientPoint.Offset(-(int)this.owner.TileLayout.PositionOffset.Width, -(int)this.owner.TileLayout.PositionOffset.Height); RadTileElement context = this.Context as RadTileElement; if (context == null) { return(true); } Point targetCell = this.GetTargetCell(context, clientPoint); if (targetCell.X == -1) { return(true); } foreach (RadTileElement radTileElement in (RadItemCollection)this.owner.Items) { if (radTileElement != context && radTileElement.Row == targetCell.X && radTileElement.Column == targetCell.Y) { radTileElement.PositionOffset = new SizeF(15f, 0.0f); this.previousHoveredTile = radTileElement; break; } } } return(false); }
private bool CanPlace(RadTileElement tileElement, int row, int col) { Rectangle rect = new Rectangle(col, row, tileElement.ColSpan, tileElement.RowSpan); foreach (RadTileElement radTileElement in (RadItemCollection)this.Items) { if (radTileElement != tileElement && new Rectangle(radTileElement.Column, radTileElement.Row, radTileElement.ColSpan, radTileElement.RowSpan).IntersectsWith(rect)) { return(false); } } return(true); }
public void ScrollToItem(RadTileElement tile, int desiredOffset) { int num = tile.ControlBoundingRectangle.X - this.scrollBar.ControlBoundingRectangle.X - desiredOffset + this.scrollBar.Value; if (num > this.scrollBar.Maximum - this.scrollBar.LargeChange + 1) { num = this.scrollBar.Maximum - this.scrollBar.LargeChange + 1; } else if (num < 0) { num = 0; } this.scrollBar.Value = num; }
private void OffsetTiles(TileGroupElement group, RadTileElement current, int offset) { this.offsetStack.Push(current); foreach (RadTileElement current1 in (RadItemCollection)group.Items) { if (!this.offsetStack.Contains(current1) && current1.Column < current.Column + current.ColSpan + offset && (current1.Column + current1.ColSpan > current.Column && current1.Row < current.Row + current.RowSpan) && current1.Row + current1.RowSpan > current.Row) { this.OffsetTiles(group, current1, offset - (current1.Column - current.Column - current.ColSpan)); } } current.Column += offset; group.ColumnsCount = Math.Max(group.ColumnsCount, current.Column + current.ColSpan); this.offsetStack.Pop(); }
protected override void OnPanGesture(PanGestureEventArgs args) { base.OnPanGesture(args); if (!this.zoomedIn || args.Handled) { return; } RadTileElement elementAtPoint = this.ElementTree.GetElementAtPoint(args.Location) as RadTileElement; if (args.IsBegin && elementAtPoint != null && elementAtPoint.AllowDrag) { return; } this.ScrollView(args.Offset.Width, true); args.Handled = true; }
private void items_ItemsChanged( RadItemCollection changed, RadItem target, ItemsChangeOperation operation) { if (target != null && !typeof(RadTileElement).IsAssignableFrom(target.GetType())) { throw new ArgumentException("The Items collection accepts only objects or descendants of type RadTileElement"); } RadTileElement tileElement = target as RadTileElement; RadControl control = this.ElementTree.Control as RadControl; if (control != null && control.IsInitializing || this.ElementTree.Control.Site != null) { return; } if (this.AutoArrangeNewTiles && tileElement != null && operation == ItemsChangeOperation.Inserted) { int num1 = 0; int num2 = 0; bool flag = false; if (tileElement.GetValueSource(GridLayout.ColumnIndexProperty) > ValueSource.DefaultValue || tileElement.GetValueSource(GridLayout.RowIndexProperty) > ValueSource.DefaultValue) { this.UpdateCellCount(); this.InvalidateMeasure(); return; } int col = 0; while (!flag) { for (int row = 0; !flag && row < this.RowsCount; ++row) { if (this.CanPlace(tileElement, row, col)) { num1 = row; num2 = col; flag = true; } } ++col; } tileElement.Column = num2; tileElement.Row = num1; } this.UpdateCellCount(); this.InvalidateMeasure(); }
private void items_ItemsChanged( RadItemCollection changed, RadItem target, ItemsChangeOperation operation) { RadTileElement tileElement = target as RadTileElement; RadPanoramaElement ancestor = this.FindAncestor <RadPanoramaElement>(); RadControl radControl = this.ElementTree != null ? this.ElementTree.Control as RadControl : (RadControl)null; if (radControl == null || radControl.IsInitializing || this.DesignMode) { return; } if (ancestor != null && ancestor.AutoArrangeNewTiles && (tileElement != null && operation == ItemsChangeOperation.Inserted)) { int num1 = 0; int num2 = 0; bool flag = false; if (tileElement.GetValueSource(GridLayout.ColumnIndexProperty) > ValueSource.DefaultValue || tileElement.GetValueSource(GridLayout.RowIndexProperty) > ValueSource.DefaultValue) { this.UpdateCellCount(); this.InvalidateMeasure(); return; } int col = 0; while (!flag) { for (int row = 0; !flag && row < this.RowsCount; ++row) { if (this.CanPlace(tileElement, row, col)) { num1 = row; num2 = col; flag = true; } } ++col; } tileElement.Column = num2; tileElement.Row = num1; } this.UpdateCellCount(); this.InvalidateMeasure(); }
protected virtual void HandleGroupedDragDrop(RadDropEventArgs e) { RadTileElement hitTarget = e.HitTarget as RadTileElement; RadTileElement context = this.Context as RadTileElement; Point point = e.DropLocation; if (hitTarget != null) { point = hitTarget.PointToControl(point); } TileGroupElement targetGroup = this.GetTargetGroup(new RectangleF((PointF)point, (SizeF)context.Size)); if (context == null || targetGroup == null) { return; } Point targetCell = this.GetTargetCell(targetGroup, point); if (targetCell.X == -1) { return; } targetCell.X = Math.Max(0, Math.Min(targetCell.X, targetGroup.RowsCount - context.RowSpan)); context.Row = targetCell.X; context.Column = targetCell.Y; if (!targetGroup.Items.Contains((RadItem)context)) { (context.Parent.Parent as TileGroupElement).Items.Remove((RadItem)context); targetGroup.Items.Add((RadItem)context); } int colSpan = context.ColSpan; context.ColSpan = 0; this.OffsetTiles(targetGroup, context, colSpan); context.ColSpan = colSpan; context.Column -= colSpan; this.owner.InvalidateMeasure(true); this.owner.UpdateLayout(); }
protected virtual Point GetTargetCell(RadTileElement source, Point location) { float width = (float)this.owner.CellSize.Width; float height = (float)this.owner.CellSize.Height; int y = (int)((double)location.X / (double)width) + (location.X - (int)((double)location.X / (double)width) > 0 ? 1 : 0) - 1; Point point1 = new Point((int)((double)location.Y / (double)height) + ((double)location.Y - (double)location.Y / (double)height > 0.0 ? 1 : 0) - 1, y); Point point2 = Point.Empty; PointF pointF1 = new PointF(float.PositiveInfinity, float.PositiveInfinity); if (point1.X < 0) { point1.X = 0; } if (point1.Y < 0) { point1.Y = 0; } for (int index = 0; index < this.checkDirections.Length; ++index) { Point point3 = new Point(point1.X + this.checkDirections[index].X, point1.Y + this.checkDirections[index].Y); if (this.CanPlaceElementAtPosition(point3.X, point3.Y, source.ColSpan, source.RowSpan)) { PointF cellCoordinates = this.GetCellCoordinates(point3.X, point3.Y); PointF pointF2 = new PointF(cellCoordinates.X - (float)location.X, cellCoordinates.Y - (float)location.Y); if ((double)pointF2.X * (double)pointF2.X + (double)pointF2.Y * (double)pointF2.Y < (double)pointF1.X * (double)pointF1.X + (double)pointF1.Y * (double)pointF1.Y) { pointF1 = pointF2; point2 = new Point(point3.X, point3.Y); } } } if ((double)pointF1.X == double.PositiveInfinity || (double)pointF1.Y == double.PositiveInfinity) { return(new Point(-1, -1)); } return(point2); }
public void ScrollToItem(RadTileElement tile) { this.ScrollToItem(tile, 0); }