private void timer1_Tick(object sender, EventArgs e) { gr.Clear(Color.White); int xx = 20; int yy = 10; var ctx = new DesktopDrawingContext(gr, pictureBox1); #region arrange icons foreach (var item in Elements.OfType <DesktopIcon>()) { //var ms = gr.MeasureString(item.Caption, font1); //gr.DrawString(item.Caption, font1, Brushes.Black, xx + xsz / 2 - ms.Width / 2, yy + yshift); item.Position = new PointF(xx, yy); yy += 80; if (yy > (Height - 150)) { yy = 10; xx += 90; } } #endregion foreach (var item in Elements.OrderBy(z => z.ZOrder)) { item.Draw(ctx); } pictureBox1.Image = bmp; }
public override void Draw(DesktopDrawingContext ctx) { var pos = ctx.CursorPos; Hovered = BoundingBox.IntersectsWith(new RectangleF(pos.X, pos.Y, 1, 1)); var gr = ctx.Graphics; var ms = gr.MeasureString(Caption, Font); var yy = Position.Y; var xx = Position.X; var sx = xx + Image.Width / 2 - ms.Width / 2; var sy = yy + Image.Height; if (Hovered) { gr.FillRectangle(Brushes.LightBlue, sx, sy, ms.Width, ms.Height); } gr.DrawString(Caption, Font, Brushes.Black, sx, sy); gr.DrawImage(Image, xx, yy); base.Draw(ctx); }
public virtual void Draw(DesktopDrawingContext ctx) { }