예제 #1
0
        protected virtual Point GetCellAtPoint(TileGroupElement group, Point location)
        {
            float width  = (float)group.CellSize.Width;
            float height = (float)group.CellSize.Height;
            int   y      = (int)((double)location.X / (double)width) + (location.X - (int)((double)location.X / (double)width) > 0 ? 1 : 0) - 1;

            return(new Point((int)((double)location.Y / (double)height) + ((double)location.Y - (double)location.Y / (double)height > 0.0 ? 1 : 0) - 1, y));
        }
예제 #2
0
 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);
 }
예제 #3
0
        protected PointF GetCellCoordinates(
            TileGroupElement group,
            int rowIndex,
            int columnIndex)
        {
            float width  = (float)group.CellSize.Width;
            float height = (float)group.CellSize.Height;

            return(new PointF(width * (float)columnIndex, height * (float)rowIndex));
        }
        public static TileGroupElement AddTileGroupElement(string name, string text)
        {
            TileGroupElement tileGroupElement = new Telerik.WinControls.UI.TileGroupElement();

            tileGroupElement.Font      = new System.Drawing.Font("B Yekan", 20F);
            tileGroupElement.Name      = name;
            tileGroupElement.Text      = text;
            tileGroupElement.RowsCount = 4;

            return(tileGroupElement);
        }
예제 #5
0
 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();
 }
예제 #6
0
        protected virtual TileGroupElement GetTargetGroup(RectangleF tileRectangle)
        {
            TileGroupElement tileGroupElement = (TileGroupElement)null;
            float            num1             = 0.0f;

            foreach (TileGroupElement group in (RadItemCollection)this.owner.Groups)
            {
                if (tileRectangle.IntersectsWith((RectangleF)group.ControlBoundingRectangle))
                {
                    RectangleF rectangleF = tileRectangle;
                    rectangleF.IntersectsWith((RectangleF)group.ControlBoundingRectangle);
                    float num2 = rectangleF.Width * rectangleF.Height;
                    if ((double)num2 > (double)num1)
                    {
                        num1             = num2;
                        tileGroupElement = group;
                    }
                }
            }
            return(tileGroupElement);
        }
예제 #7
0
        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();
        }
예제 #8
0
        protected virtual Point GetTargetCell(TileGroupElement group, Point dropLocation)
        {
            dropLocation = new Point(Math.Max(dropLocation.X - group.ControlBoundingRectangle.X, 0), Math.Max(dropLocation.Y - group.ContentElement.ControlBoundingRectangle.Y, 0));
            Point  cellAtPoint = this.GetCellAtPoint(group, dropLocation);
            Point  point1      = Point.Empty;
            PointF pointF1     = new PointF(float.PositiveInfinity, float.PositiveInfinity);

            for (int index = 0; index < this.checkDirections.Length; ++index)
            {
                Point  point2          = new Point(cellAtPoint.X + this.checkDirections[index].X, cellAtPoint.Y + this.checkDirections[index].Y);
                PointF cellCoordinates = this.GetCellCoordinates(group, point2.X, point2.Y);
                PointF pointF2         = new PointF(cellCoordinates.X - (float)dropLocation.X, cellCoordinates.Y - (float)dropLocation.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;
                    point1  = new Point(point2.X, point2.Y);
                }
            }
            if ((double)pointF1.X == double.PositiveInfinity || (double)pointF1.Y == double.PositiveInfinity)
            {
                return(new Point(-1, -1));
            }
            return(point1);
        }