Skip to content

Commit d9bd68e

Browse files
authored
Merge pull request #9 from nutdotnet/master
Various changes thanks to @PaulMartinsen
2 parents 6bba6c4 + b0d1d99 commit d9bd68e

12 files changed

+1342
-416
lines changed

.gitignore

+396-7
Large diffs are not rendered by default.

AGauge/AGauge.cs

+217-405
Large diffs are not rendered by default.

AGauge/AGauge.csproj

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,8 +10,9 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>System.Windows.Forms</RootNamespace>
1212
<AssemblyName>AGauge</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkProfile />
1516
</PropertyGroup>
1617
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1718
<DebugSymbols>true</DebugSymbols>
@@ -21,6 +22,7 @@
2122
<DefineConstants>DEBUG;TRACE</DefineConstants>
2223
<ErrorReport>prompt</ErrorReport>
2324
<WarningLevel>4</WarningLevel>
25+
<Prefer32Bit>false</Prefer32Bit>
2426
</PropertyGroup>
2527
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2628
<DebugType>pdbonly</DebugType>
@@ -29,6 +31,7 @@
2931
<DefineConstants>TRACE</DefineConstants>
3032
<ErrorReport>prompt</ErrorReport>
3133
<WarningLevel>4</WarningLevel>
34+
<Prefer32Bit>false</Prefer32Bit>
3235
</PropertyGroup>
3336
<ItemGroup>
3437
<Reference Include="System" />
@@ -48,7 +51,15 @@
4851
<Compile Include="AGauge.Designer.cs">
4952
<DependentUpon>AGauge.cs</DependentUpon>
5053
</Compile>
54+
<Compile Include="AGaugeLabel.cs" />
55+
<Compile Include="AGaugeLabelCollection.cs" />
56+
<Compile Include="AGaugeNeedleColor.cs" />
57+
<Compile Include="AGaugeRange.cs" />
58+
<Compile Include="AGaugeRangeCollection.cs" />
59+
<Compile Include="Categories.cs" />
60+
<Compile Include="NeedleType.cs" />
5161
<Compile Include="Properties\AssemblyInfo.cs" />
62+
<Compile Include="ValueInRangeChangedEventArgs.cs" />
5263
</ItemGroup>
5364
<ItemGroup>
5465
<None Include="AGauge - FxCop.FxCop" />

AGauge/AGaugeLabel.cs

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright (C) 2007 A.J.Bauer
2+
//
3+
// This software is provided as-is, without any express or implied
4+
// warranty. In no event will the authors be held liable for any damages
5+
// arising from the use of this software.
6+
7+
// Permission is granted to anyone to use this software for any purpose,
8+
// including commercial applications, and to alter it and redistribute it
9+
// freely, subject to the following restrictions:
10+
// 1. The origin of this software must not be misrepresented; you must not
11+
// claim that you wrote the original software. if you use this software
12+
// in a product, an acknowledgment in the product documentation would be
13+
// appreciated but is not required.
14+
// 2. Altered source versions must be plainly marked as such, and must not be
15+
// misrepresented as being the original software.
16+
// 3. This notice may not be removed or altered from any source distribution.
17+
//
18+
// -----------------------------------------------------------------------------------
19+
// Copyright (C) 2012 Code Artist
20+
//
21+
// Added several improvement to original code created by A.J.Bauer.
22+
// Visit: http://codearteng.blogspot.com for more information on change history.
23+
//
24+
// -----------------------------------------------------------------------------------
25+
26+
using System.Drawing;
27+
28+
namespace System.Windows.Forms
29+
{
30+
public class AGaugeLabel
31+
{
32+
[System.ComponentModel.Browsable(true),
33+
System.ComponentModel.Category("Design"),
34+
System.ComponentModel.DisplayName("(Name)"),
35+
System.ComponentModel.Description("Instance Name.")]
36+
public string Name { get { return _Name; } set { NotifyChanging(); _Name = value; NotifyChanged(); } }
37+
private string _Name;
38+
39+
[System.ComponentModel.Browsable(false)]
40+
public void SetOwner(AGauge value) { Owner = value; }
41+
private AGauge Owner;
42+
43+
private void NotifyOwner() { if (Owner != null) Owner.RepaintControl(); }
44+
45+
private void NotifyChanging()
46+
{
47+
if (Owner != null)
48+
{
49+
Owner.NotifyChanging(nameof(AGauge.GaugeLabels));
50+
}
51+
}
52+
53+
private void NotifyChanged()
54+
{
55+
if (Owner != null)
56+
{
57+
Owner.NotifyChanged(nameof(AGauge.GaugeLabels));
58+
}
59+
}
60+
61+
[System.ComponentModel.Browsable(true),
62+
System.ComponentModel.Category("Appearance"),
63+
System.ComponentModel.Description("The color of the caption text.")]
64+
public Color Color { get { return _Color; } set { NotifyChanging(); _Color = value; NotifyOwner(); NotifyChanged(); } }
65+
private Color _Color = Color.FromKnownColor(KnownColor.WindowText);
66+
67+
[System.ComponentModel.Browsable(true),
68+
System.ComponentModel.Category("Appearance"),
69+
System.ComponentModel.Description("The text of the caption.")]
70+
public String Text { get { return _Text; } set { NotifyChanging(); _Text = value; NotifyOwner(); NotifyChanged(); } }
71+
private String _Text;
72+
73+
[System.ComponentModel.Browsable(true),
74+
System.ComponentModel.Category("Appearance"),
75+
System.ComponentModel.Description("The position of the caption.")]
76+
public Point Position { get { return _Position; } set { NotifyChanging(); _Position = value; NotifyOwner(); NotifyChanged(); } }
77+
private Point _Position;
78+
79+
[System.ComponentModel.Browsable(true),
80+
System.ComponentModel.Category("Appearance"),
81+
System.ComponentModel.Description("Font of Text.")]
82+
public Font Font { get { return _Font; } set { NotifyChanging(); _Font = value; NotifyOwner(); NotifyChanged(); } }
83+
private Font _Font = DefaultFont;
84+
85+
public void ResetFont() { NotifyChanging(); _Font = DefaultFont; NotifyChanged(); }
86+
private Boolean ShouldSerializeFont() { return (_Font != DefaultFont); }
87+
private static Font DefaultFont = System.Windows.Forms.Control.DefaultFont;
88+
}
89+
}

