![]() |
Desktop Development »
Miscellaneous »
General
Beginner
License: The Code Project Open License (CPOL)
Cool Angle Select Control (Photoshop style)By Roey CA cool control to select Angles. |
C# (C# 1.0, C# 2.0, C# 3.0), .NET (.NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5), Win32
|
||||||||||
|
Advanced Search |
|
|
|
||||||||||||||||

Hi everybody! this is the first time i decided to release a code of mine on codeproject. it's quite straight forward, i don't have much to say about it, and i think the picture above describe it pretty well.
basically, i needed a control to select an angle, and i made the one above. I saw the one used on Photoshop, and decided to create one of my own.
The implementation is really simple, as the code below shows:
/// <summary> /// Event - User is moving the mouse. /// </summary> private void AngleSelect_MouseMove(object sender, MouseEventArgs e) { if (Clicked == true) { //if mouse down, change the Angle. Point centerPoint = new Point(ClientRectangle.Width / 2, ClientRectangle.Height / 2); Point mousePos = ((MouseEventArgs)e).Location; //Using the Atan2 function in order to get the Angle of the Slope between the center Point of the control and the Mouse Point. double radians = Math.Atan2(mousePos.Y - centerPoint.Y, mousePos.X - centerPoint.X); //Then converting from Radians to regular Units. angle = (int)(radians * (180 / Math.PI)); Refresh(); //call delegated function try { angleChanged(angle); } catch { } } }
Here are the main Properties the events to use:
FillColor - Sets the Circle's fill color.
LineColor - Sets the Circles's line color.
angleChanged - (event) Called when ever the user is changing the Angle.
Angle - Sets or Gets the angle of the control.
Hope, you'll find this useful.
Roey
| You must Sign In to use this message board. | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 13 Nov 2008 Editor: |
Copyright 2006 by Roey C Everything else Copyright © CodeProject, 1999-2009 Web16 | Advertise on the Code Project |