-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseColourControl.cs
102 lines (91 loc) · 2.83 KB
/
BaseColourControl.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
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ColourPickerComponents
{
public abstract partial class BaseColourControl : UserControl
{
// Event stuff
public event ColourEventHandler NewColour;
public delegate void ColourEventHandler(object sender, ColourEventArgs colourArgs);
public void OnNewColour(ColourEventArgs colourArgs)
{
// Note the copy to a local variable, so that we don't risk a
// NullReferenceException if another thread unsubscribes between the test and
// the invocation.
ColourEventHandler handler = NewColour;
if (handler != null)
{
handler(this, colourArgs);
}
}
// Mouse bools
protected bool mouseInRegion = false;
protected bool mouseDown = false;
public bool HasBeenClicked = false;
// Colour handler
protected ColourHandler.HSV HSV;
private bool showmarker = true;
[DefaultValue(true), Category("Appearance"), Description("Show a marker at the current selection.")]
public bool ShowMarker
{
get
{
return this.showmarker;
}
set
{
this.showmarker = value;
}
}
private const int MAXMARKERWIDTH = 5;
private int markerwidth = 2; // will be double
[DefaultValue(2), Category("Appearance"), Description("Size of position marker")]
public int MarkerWidth
{
get
{
if (this.showmarker)
{
return this.markerwidth;
}
else
{
return 0;
}
}
set
{
if (value == 0)
{
this.markerwidth = 0;
this.showmarker = false;
}
else if (value > 0 && value <= MAXMARKERWIDTH)
{
this.markerwidth = value;
}
else
{
throw new ArgumentOutOfRangeException("Invalid value. Value must be between 0 and " + MAXMARKERWIDTH.ToString());
}
}
}
public float MarkerPenWidth
{
get
{
return (float)Math.Ceiling((double)this.MarkerWidth / 2d);
}
}
public BaseColourControl()
{
InitializeComponent();
}
}
}