AGauge/AGaugeLabelCollection.cs

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Copyright (C) 2007 A.J.Bauer
2+
//
3+
// This software is provided as-is, without any express or implied
4+
// warranty. In no event will the authors be held liable for any damages
5+
// arising from the use of this software.
6+
7+
// Permission is granted to anyone to use this software for any purpose,
8+
// including commercial applications, and to alter it and redistribute it
9+
// freely, subject to the following restrictions:
10+
// 1. The origin of this software must not be misrepresented; you must not
11+
// claim that you wrote the original software. if you use this software
12+
// in a product, an acknowledgment in the product documentation would be
13+
// appreciated but is not required.
14+
// 2. Altered source versions must be plainly marked as such, and must not be
15+
// misrepresented as being the original software.
16+
// 3. This notice may not be removed or altered from any source distribution.
17+
//
18+
// -----------------------------------------------------------------------------------
19+
// Copyright (C) 2012 Code Artist
20+
//
21+
// Added several improvement to original code created by A.J.Bauer.
22+
// Visit: http://codearteng.blogspot.com for more information on change history.
23+
//
24+
// -----------------------------------------------------------------------------------
25+
26+
using System.Collections;
27+
using System.ComponentModel.Design;
28+
29+
namespace System.Windows.Forms
30+
{
31+
public class AGaugeLabelCollection : CollectionBase
32+
{
33+
private readonly AGauge m_Owner;
34+
35+
public AGaugeLabelCollection(AGauge sender)
36+
{
37+
m_Owner = sender;
38+
}
39+
40+
private void NotifyChanging()
41+
{
42+
if (m_Owner != null)
43+
{
44+
m_Owner.NotifyChanging(nameof(AGauge.GaugeLabels));
45+
}
46+
}
47+
48+
private void NotifyChanged()
49+
{
50+
if (m_Owner != null)
51+
{
52+
m_Owner.NotifyChanged(nameof(AGauge.GaugeLabels));
53+
}
54+
}
55+
56+
public AGaugeLabel this[int index] { get { return (AGaugeLabel)List[index]; } }
57+
public bool Contains(AGaugeLabel itemType) { return List.Contains(itemType); }
58+
public int Add(AGaugeLabel itemType)
59+
{
60+
itemType.SetOwner(m_Owner);
61+
if (string.IsNullOrEmpty(itemType.Name)) itemType.Name = GetUniqueName();
62+
var ret = List.Add(itemType);
63+
if (m_Owner != null) m_Owner.RepaintControl();
64+
return ret;
65+
}
66+
public void Remove(AGaugeLabel itemType)
67+
{
68+
List.Remove(itemType);
69+
if (m_Owner != null) m_Owner.RepaintControl();
70+
}
71+
public void Insert(int index, AGaugeLabel itemType)
72+
{
73+
itemType.SetOwner(m_Owner);
74+
if (string.IsNullOrEmpty(itemType.Name)) itemType.Name = GetUniqueName();
75+
List.Insert(index, itemType);
76+
if (m_Owner != null) m_Owner.RepaintControl();
77+
}
78+
public int IndexOf(AGaugeLabel itemType) { return List.IndexOf(itemType); }
79+
public AGaugeLabel FindByName(string name)
80+
{
81+
foreach (AGaugeLabel ptrRange in List)
82+
{
83+
if (ptrRange.Name == name) return ptrRange;
84+
}
85+
return null;
86+
}
87+
88+
protected override void OnInsert(int index, object value)
89+
{
90+
NotifyChanging();
91+
var NewLabel = (AGaugeLabel)value;
92+
if (string.IsNullOrEmpty(NewLabel.Name))
93+
{
94+
NewLabel.Name = GetUniqueName();
95+
}
96+
NewLabel.SetOwner(m_Owner);
97+
}
98+
99+
protected override void OnInsertComplete(int index, object value)
100+
{
101+
if (m_Owner != null)
102+
{
103+
m_Owner.RepaintControl();
104+
}
105+
NotifyChanged();
106+
}
107+
108+
protected override void OnSet(int index, object oldValue, object newValue)
109+
{
110+
NotifyChanging();
111+
}
112+
113+
protected override void OnSetComplete(int index, object oldValue, object newValue)
114+
{
115+
m_Owner?.RepaintControl();
116+
NotifyChanged();
117+
}
118+
119+
protected override void OnRemove(int index, object value)
120+
{
121+
NotifyChanging();
122+
}
123+
124+
protected override void OnRemoveComplete(int index, object value)
125+
{
126+
if (m_Owner != null)
127+
{
128+
m_Owner.RepaintControl();
129+
}
130+
NotifyChanged();
131+
}
132+
133+
protected override void OnClear()
134+
{
135+
NotifyChanging();
136+
}
137+
138+
protected override void OnClearComplete()
139+
{
140+
if (m_Owner != null)
141+
{
142+
m_Owner.RepaintControl();
143+
}
144+
NotifyChanged();
145+
}
146+
147+
private string GetUniqueName()
148+
{
149+
const string Prefix = "GaugeLabel";
150+
int index = 1;
151+
while (this.Count != 0)
152+
{
153+
for (int x = 0; x < this.Count; x++)
154+
{
155+
if (this[x].Name == (Prefix + index.ToString()))
156+
continue;
157+
else
158+
return Prefix + index.ToString();
159+
}
160+
index++;
161+
};
162+
return Prefix + index.ToString();
163+
}
164+
}
165+
}

