示例#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);
        }
示例#2
0
        private void FontsTileView_DrawItem(object sender, TileView.TileViewControl.DrawTileListItemEventArgs e)
        {
            if (treeView.Nodes.Count == 0)
            {
                return;
            }

            if (treeView.SelectedNode == null)
            {
                return;
            }

            int  i;
            char c;

            if ((int)treeView.SelectedNode.Parent.Tag == 1)
            {
                // Unicode fonts
                i = e.Index;
                c = (char)i;

                // draw what should be in tile
                e.Graphics.DrawString(c.ToString(), DefaultFont, Brushes.Gray, e.Bounds.X + (e.Bounds.Width / 2), e.Bounds.Y + (e.Bounds.Height / 2));

                // draw using font from uo if character exists
                var bmp = UnicodeFonts.Fonts[(int)treeView.SelectedNode.Tag].Chars[i].GetImage();
                if (bmp == null)
                {
                    return;
                }

                int width  = bmp.Width;
                int height = bmp.Height;

                if (width > e.Bounds.Width)
                {
                    width = e.Bounds.Width - 2;
                }

                if (height > e.Bounds.Height)
                {
                    height = e.Bounds.Height - 2;
                }

                e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, width, height));

                bmp.Dispose();
            }
            else
            {
                // ASCII Fonts
                i = e.Index;
                c = (char)(i + AsciiFontOffset);

                // draw what should be in tile
                e.Graphics.DrawString(c.ToString(), DefaultFont, Brushes.Gray, e.Bounds.X + (e.Bounds.Width / 2), e.Bounds.Y + (e.Bounds.Height / 2));

                // draw using font from uo if character exists
                var font = (int)treeView.SelectedNode.Tag;
                e.Graphics.DrawImage(ASCIIText.Fonts[font].Characters[_fonts[i]], new Point(e.Bounds.X + 2, e.Bounds.Y + 2));
            }
        }