

this will be the bit pattern that gets shown on the segments, // bits 0 through 6 corresponding to each segment. Private void SevenSegment_Paint( object sender, PaintEventArgs e) Let's examine the control's Paint event to see exactly what's going on: To draw the polygons on the control, I use the FillPolygon function, passing it the array of points that represent the polygon. To model the polygons, I drew them out on graph paper, and recorded the coordinates of each point in each polygon. To replicate the look of a seven-segment display, I draw seven polygons that precisely match the physical layout of a real display. Rebuild your project, and you'll be able to select the SevenSegment control from your tool palette and drop it right onto your forms. This custom control can be built into your application by simply including the "SevenSegment.cs" file in your project. They're called seven-segment displays because they're actually made up of seven "segments" - seven individual lights (LEDs or otherwise) that light up in different patterns that represent any of the ten digits (0 - 9). They appear on pretty much every piece of electronic equipment that needs to display numbers for any reason, like the timer on a microwave oven, the display on a CD player, or the time on your digital wristwatch. BackgroundĮven if you haven't heard the name "seven-segment display" before, you've probably seen quite a few in your lifetime. And, if you like the control and are able to use it, or learn from it, so much the better. I also wrote the control to become more familiar with the internals of C# and.

That's why I decided to write this seven-segment LED control: not because it's any more "useful" than a standard Label control, but because it looks freakin' sweet. Sometimes, there are certain controls that just beg to be written, whether they're useful or not.

Your user base is already familiar with the OS's native controls, so creating custom controls would only add to the learning curve for your application. From the point of view of usability, it should always make the most sense to use the controls that are shipped with the Operating System.

I'm usually not a big fan of custom controls except in the most extreme circumstances. The source code is available on GitHub! Introduction
