酷炫角度选择控件(Photoshop 风格) 
一个用于选择角度的酷炫控件。

引言
这是我第一次决定在 CodeProject 上发布我的代码。它非常简单明了,我没什么好说的,我想上面的图片已经很好地描述了它。
基本上,我需要一个选择角度的控件,所以我制作了上面的这个。我看到了 Photoshop 中使用的那个,并决定自己创建一个。
实现非常简单,如以下代码所示
/// <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 { }
    }
}
以下是主要属性和要使用的事件
- FillColor- 设置圆的填充颜色。
- LineColor- 设置圆的线条颜色。
- Angle- 设置或获取控件的角度。
- AngleChanged- 在用户更改角度时调用。
希望对您有所帮助。




