Click here to Skip to main content
Click here to Skip to main content

Customizable Tracker Control

, 6 Jun 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Windows Forms Control to visualize performance counters
tracker_demo.jpg

Introduction

A while ago, I stumbled over an article written by Andelko Pavelic. I looked into the code and found it to be an interesting approach. But I needed something more stable, accurate and flexible - and I needed better looks. So I took the base idea and wrote my own version, the TrackerControl 2.0. Although almost nothing is left of Andelko's initial code, credits belong to him for providing the initial idea.

Using the Code

There is a bunch of additional features and properties added to the original control.

First of all, the coloring of the drawn graph is extended to optionally use a linear color gradient:

tracker1.jpg

To make it more plastic, the area underneath the graph can be colorized:

tracker2.jpg

The grid can be adjusted in mesh size and optionally horizontal and/or vertical grid lines can be blanked:

tracker3.jpg

The wider the control, the more values are represented by the graph. I found it helpful in some cases to visualize the average as a horizontal bar:

tracker4.jpg

The average bar's color can also be set to a linear gradient, other than the one of the graph.

There are some features that can hardly be shown with still pictures, such as:

GridMovement.MoveWithGraph and GridMovement.Fixed

The grid can progressively move with the graph or stay fixed in the background.

GraphSizeMode.Fixed

This is the classic mode, known from the Windows Task Manager.

GraphSizeMode.Zoom

While still in line with values between Minimum and Maximum and colorizing the graph according to these fixed bounds, the vertical zoom level is continuously adjusted to the highest displayed value. That gives more granularity during periods of low values at a constant control height. The distance between the horizontal grid lines is adjusted as well (if shown), according to the zoom level.

GraphSizeMode.AutoAdjustMaximum

Sometimes the exact Maximum isn't known and it would be laborious to manually adjust the controls Maximum in your code during runtime. This setting does exactly that, correcting the Control's internal maximum continuously to the highest shown value. In difference to GraphSizeMode.Zoom, the graph's color gradient is fully utilized. The Maximum value in AutoAdjustMaximum acts as the initial internal maximum and also as the internal lower bound for its auto adjustment.

TrackerRefreshInDesignMode, TrackerRefreshInRuntimeMode and TrackerRefreshStartOnFirstValue

These settings do exactly as the names imply: The first one eventually saves you from headache caused by watching moving grid lines while designing the form and the second is useful to halt and resume the TrackerControl during runtime. The third prevents the Control from refreshing until it gets the first value to be drawn.

StartValue

Depending on the area of application, sometimes the start value of the graph needs to be other than 0.

ResetValueBuffer

Flushes the internal value buffer and clears the graph.

Points of Interest

Combining the settings help to customize visualization. They can also be changed during runtime, allowing interesting visual effects.

Keep in mind that there is no error handling implemented. Eventually, you need to do this yourself according to your application's exception handling strategy.

History

  • 6th June, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

BTDex

Germany Germany
No Biography provided

Comments and Discussions

 
Questionhigh consumtion CPU Pinmemberspiritdead7-Oct-12 12:48 
GeneralPretty good stuff. PinmvpMd. Marufuzzaman11-Jul-10 23:42 
Pretty good stuff but it will be more helpful to us if you provide the explanation of your code snippets.
Thanks
Md. Marufuzzaman


I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

GeneralLooks Great! PinmemberShane Story9-Jun-10 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 6 Jun 2010
Article Copyright 2010 by BTDex
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid