Cross to follow mouse
-
I have created a control which follows the mouse using MousePosition However i would actually like the mouse value produced by the control to start at 0 at the top and left sides of my control and finish at 1000. at the bottom and the right sides of the control. Does anyone know how i can do this? Thanx in advance
-
I have created a control which follows the mouse using MousePosition However i would actually like the mouse value produced by the control to start at 0 at the top and left sides of my control and finish at 1000. at the bottom and the right sides of the control. Does anyone know how i can do this? Thanx in advance
I'm not sure what you mean, but I think you mean you want to do some basic primary school math to convert the width and height of the control to be a range from 0 to 1000 ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
I'm not sure what you mean, but I think you mean you want to do some basic primary school math to convert the width and height of the control to be a range from 0 to 1000 ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
I'm not sure what you mean, but I think you mean you want to do some basic primary school math to convert the width and height of the control to be a range from 0 to 1000 ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Thanx for the help. I have created some code that works now dont know if this is the idea you thought but it functions correctly. Only the painted cross moves the same as the value ill just have to change this and it will be complete.
private int MAX\_VALUE = 1000; private int MIN\_VALUE = 0; private double m\_WidthMultiplyNo = 0; private double m\_HeightMultiplyNo = 0; public Point Origin { get { return m\_origin; } set { m\_origin = calculateNewPosition(value); if (PositionChanged != null) { this.PositionChanged(); } } } private Point calculateNewPosition(Point Value) { if (Value.Y < m\_position.Y) { if (Value.X > m\_position.X) { Value.Y -= 1; Value.X += 1; } else if (Value.X < m\_position.X) { Value.Y -= 1; Value.X -= 1; } } else if (Value.Y > m\_position.Y) { if (Value.X > m\_position.X) { Value.Y += 1; Value.X += 1; } else if (Value.X < m\_position.X) { Value.Y += 1; Value.X -= 1; } } Value.X \*= (int)m\_WidthMultiplyNo; Value.Y \*= (int)m\_HeightMultiplyNo; Value = KeepInsideValue(Value); return Value; }