Images can be drawn at runtime using the Paint event, like the following:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub template1_Paint(sender As Object, e As C1.Win.C1Tile.TemplatePaintEventArgs) Dim g As Graphics = e.Graphics g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality Dim rect As Rectangle = e.ClipRectangle rect.X += (rect.Width - 28) \ 2 rect.Y += (rect.Height - 28) \ 2 rect.Width = 28 rect.Height = 28 Dim brush As Brush = New SolidBrush(e.Tile.GetBackColor()) Dim pen As New Pen(e.Tile.GetForeColor()) Select Case e.Tile.IntValue Case 1 g.FillPie(brush, rect, 50F, 270F) g.DrawPie(pen, rect, 50F, 270F) Exit Select Case 2 g.FillRectangle(brush, rect) g.DrawRectangle(pen, rect) Exit Select Case Else g.FillEllipse(brush, rect) g.DrawEllipse(pen, rect) Exit Select End Select brush.Dispose() pen.Dispose() End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void template8_Paint(object sender, C1.Win.C1Tile.TemplatePaintEventArgs e) { Graphics g = e.Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; Rectangle rect = e.ClipRectangle; rect.X += (rect.Width - 28) / 2; rect.Y += (rect.Height - 28) / 2; rect.Width = 28; rect.Height = 28; Brush brush = new SolidBrush(e.Tile.GetBackColor()); Pen pen = new Pen(e.Tile.GetForeColor()); switch (e.Tile.IntValue) { case 1: g.FillPie(brush, rect, 50f, 270f); g.DrawPie(pen, rect, 50f, 270f); break; case 2: g.FillRectangle(brush, rect); g.DrawRectangle(pen, rect); break; default: g.FillEllipse(brush, rect); g.DrawEllipse(pen, rect); break; } brush.Dispose(); pen.Dispose(); } |