Download the file: SimpleDigitStyle.cs

Let's assume that you want to create your own style for digits element. In order to do this, you need to complete the following steps:

1. Use the code as follows:
class CustomDigetStyle : 
PerpetuumSoft.Instrumentation.Model.Specialized.DrawDigitSegment
    {
        public override void CalculateRegions()
        {
            //throw new NotImplementedException();
        }
 
        public override void DrawColon(
		PerpetuumSoft.Framework.Drawing.Fill activeFill, 
		int digitSpace,
		PerpetuumSoft.Framework.Drawing.GraphicStream stream)
        {
            //throw new NotImplementedException();
        }
    }
2. In the CalculateRegion function you need to add the calculation of the numbers segment and fill the segmentPaths array as follows:
segmentPaths[0] – Top
segmentPaths[1] – Bottom
segmentPaths[2] – left top segment
segmentPaths[3] – right top
segmentPaths[4] – left bottom
segmentPaths[5] – right bottom
segmentPaths[6] - middle
The DrawColon method draws the colon. It can be implemented the following way:
public override void DrawColon(Fill activeFill, 
int digitSpace, GraphicStream stream)
    {
        stream.FillRectangle(activeFill, new 
		VectorRectangle(0, DigitHeight * 0.3, 
				SegmentThickness, SegmentThickness));
        stream.FillRectangle(activeFill, new 
		VectorRectangle(0, DigitHeight * 0.7, 
				SegmentThickness, SegmentThickness));
        stream.Transform(
		new Matrix(1, 0, 0, 1,digitSpace + SegmentThickness, 0));
    }
To make a style available, it's necessary to register it in the styles collection:
PerpetuumSoft.Instrumentation.Model.Specialized.
DrawDigitSegment.RegisterDigitStyle(typeof(CustomDigetStyle));
After registration this style will be available in the properties:

Add Feedback