AGauge/AGaugeNeedleColor.cs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (C) 2007 A.J.Bauer
2+
//
3+
// This software is provided as-is, without any express or implied
4+
// warranty. In no event will the authors be held liable for any damages
5+
// arising from the use of this software.
6+
7+
// Permission is granted to anyone to use this software for any purpose,
8+
// including commercial applications, and to alter it and redistribute it
9+
// freely, subject to the following restrictions:
10+
// 1. The origin of this software must not be misrepresented; you must not
11+
// claim that you wrote the original software. if you use this software
12+
// in a product, an acknowledgment in the product documentation would be
13+
// appreciated but is not required.
14+
// 2. Altered source versions must be plainly marked as such, and must not be
15+
// misrepresented as being the original software.
16+
// 3. This notice may not be removed or altered from any source distribution.
17+
//
18+
// -----------------------------------------------------------------------------------
19+
// Copyright (C) 2012 Code Artist
20+
//
21+
// Added several improvement to original code created by A.J.Bauer.
22+
// Visit: http://codearteng.blogspot.com for more information on change history.
23+
//
24+
// -----------------------------------------------------------------------------------
25+
26+
namespace System.Windows.Forms
27+
{
28+
/// <summary>
29+
/// First needle color
30+
/// </summary>
31+
public enum AGaugeNeedleColor
32+
{
33+
Gray = 0,
34+
Red = 1,
35+
Green = 2,
36+
Blue = 3,
37+
Yellow = 4,
38+
Violet = 5,
39+
Magenta = 6,
40+
White = 7,
41+
};
42+
}

0 commit comments

Comments
 (0)