示例#1
0
        void tileViewControl1_DrawItem(object sender, TileView.TileViewControl.DrawTileListItemEventArgs e)
        {
            Point pp = new Point(e.Bounds.X + tileViewControl1.TilePadding.Left, e.Bounds.Y + tileViewControl1.TilePadding.Top);

            e.Graphics.FillRectangle(Brushes.Pink, new Rectangle(pp, tileViewControl1.TileSize)); // tile itself

            //TODO: Rewrite text drawing completely
            string text = e.Index.ToString();

            /*
             * SizeF ts = e.Graphics.MeasureString(text, tileViewControl1.Font);
             * PointF tp = new PointF(pp.X + tileViewControl1.TileSize.Width / 2 - ts.Width / 2, pp.Y + tileViewControl1.TileSize.Height + ts.Height / 2);
             *
             * e.Graphics.DrawString(text, tileViewControl1.Font, new SolidBrush(tileViewControl1.ForeColor), tp.X, tp.Y); // text*/

            RectangleF rect = new RectangleF(e.Bounds.X, e.Bounds.Top + tileViewControl1.TilePadding.Top + tileViewControl1.TileSize.Height, tileViewControl1.TileSize.Width, tileViewControl1.TilePadding.Bottom);

            /*SizeF strLayout = new SizeF(tileViewControl1.TileSize.Width, tileViewControl1.TilePadding.Bottom);
             * SizeF strSize = e.Graphics.MeasureString(text, e.Font, strLayout, tileViewControl1.TextStringFormat);
             * PointF strPos = new PointF(e.Bounds.X + (e.Bounds.Width - strSize.Width) / 2, e.Bounds.Top + tileViewControl1.TilePadding.Top + tileViewControl1.TileSize.Height + ( strLayout.Height/2 - strSize.Height / 2));
             * //new RectangleF(new PointF((ImagesListView.TileSize.Width - strSize.Width) / 2 + e.Bounds.Left, e.Bounds.Y + ImagesListView.TilePadding.Top + ImagesListView.TileSize.Height + (e.Font.Height - strSize.Height / 2))
             * if (tileViewControl1.TilePadding.Bottom - strSize.Height < 2) return; //No space for text
             * e.Graphics.DrawString(text, e.Font, SystemBrushes.ControlText, new RectangleF(strPos, strSize), tileViewControl1.TextStringFormat);*/
            e.DrawText(rect, text);
            //cannot use new SolidBrush(e.ForeColor) due to change on Focus to white
            //e.Graphics.DrawRectangle(Pens.Red, strPos.X, strPos.Y, strSize.Width, strSize.Height);
        }