Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Vector graphics in CLI control

2009-07-18

This post is done from the middle of nowhere and I am using my 3G phone as a modem. I hope that I manage to upload everything.

I have added support for vector graphics in my CLI control to make the control more versatile. A collection named GraphicalElement holds the graphics to be drawn. Graphical elements in the collection can be manipulated and changes are reflected when the control is redrawn (you can call the Invalidate method to flag the control as dirty). When scrolling occurs, all graphical elements also are moved up. Elements are deleted when they scroll out of view.

This simple example shows how to add graphics (it draws 60 bars in a nice pattern):

For I As Integer = 1 To 60
Cli1.GraphicalElements.AddBox(“”, Brushes.Yellow, I * 10, 10, 8, _
CType(50 + (Math.Sin(I / 3) * 50), Integer))
Next

Because elements are deleted automatically when they scroll out of view, items will get new index numbers. Therefore, you should either save a reference to the item (a reference can be created manually using the Box constructor, but a reference to a Box is also given as return value from the AddBox method) or give the element a name, and then acquire a reference when a reference is needed using the FindElementByName method of the GraphicalElement collection.

When I have the opportunity, I will do some more examples and some illustrations.

Categories: Microsoft .NET

Tags: CLIControl

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips