Page 1 of 1

turn Gauge

Posted: Wed Jan 31, 2007 7:41 am
by 9788246
Hi..
Can I use a gauge as a turnbutton (I dont know how i can call it). I mean: Wenn I click over the gauge, the line in it has to follow the mouse, so the value of the gauege has to change.
Is sth like that possible?
Thansk..

Posted: Wed Jan 31, 2007 12:44 pm
by narcis
Hi MU,

You can do something like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			gauges1.Value = 50;
		}

		private bool moveGauge = false;

		private void tChart1_MouseDown(object sender, MouseEventArgs e)
		{
			moveGauge = true;
		}

		private void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			if (moveGauge)
			{
				int tmpL = gauges1.CalcXPos(0) - gauges1.XRadius;
				int tmpW = (gauges1.CalcXPos(0) + gauges1.XRadius) - tmpL;
				double val = ((double)(e.X - tmpL) / (double)tmpW) * gauges1.Maximum;
				gauges1.Value = val;
			}
		}

		private void tChart1_MouseUp(object sender, MouseEventArgs e)
		{
			moveGauge = false;
		}
BTW: You can call it a knob :wink:.