-
Notifications
You must be signed in to change notification settings - Fork 2
/
AzimuthAngleEditor.cs
89 lines (79 loc) · 3.31 KB
/
AzimuthAngleEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// ********************************************************************************************************
// Product Name: DotSpatial.Symbology.Forms.dll
// Description: The Windows Forms user interface layer for the DotSpatial.Symbology library.
// ********************************************************************************************************
// The contents of this file are subject to the MIT License (MIT)
// you may not use this file except in compliance with the License. You may obtain a copy of the License at
// http://dotspatial.codeplex.com/license
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
// ANY KIND, either expressed or implied. See the License for the specific language governing rights and
// limitations under the License.
//
// The Original Code is from MapWindow.dll version 6.0
//
// The Initial Developer of this Original Code is Ted Dunsford. Created 3/7/2009 2:14:56 PM
//
// Contributor(s): (Open source contributors should list themselves and their modifications here).
//
// ********************************************************************************************************
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;
namespace DotSpatial.Symbology.Forms
{
/// <summary>
/// CharacterCodeEditor
/// </summary>
public class AzimuthAngleEditor : UITypeEditor
{
IWindowsFormsEditorService _dialogProvider;
#region Methods
/// <summary>
/// Edits a value based on some user input which is collected from a character control.
/// </summary>
/// <param name="context"></param>
/// <param name="provider"></param>
/// <param name="value"></param>
/// <returns></returns>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
_dialogProvider = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
AngleControl ac = new AngleControl();
ac.StartAngle = 90;
ac.Clockwise = true;
ac.Angle = Convert.ToInt32(value);
ac.AngleChosen += AcAngleChosen;
if (_dialogProvider != null) _dialogProvider.DropDownControl(ac);
return (double)ac.Angle;
}
private void AcAngleChosen(object sender, EventArgs e)
{
_dialogProvider.CloseDropDown();
}
/// <summary>
/// Gets the UITypeEditorEditStyle, which in this case is drop down.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.DropDown;
}
#endregion
#region Properties
/// <summary>
/// Ensures that we can widen the drop-down without having to close the drop down,
/// widen the control, and re-open it again.
/// </summary>
public override bool IsDropDownResizable
{
get
{
return true;
}
}
#endregion
}
}