CircleAnglePicker Control

When developing graphics applications, it sometimes becomes necessary to provide the user with an interface for picking the tilt angle. In Windows Forms, for this purpose, we can use the NumericUpDown control or, at worst, a TextBox control or even a TrackBar. But it’s not convenient.

In the Photoshop interface, you can find a pretty handy component for adjusting the tilt angles. This is really visual and convenient. I made a similar control for Windows Forms projects.

The control is a circle with a line going from the center. The angle is selected by moving the line in the circle.

 

CircleAnglePicker — is a free user control written in C#. The source code is open and provided under the terms of the MIT license.

Installation

You can add CircleAnglePicker to your project in two ways.

Using the NuGet Package Manager (recommended).

Run the following command in the Package Manager Console:

Install-Package CircleAnglePicker



Or using the graphical interface of NuGet Packages, 

Manually add a reference to the assembly. To do this, download and unpack the latest release of CircleAnglePicker.

Use the menu Project => Add Reference. In the window that appears, go to the Browse tab and find the CircleAnglePicker.dll file of the same version of the .NET Framework as in your project.

NOTE

This method can be convenient for older versions of
Visual Studio (2010 and earlier). If possible, it is better to use the first installation method, using NuGet.

Usage

CircleAnglePicker control is very easy to use.

Place the CircleAnglePicker control on the form.

NOTE

If for some reason you can not find the
CircleAnglePicker control in the Toolbox panel, right-click on the Toolbox, select the “Choose Items…” menu and in the window that appears, browse and select the CircleAnglePicker.dll file.

All property values of the control instance placed on the form can be left by default.

The main property is Value. When the value of the Value property changes, a ValueChanged event occurs. You can create a handler for this event by simply double-clicking on the CircleAnglePicker control instance on the form.



You can place an instance of NumericUpDown on the form and use it with CircleAnglePicker, as shown in the following example,

  1. public partial class Form1: Form {  
  2.     public Form1() {  
  3.         InitializeComponent();  
  4.     }  
  5.     private void Form1_Load(object sender, EventArgs e) {  
  6.         // set min and max value to numericUpDown1  
  7.         numericUpDown1.Minimum = -180;  
  8.         numericUpDown1.Maximum = 180;  
  9.         // set value to circleAnglePicker1  
  10.         circleAnglePicker1.Value = 45;  
  11.         // call handler  
  12.         circleAnglePicker1_ValueChanged(circleAnglePicker1, null);  
  13.     }  
  14.     private void circleAnglePicker1_ValueChanged(object sender, EventArgs e) {  
  15.         // set value from circleAnglePicker1 to the numericUpDown1  
  16.         numericUpDown1.Value = circleAnglePicker1.Value;  
  17.     }  
  18.     private void numericUpDown1_ValueChanged(object sender, EventArgs e) {  
  19.         // set value from numericUpDown1 to the circleAnglePicker1  
  20.         circleAnglePicker1.Value = (int) numericUpDown1.Value;  
  21.     }  
  22. }  

 

If desired, you can customize the appearance of CircleAnglePicker control.

 

Enjoy!