├── .gitignore
├── README.md
├── SevenSegTest.sln
├── SevenSegTest
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── SevenSegTest.csproj
└── SevenSegment
├── SevenSegment.cs
├── SevenSegment.csproj
├── SevenSegmentArray.cs
└── bin
└── Release
└── SevenSegment.dll
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]eleases/
17 | x64/
18 | x86/
19 | build/
20 | bld/
21 | [Oo]bj/
22 |
23 | # Visual Studo 2015 cache/options directory
24 | .vs/
25 |
26 | # MSTest test Results
27 | [Tt]est[Rr]esult*/
28 | [Bb]uild[Ll]og.*
29 |
30 | # NUNIT
31 | *.VisualState.xml
32 | TestResult.xml
33 |
34 | # Build Results of an ATL Project
35 | [Dd]ebugPS/
36 | [Rr]eleasePS/
37 | dlldata.c
38 |
39 | *_i.c
40 | *_p.c
41 | *_i.h
42 | *.ilk
43 | *.meta
44 | *.obj
45 | *.pch
46 | *.pdb
47 | *.pgc
48 | *.pgd
49 | *.rsp
50 | *.sbr
51 | *.tlb
52 | *.tli
53 | *.tlh
54 | *.tmp
55 | *.tmp_proj
56 | *.log
57 | *.vspscc
58 | *.vssscc
59 | .builds
60 | *.pidb
61 | *.svclog
62 | *.scc
63 |
64 | # Chutzpah Test files
65 | _Chutzpah*
66 |
67 | # Visual C++ cache files
68 | ipch/
69 | *.aps
70 | *.ncb
71 | *.opensdf
72 | *.sdf
73 | *.cachefile
74 |
75 | # Visual Studio profiler
76 | *.psess
77 | *.vsp
78 | *.vspx
79 |
80 | # TFS 2012 Local Workspace
81 | $tf/
82 |
83 | # Guidance Automation Toolkit
84 | *.gpState
85 |
86 | # ReSharper is a .NET coding add-in
87 | _ReSharper*/
88 | *.[Rr]e[Ss]harper
89 | *.DotSettings.user
90 |
91 | # JustCode is a .NET coding addin-in
92 | .JustCode
93 |
94 | # TeamCity is a build add-in
95 | _TeamCity*
96 |
97 | # DotCover is a Code Coverage Tool
98 | *.dotCover
99 |
100 | # NCrunch
101 | _NCrunch_*
102 | .*crunch*.local.xml
103 |
104 | # MightyMoose
105 | *.mm.*
106 | AutoTest.Net/
107 |
108 | # Web workbench (sass)
109 | .sass-cache/
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.[Pp]ublish.xml
129 | *.azurePubxml
130 | # TODO: Comment the next line if you want to checkin your web deploy settings
131 | # but database connection strings (with potential passwords) will be unencrypted
132 | *.pubxml
133 | *.publishproj
134 |
135 | # NuGet Packages
136 | *.nupkg
137 | # The packages folder can be ignored because of Package Restore
138 | **/packages/*
139 | # except build/, which is used as an MSBuild target.
140 | !**/packages/build/
141 | # Uncomment if necessary however generally it will be regenerated when needed
142 | #!**/packages/repositories.config
143 |
144 | # Windows Azure Build Output
145 | csx/
146 | *.build.csdef
147 |
148 | # Windows Store app package directory
149 | AppPackages/
150 |
151 | # Others
152 | *.[Cc]ache
153 | ClientBin/
154 | [Ss]tyle[Cc]op.*
155 | ~$*
156 | *~
157 | *.dbmdl
158 | *.dbproj.schemaview
159 | *.pfx
160 | *.publishsettings
161 | node_modules/
162 | bower_components/
163 |
164 | # RIA/Silverlight projects
165 | Generated_Code/
166 |
167 | # Backup & report files from converting an old project file
168 | # to a newer Visual Studio version. Backup files are not needed,
169 | # because we have git ;-)
170 | _UpgradeReport_Files/
171 | Backup*/
172 | UpgradeLog*.XML
173 | UpgradeLog*.htm
174 |
175 | # SQL Server files
176 | *.mdf
177 | *.ldf
178 |
179 | # Business Intelligence projects
180 | *.rdl.data
181 | *.bim.layout
182 | *.bim_*.settings
183 |
184 | # Microsoft Fakes
185 | FakesAssemblies/
186 |
187 | # Node.js Tools for Visual Studio
188 | .ntvs_analysis.dat
189 |
190 | # Visual Studio 6 build log
191 | *.plg
192 |
193 | # Visual Studio 6 workspace options file
194 | *.opt
195 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SevenSegment
2 |
3 | A full-featured .NET seven-segment control for WinForms.
4 |
5 | Copyright 2009-2020 Dmitry Brant. All Rights Reserved.
6 |
7 | me@dmitrybrant.com, https://dmitrybrant.com
8 |
9 | This component is free for personal use.
10 | If you would like to use it in a commercial application, please e-mail me at the address above.
11 | This software comes as-is, with no warranty.
12 |
--------------------------------------------------------------------------------
/SevenSegTest.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27004.2002
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SevenSegTest", "SevenSegTest\SevenSegTest.csproj", "{F619AEED-0AF6-4757-AC05-FBE94BF0FBAE}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SevenSegment", "SevenSegment\SevenSegment.csproj", "{00DB5A9C-12D3-43B0-9E4A-D9ECA873F5C9}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {F619AEED-0AF6-4757-AC05-FBE94BF0FBAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {F619AEED-0AF6-4757-AC05-FBE94BF0FBAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {F619AEED-0AF6-4757-AC05-FBE94BF0FBAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {F619AEED-0AF6-4757-AC05-FBE94BF0FBAE}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {00DB5A9C-12D3-43B0-9E4A-D9ECA873F5C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {00DB5A9C-12D3-43B0-9E4A-D9ECA873F5C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {00DB5A9C-12D3-43B0-9E4A-D9ECA873F5C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {00DB5A9C-12D3-43B0-9E4A-D9ECA873F5C9}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {0BD5657F-A3C4-45D6-A17C-A548A8935E59}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/SevenSegTest/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SevenSegTest
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.textBox1 = new System.Windows.Forms.TextBox();
34 | this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
35 | this.label2 = new System.Windows.Forms.Label();
36 | this.groupBox1 = new System.Windows.Forms.GroupBox();
37 | this.chkDotOn = new System.Windows.Forms.CheckBox();
38 | this.chkDotShow = new System.Windows.Forms.CheckBox();
39 | this.textBox2 = new System.Windows.Forms.TextBox();
40 | this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
41 | this.label3 = new System.Windows.Forms.Label();
42 | this.label4 = new System.Windows.Forms.Label();
43 | this.groupBox2 = new System.Windows.Forms.GroupBox();
44 | this.chkColonOn = new System.Windows.Forms.CheckBox();
45 | this.chkColonShow = new System.Windows.Forms.CheckBox();
46 | this.sevenSegmentArray1 = new DmitryBrant.CustomControls.SevenSegmentArray();
47 | this.sevenSegment1 = new DmitryBrant.CustomControls.SevenSegment();
48 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
49 | this.groupBox1.SuspendLayout();
50 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
51 | this.groupBox2.SuspendLayout();
52 | this.SuspendLayout();
53 | //
54 | // label1
55 | //
56 | resources.ApplyResources(this.label1, "label1");
57 | this.label1.Name = "label1";
58 | //
59 | // textBox1
60 | //
61 | resources.ApplyResources(this.textBox1, "textBox1");
62 | this.textBox1.Name = "textBox1";
63 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
64 | //
65 | // numericUpDown1
66 | //
67 | resources.ApplyResources(this.numericUpDown1, "numericUpDown1");
68 | this.numericUpDown1.Maximum = new decimal(new int[] {
69 | 127,
70 | 0,
71 | 0,
72 | 0});
73 | this.numericUpDown1.Name = "numericUpDown1";
74 | this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
75 | //
76 | // label2
77 | //
78 | resources.ApplyResources(this.label2, "label2");
79 | this.label2.Name = "label2";
80 | //
81 | // groupBox1
82 | //
83 | this.groupBox1.Controls.Add(this.chkDotOn);
84 | this.groupBox1.Controls.Add(this.chkDotShow);
85 | resources.ApplyResources(this.groupBox1, "groupBox1");
86 | this.groupBox1.Name = "groupBox1";
87 | this.groupBox1.TabStop = false;
88 | //
89 | // chkDotOn
90 | //
91 | resources.ApplyResources(this.chkDotOn, "chkDotOn");
92 | this.chkDotOn.Name = "chkDotOn";
93 | this.chkDotOn.UseVisualStyleBackColor = true;
94 | this.chkDotOn.CheckedChanged += new System.EventHandler(this.chkDotShow_CheckedChanged);
95 | //
96 | // chkDotShow
97 | //
98 | resources.ApplyResources(this.chkDotShow, "chkDotShow");
99 | this.chkDotShow.Checked = true;
100 | this.chkDotShow.CheckState = System.Windows.Forms.CheckState.Checked;
101 | this.chkDotShow.Name = "chkDotShow";
102 | this.chkDotShow.UseVisualStyleBackColor = true;
103 | this.chkDotShow.CheckedChanged += new System.EventHandler(this.chkDotShow_CheckedChanged);
104 | //
105 | // textBox2
106 | //
107 | resources.ApplyResources(this.textBox2, "textBox2");
108 | this.textBox2.Name = "textBox2";
109 | this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
110 | //
111 | // numericUpDown2
112 | //
113 | resources.ApplyResources(this.numericUpDown2, "numericUpDown2");
114 | this.numericUpDown2.Maximum = new decimal(new int[] {
115 | 32,
116 | 0,
117 | 0,
118 | 0});
119 | this.numericUpDown2.Name = "numericUpDown2";
120 | this.numericUpDown2.Value = new decimal(new int[] {
121 | 8,
122 | 0,
123 | 0,
124 | 0});
125 | this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
126 | //
127 | // label3
128 | //
129 | resources.ApplyResources(this.label3, "label3");
130 | this.label3.Name = "label3";
131 | //
132 | // label4
133 | //
134 | resources.ApplyResources(this.label4, "label4");
135 | this.label4.Name = "label4";
136 | //
137 | // groupBox2
138 | //
139 | this.groupBox2.Controls.Add(this.chkColonOn);
140 | this.groupBox2.Controls.Add(this.chkColonShow);
141 | resources.ApplyResources(this.groupBox2, "groupBox2");
142 | this.groupBox2.Name = "groupBox2";
143 | this.groupBox2.TabStop = false;
144 | //
145 | // chkColonOn
146 | //
147 | resources.ApplyResources(this.chkColonOn, "chkColonOn");
148 | this.chkColonOn.Name = "chkColonOn";
149 | this.chkColonOn.UseVisualStyleBackColor = true;
150 | this.chkColonOn.CheckedChanged += new System.EventHandler(this.chkDotShow_CheckedChanged);
151 | //
152 | // chkColonShow
153 | //
154 | resources.ApplyResources(this.chkColonShow, "chkColonShow");
155 | this.chkColonShow.Name = "chkColonShow";
156 | this.chkColonShow.UseVisualStyleBackColor = true;
157 | this.chkColonShow.CheckedChanged += new System.EventHandler(this.chkDotShow_CheckedChanged);
158 | //
159 | // sevenSegmentArray1
160 | //
161 | resources.ApplyResources(this.sevenSegmentArray1, "sevenSegmentArray1");
162 | this.sevenSegmentArray1.ArrayCount = 8;
163 | this.sevenSegmentArray1.ColorBackground = System.Drawing.Color.Black;
164 | this.sevenSegmentArray1.ColorDark = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
165 | this.sevenSegmentArray1.ColorLight = System.Drawing.Color.Red;
166 | this.sevenSegmentArray1.DecimalShow = true;
167 | this.sevenSegmentArray1.ElementPadding = new System.Windows.Forms.Padding(6, 4, 4, 4);
168 | this.sevenSegmentArray1.ElementWidth = 10;
169 | this.sevenSegmentArray1.ItalicFactor = -0.1F;
170 | this.sevenSegmentArray1.Name = "sevenSegmentArray1";
171 | this.sevenSegmentArray1.TabStop = false;
172 | this.sevenSegmentArray1.Value = "";
173 | //
174 | // sevenSegment1
175 | //
176 | this.sevenSegment1.ColonOn = false;
177 | this.sevenSegment1.ColonShow = false;
178 | this.sevenSegment1.ColorBackground = System.Drawing.Color.DimGray;
179 | this.sevenSegment1.ColorDark = System.Drawing.Color.DarkGray;
180 | this.sevenSegment1.ColorLight = System.Drawing.Color.Lime;
181 | this.sevenSegment1.CustomPattern = 0;
182 | this.sevenSegment1.DecimalOn = false;
183 | this.sevenSegment1.DecimalShow = true;
184 | this.sevenSegment1.ElementWidth = 10;
185 | this.sevenSegment1.ItalicFactor = -0.07F;
186 | resources.ApplyResources(this.sevenSegment1, "sevenSegment1");
187 | this.sevenSegment1.Name = "sevenSegment1";
188 | this.sevenSegment1.TabStop = false;
189 | this.sevenSegment1.Value = null;
190 | //
191 | // Form1
192 | //
193 | resources.ApplyResources(this, "$this");
194 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
195 | this.Controls.Add(this.groupBox2);
196 | this.Controls.Add(this.label4);
197 | this.Controls.Add(this.label3);
198 | this.Controls.Add(this.numericUpDown2);
199 | this.Controls.Add(this.textBox2);
200 | this.Controls.Add(this.sevenSegmentArray1);
201 | this.Controls.Add(this.sevenSegment1);
202 | this.Controls.Add(this.groupBox1);
203 | this.Controls.Add(this.label2);
204 | this.Controls.Add(this.numericUpDown1);
205 | this.Controls.Add(this.textBox1);
206 | this.Controls.Add(this.label1);
207 | this.Name = "Form1";
208 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
209 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
210 | this.groupBox1.ResumeLayout(false);
211 | this.groupBox1.PerformLayout();
212 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
213 | this.groupBox2.ResumeLayout(false);
214 | this.groupBox2.PerformLayout();
215 | this.ResumeLayout(false);
216 | this.PerformLayout();
217 |
218 | }
219 |
220 | #endregion
221 |
222 | private System.Windows.Forms.Label label1;
223 | private System.Windows.Forms.TextBox textBox1;
224 | private System.Windows.Forms.NumericUpDown numericUpDown1;
225 | private System.Windows.Forms.Label label2;
226 | private System.Windows.Forms.GroupBox groupBox1;
227 | private System.Windows.Forms.CheckBox chkDotOn;
228 | private System.Windows.Forms.CheckBox chkDotShow;
229 | private DmitryBrant.CustomControls.SevenSegment sevenSegment1;
230 | private DmitryBrant.CustomControls.SevenSegmentArray sevenSegmentArray1;
231 | private System.Windows.Forms.TextBox textBox2;
232 | private System.Windows.Forms.NumericUpDown numericUpDown2;
233 | private System.Windows.Forms.Label label3;
234 | private System.Windows.Forms.Label label4;
235 | private System.Windows.Forms.GroupBox groupBox2;
236 | private System.Windows.Forms.CheckBox chkColonOn;
237 | private System.Windows.Forms.CheckBox chkColonShow;
238 |
239 |
240 | }
241 | }
242 |
243 |
--------------------------------------------------------------------------------
/SevenSegTest/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace SevenSegTest
5 | {
6 | public partial class Form1 : Form
7 | {
8 | public Form1()
9 | {
10 | InitializeComponent();
11 |
12 | textBox1.Text = "5";
13 | textBox2.Text = "3.1415";
14 | }
15 |
16 | private void textBox1_TextChanged(object sender, EventArgs e)
17 | {
18 | sevenSegment1.Value = textBox1.Text;
19 | }
20 |
21 | private void numericUpDown1_ValueChanged(object sender, EventArgs e)
22 | {
23 | sevenSegment1.CustomPattern = (int)numericUpDown1.Value;
24 | }
25 |
26 | private void chkDotShow_CheckedChanged(object sender, EventArgs e)
27 | {
28 | sevenSegment1.DecimalShow = chkDotShow.Checked;
29 | sevenSegment1.DecimalOn = chkDotOn.Checked;
30 | sevenSegment1.ColonShow = chkColonShow.Checked;
31 | sevenSegment1.ColonOn = chkColonOn.Checked;
32 | }
33 |
34 | private void textBox2_TextChanged(object sender, EventArgs e)
35 | {
36 | sevenSegmentArray1.Value = textBox2.Text;
37 | }
38 |
39 | private void numericUpDown2_ValueChanged(object sender, EventArgs e)
40 | {
41 | sevenSegmentArray1.ArrayCount = (int)numericUpDown2.Value;
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SevenSegTest/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | True
123 |
124 |
125 |
126 | 25, 15
127 |
128 |
129 | 44, 13
130 |
131 |
132 | 3
133 |
134 |
135 | Symbol:
136 |
137 |
138 | label1
139 |
140 |
141 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
142 |
143 |
144 | $this
145 |
146 |
147 | 11
148 |
149 |
150 | 75, 12
151 |
152 |
153 | 1
154 |
155 |
156 | 46, 20
157 |
158 |
159 | 0
160 |
161 |
162 | textBox1
163 |
164 |
165 | System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
166 |
167 |
168 | $this
169 |
170 |
171 | 10
172 |
173 |
174 | 75, 38
175 |
176 |
177 | 46, 20
178 |
179 |
180 | 1
181 |
182 |
183 | numericUpDown1
184 |
185 |
186 | System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
187 |
188 |
189 | $this
190 |
191 |
192 | 9
193 |
194 |
195 | True
196 |
197 |
198 | 25, 40
199 |
200 |
201 | 44, 13
202 |
203 |
204 | 6
205 |
206 |
207 | Pattern:
208 |
209 |
210 | label2
211 |
212 |
213 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
214 |
215 |
216 | $this
217 |
218 |
219 | 8
220 |
221 |
222 | True
223 |
224 |
225 | 63, 21
226 |
227 |
228 | 40, 17
229 |
230 |
231 | 3
232 |
233 |
234 | On
235 |
236 |
237 | chkDotOn
238 |
239 |
240 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
241 |
242 |
243 | groupBox1
244 |
245 |
246 | 0
247 |
248 |
249 | True
250 |
251 |
252 | 10, 21
253 |
254 |
255 | 53, 17
256 |
257 |
258 | 2
259 |
260 |
261 | Show
262 |
263 |
264 | chkDotShow
265 |
266 |
267 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
268 |
269 |
270 | groupBox1
271 |
272 |
273 | 1
274 |
275 |
276 | 12, 64
277 |
278 |
279 | 112, 49
280 |
281 |
282 | 2
283 |
284 |
285 | Decimal point
286 |
287 |
288 | groupBox1
289 |
290 |
291 | System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
292 |
293 |
294 | $this
295 |
296 |
297 | 7
298 |
299 |
300 |
301 | Bottom, Left
302 |
303 |
304 | 180, 202
305 |
306 |
307 | 139, 20
308 |
309 |
310 | 9
311 |
312 |
313 | textBox2
314 |
315 |
316 | System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
317 |
318 |
319 | $this
320 |
321 |
322 | 4
323 |
324 |
325 | Bottom, Left
326 |
327 |
328 | 71, 202
329 |
330 |
331 | 52, 20
332 |
333 |
334 | 10
335 |
336 |
337 | numericUpDown2
338 |
339 |
340 | System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
341 |
342 |
343 | $this
344 |
345 |
346 | 3
347 |
348 |
349 | Bottom, Left
350 |
351 |
352 | True
353 |
354 |
355 | 12, 205
356 |
357 |
358 | 53, 13
359 |
360 |
361 | 11
362 |
363 |
364 | Elements:
365 |
366 |
367 | label3
368 |
369 |
370 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
371 |
372 |
373 | $this
374 |
375 |
376 | 2
377 |
378 |
379 | Bottom, Left
380 |
381 |
382 | True
383 |
384 |
385 | 143, 205
386 |
387 |
388 | 31, 13
389 |
390 |
391 | 12
392 |
393 |
394 | Text:
395 |
396 |
397 | label4
398 |
399 |
400 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
401 |
402 |
403 | $this
404 |
405 |
406 | 1
407 |
408 |
409 | True
410 |
411 |
412 | 63, 21
413 |
414 |
415 | 40, 17
416 |
417 |
418 | 3
419 |
420 |
421 | On
422 |
423 |
424 | chkColonOn
425 |
426 |
427 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
428 |
429 |
430 | groupBox2
431 |
432 |
433 | 0
434 |
435 |
436 | True
437 |
438 |
439 | 10, 21
440 |
441 |
442 | 53, 17
443 |
444 |
445 | 2
446 |
447 |
448 | Show
449 |
450 |
451 | chkColonShow
452 |
453 |
454 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
455 |
456 |
457 | groupBox2
458 |
459 |
460 | 1
461 |
462 |
463 | 12, 119
464 |
465 |
466 | 112, 49
467 |
468 |
469 | 13
470 |
471 |
472 | Colon
473 |
474 |
475 | groupBox2
476 |
477 |
478 | System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
479 |
480 |
481 | $this
482 |
483 |
484 | 0
485 |
486 |
487 | Bottom, Left, Right
488 |
489 |
490 | 12, 228
491 |
492 |
493 | 365, 69
494 |
495 |
496 | 8
497 |
498 |
499 | sevenSegmentArray1
500 |
501 |
502 | DmitryBrant.CustomControls.SevenSegmentArray, SevenSegTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
503 |
504 |
505 | $this
506 |
507 |
508 | 5
509 |
510 |
511 | 146, 15
512 |
513 |
514 | 12, 4, 8, 4
515 |
516 |
517 | 109, 153
518 |
519 |
520 | 7
521 |
522 |
523 | sevenSegment1
524 |
525 |
526 | DmitryBrant.CustomControls.SevenSegment, SevenSegTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
527 |
528 |
529 | $this
530 |
531 |
532 | 6
533 |
534 |
535 | True
536 |
537 |
538 | 6, 13
539 |
540 |
541 | 389, 309
542 |
543 |
544 | Seven-Segment Test
545 |
546 |
547 | Form1
548 |
549 |
550 | System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
551 |
552 |
--------------------------------------------------------------------------------
/SevenSegTest/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace SevenSegTest
5 | {
6 | static class Program
7 | {
8 | ///
9 | /// The main entry point for the application.
10 | ///
11 | [STAThread]
12 | static void Main()
13 | {
14 | Application.EnableVisualStyles();
15 | Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
16 | Application.SetCompatibleTextRenderingDefault(false);
17 | Application.Run(new Form1());
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/SevenSegTest/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18444
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SevenSegTest.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SevenSegTest.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/SevenSegTest/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/SevenSegTest/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18444
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SevenSegTest.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SevenSegTest/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SevenSegTest/SevenSegTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0-windows7.0
4 | WinExe
5 | false
6 | true
7 | true
8 | Dmitry Brant
9 | Copyright 2009- Dmitry Brant
10 |
11 |
12 |
13 | 3.5
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/SevenSegment/SevenSegment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using System.Drawing;
4 | using System.Drawing.Drawing2D;
5 |
6 | /*
7 | * Seven-segment LED control for .NET
8 | *
9 | * Copyright 2009-2019 Dmitry Brant. All Rights Reserved.
10 | * me@dmitrybrant.com
11 | * http://dmitrybrant.com
12 | *
13 | * This component is free for personal use.
14 | * If you would like to use it in a commercial application, please
15 | * e-mail me at the address above.
16 | * This software comes as-is, with no warranty.
17 | *
18 | * Features:
19 | * - Customizable colors
20 | * - Displays numbers and most letters, plus decimal point
21 | * - Supports custom LED patterns
22 | * - Customizable segment width and italics
23 | *
24 | */
25 |
26 | namespace DmitryBrant.CustomControls
27 | {
28 | public class SevenSegment : UserControl
29 | {
30 | private Point[][] segPoints;
31 |
32 | private int gridHeight = 80;
33 | private int gridWidth = 48;
34 | private int elementWidth = 10;
35 | private float italicFactor = 0.0F;
36 | private Color colorBackground = Color.DarkGray;
37 | private Color colorDark = Color.DimGray;
38 | private Color colorLight = Color.Red;
39 |
40 | private string theValue = null;
41 | private bool showDot = true, dotOn = false;
42 | private bool showColon = false, colonOn = false;
43 | private int customPattern = 0;
44 |
45 | ///
46 | /// These are the various bit patterns that represent the characters
47 | /// that can be displayed in the seven segments. Bits 0 through 6
48 | /// correspond to each of the LEDs, from top to bottom!
49 | ///
50 | public enum ValuePattern
51 | {
52 | None = 0x0, Zero = 0x77, One = 0x24, Two = 0x5D, Three = 0x6D,
53 | Four = 0x2E, Five = 0x6B, Six = 0x7B, Seven = 0x25,
54 | Eight = 0x7F, Nine = 0x6F, A = 0x3F, B = 0x7A, C = 0x53, c = 0x58,
55 | D = 0x7C, E = 0x5B, F = 0x1B, G = 0x73, H = 0x3E, h = 0x3A, i = 0x20,
56 | J = 0x74, L = 0x52, N = 0x38, o = 0x78, P = 0x1F, Q = 0x2F, R = 0x18,
57 | T = 0x5A, U = 0x76, u = 0x70, Y = 0x6E,
58 | Dash = 0x8, Equals = 0x48, Degrees = 0xF,
59 | Apostrophe = 0x2, Quote = 0x6, RBracket = 0x65,
60 | Underscore = 0x40, Identical = 0x49, Not = 0x28
61 | }
62 |
63 | public SevenSegment()
64 | {
65 | SuspendLayout();
66 | Name = "SevenSegment";
67 | Size = new Size(32, 64);
68 | Paint += new PaintEventHandler(SevenSegment_Paint);
69 | Resize += new EventHandler(SevenSegment_Resize);
70 | ResumeLayout(false);
71 |
72 | TabStop = false;
73 | Padding = new Padding(4, 4, 4, 4);
74 | DoubleBuffered = true;
75 |
76 | segPoints = new Point[7][];
77 | for (int i = 0; i < 7; i++) segPoints[i] = new Point[6];
78 |
79 | RecalculatePoints();
80 | }
81 |
82 | ///
83 | /// Recalculate the points that represent the polygons of the
84 | /// seven segments, whether we're just initializing or
85 | /// changing the segment width.
86 | ///
87 | private void RecalculatePoints()
88 | {
89 | int halfHeight = gridHeight / 2, halfWidth = elementWidth / 2;
90 |
91 | int p = 0;
92 | segPoints[p][0].X = elementWidth + 1; segPoints[p][0].Y = 0;
93 | segPoints[p][1].X = gridWidth - elementWidth - 1; segPoints[p][1].Y = 0;
94 | segPoints[p][2].X = gridWidth - halfWidth - 1; segPoints[p][2].Y = halfWidth;
95 | segPoints[p][3].X = gridWidth - elementWidth - 1; segPoints[p][3].Y = elementWidth;
96 | segPoints[p][4].X = elementWidth + 1; segPoints[p][4].Y = elementWidth;
97 | segPoints[p][5].X = halfWidth + 1; segPoints[p][5].Y = halfWidth;
98 |
99 | p++;
100 | segPoints[p][0].X = 0; segPoints[p][0].Y = elementWidth + 1;
101 | segPoints[p][1].X = halfWidth; segPoints[p][1].Y = halfWidth + 1;
102 | segPoints[p][2].X = elementWidth; segPoints[p][2].Y = elementWidth + 1;
103 | segPoints[p][3].X = elementWidth; segPoints[p][3].Y = halfHeight - halfWidth - 1;
104 | segPoints[p][4].X = 4; segPoints[p][4].Y = halfHeight - 1;
105 | segPoints[p][5].X = 0; segPoints[p][5].Y = halfHeight - 1;
106 |
107 | p++;
108 | segPoints[p][0].X = gridWidth - elementWidth; segPoints[p][0].Y = elementWidth + 1;
109 | segPoints[p][1].X = gridWidth - halfWidth; segPoints[p][1].Y = halfWidth + 1;
110 | segPoints[p][2].X = gridWidth; segPoints[p][2].Y = elementWidth + 1;
111 | segPoints[p][3].X = gridWidth; segPoints[p][3].Y = halfHeight - 1;
112 | segPoints[p][4].X = gridWidth - 4; segPoints[p][4].Y = halfHeight - 1;
113 | segPoints[p][5].X = gridWidth - elementWidth; segPoints[p][5].Y = halfHeight - halfWidth - 1;
114 |
115 | p++;
116 | segPoints[p][0].X = elementWidth + 1; segPoints[p][0].Y = halfHeight - halfWidth;
117 | segPoints[p][1].X = gridWidth - elementWidth - 1; segPoints[p][1].Y = halfHeight - halfWidth;
118 | segPoints[p][2].X = gridWidth - 5; segPoints[p][2].Y = halfHeight;
119 | segPoints[p][3].X = gridWidth - elementWidth - 1; segPoints[p][3].Y = halfHeight + halfWidth;
120 | segPoints[p][4].X = elementWidth + 1; segPoints[p][4].Y = halfHeight + halfWidth;
121 | segPoints[p][5].X = 5; segPoints[p][5].Y = halfHeight;
122 |
123 | p++;
124 | segPoints[p][0].X = 0; segPoints[p][0].Y = halfHeight + 1;
125 | segPoints[p][1].X = 4; segPoints[p][1].Y = halfHeight + 1;
126 | segPoints[p][2].X = elementWidth; segPoints[p][2].Y = halfHeight + halfWidth + 1;
127 | segPoints[p][3].X = elementWidth; segPoints[p][3].Y = gridHeight - elementWidth - 1;
128 | segPoints[p][4].X = halfWidth; segPoints[p][4].Y = gridHeight - halfWidth - 1;
129 | segPoints[p][5].X = 0; segPoints[p][5].Y = gridHeight - elementWidth - 1;
130 |
131 | p++;
132 | segPoints[p][0].X = gridWidth - elementWidth; segPoints[p][0].Y = halfHeight + halfWidth + 1;
133 | segPoints[p][1].X = gridWidth - 4; segPoints[p][1].Y = halfHeight + 1;
134 | segPoints[p][2].X = gridWidth; segPoints[p][2].Y = halfHeight + 1;
135 | segPoints[p][3].X = gridWidth; segPoints[p][3].Y = gridHeight - elementWidth - 1;
136 | segPoints[p][4].X = gridWidth - halfWidth; segPoints[p][4].Y = gridHeight - halfWidth - 1;
137 | segPoints[p][5].X = gridWidth - elementWidth; segPoints[p][5].Y = gridHeight - elementWidth - 1;
138 |
139 | p++;
140 | segPoints[p][0].X = elementWidth + 1; segPoints[p][0].Y = gridHeight - elementWidth;
141 | segPoints[p][1].X = gridWidth - elementWidth - 1; segPoints[p][1].Y = gridHeight - elementWidth;
142 | segPoints[p][2].X = gridWidth - halfWidth - 1; segPoints[p][2].Y = gridHeight - halfWidth;
143 | segPoints[p][3].X = gridWidth - elementWidth - 1; segPoints[p][3].Y = gridHeight;
144 | segPoints[p][4].X = elementWidth + 1; segPoints[p][4].Y = gridHeight;
145 | segPoints[p][5].X = halfWidth + 1; segPoints[p][5].Y = gridHeight - halfWidth;
146 | }
147 |
148 | ///
149 | /// Background color of the 7-segment display.
150 | ///
151 | public Color ColorBackground { get { return colorBackground; } set { colorBackground = value; Invalidate(); } }
152 | ///
153 | /// Color of inactive LED segments.
154 | ///
155 | public Color ColorDark { get { return colorDark; } set { colorDark = value; Invalidate(); } }
156 | ///
157 | /// Color of active LED segments.
158 | ///
159 | public Color ColorLight { get { return colorLight; } set { colorLight = value; Invalidate(); } }
160 |
161 | ///
162 | /// Width of LED segments.
163 | ///
164 | public int ElementWidth { get { return elementWidth; } set { elementWidth = value; RecalculatePoints(); Invalidate(); } }
165 | ///
166 | /// Shear coefficient for italicizing the displays. Try a value like -0.1.
167 | ///
168 | public float ItalicFactor { get { return italicFactor; } set { italicFactor = value; Invalidate(); } }
169 |
170 | private void SevenSegment_Resize(object sender, EventArgs e) { Invalidate(); }
171 | protected override void OnPaddingChanged(EventArgs e) { base.OnPaddingChanged(e); Invalidate(); }
172 |
173 | protected override void OnPaintBackground(PaintEventArgs e)
174 | {
175 | //base.OnPaintBackground(e);
176 | e.Graphics.Clear(colorBackground);
177 | }
178 |
179 | ///
180 | /// Character to be displayed on the seven segments. Supported characters
181 | /// are digits and most letters.
182 | ///
183 | public string Value
184 | {
185 | get { return theValue; }
186 | set
187 | {
188 | customPattern = 0;
189 | theValue = value;
190 | Invalidate();
191 | if (value == null || value.Length == 0)
192 | {
193 | return;
194 | }
195 | //is it an integer?
196 | int tempValue;
197 | if (int.TryParse(value, out tempValue))
198 | {
199 | if (tempValue > 9) tempValue = 9; if (tempValue < 0) tempValue = 0;
200 | switch (tempValue)
201 | {
202 | case 0: customPattern = (int)ValuePattern.Zero; break;
203 | case 1: customPattern = (int)ValuePattern.One; break;
204 | case 2: customPattern = (int)ValuePattern.Two; break;
205 | case 3: customPattern = (int)ValuePattern.Three; break;
206 | case 4: customPattern = (int)ValuePattern.Four; break;
207 | case 5: customPattern = (int)ValuePattern.Five; break;
208 | case 6: customPattern = (int)ValuePattern.Six; break;
209 | case 7: customPattern = (int)ValuePattern.Seven; break;
210 | case 8: customPattern = (int)ValuePattern.Eight; break;
211 | case 9: customPattern = (int)ValuePattern.Nine; break;
212 | }
213 | }
214 | else
215 | {
216 | //is it a letter?
217 | switch (value[0])
218 | {
219 | case 'A': case 'a': customPattern = (int)ValuePattern.A; break;
220 | case 'B': case 'b': customPattern = (int)ValuePattern.B; break;
221 | case 'C': customPattern = (int)ValuePattern.C; break;
222 | case 'c': customPattern = (int)ValuePattern.c; break;
223 | case 'D': case 'd': customPattern = (int)ValuePattern.D; break;
224 | case 'E': case 'e': customPattern = (int)ValuePattern.E; break;
225 | case 'F': case 'f': customPattern = (int)ValuePattern.F; break;
226 | case 'G': case 'g': customPattern = (int)ValuePattern.G; break;
227 | case 'H': customPattern = (int)ValuePattern.H; break;
228 | case 'h': customPattern = (int)ValuePattern.h; break;
229 | case 'I': customPattern = (int)ValuePattern.One; break;
230 | case 'i': customPattern = (int)ValuePattern.i; break;
231 | case 'J': case 'j': customPattern = (int)ValuePattern.J; break;
232 | case 'L': case 'l': customPattern = (int)ValuePattern.L; break;
233 | case 'N': case 'n': customPattern = (int)ValuePattern.N; break;
234 | case 'O': customPattern = (int)ValuePattern.Zero; break;
235 | case 'o': customPattern = (int)ValuePattern.o; break;
236 | case 'P': case 'p': customPattern = (int)ValuePattern.P; break;
237 | case 'Q': case 'q': customPattern = (int)ValuePattern.Q; break;
238 | case 'R': case 'r': customPattern = (int)ValuePattern.R; break;
239 | case 'S': case 's': customPattern = (int)ValuePattern.Five; break;
240 | case 'T': case 't': customPattern = (int)ValuePattern.T; break;
241 | case 'U': customPattern = (int)ValuePattern.U; break;
242 | case 'u': case 'µ': case 'μ': customPattern = (int)ValuePattern.u; break;
243 | case 'Y': case 'y': customPattern = (int)ValuePattern.Y; break;
244 | case '-': customPattern = (int)ValuePattern.Dash; break;
245 | case '=': customPattern = (int)ValuePattern.Equals; break;
246 | case '°': customPattern = (int)ValuePattern.Degrees; break;
247 | case '\'': customPattern = (int)ValuePattern.Apostrophe; break;
248 | case '"': customPattern = (int)ValuePattern.Quote; break;
249 | case '[': case '{': customPattern = (int)ValuePattern.C; break;
250 | case ']': case '}': customPattern = (int)ValuePattern.RBracket; break;
251 | case '_': customPattern = (int)ValuePattern.Underscore; break;
252 | case '≡': customPattern = (int)ValuePattern.Identical; break;
253 | case '¬': customPattern = (int)ValuePattern.Not; break;
254 | }
255 | }
256 | }
257 | }
258 |
259 | ///
260 | /// Set a custom bit pattern to be displayed on the seven segments. This is an
261 | /// integer value where bits 0 through 6 correspond to each respective LED
262 | /// segment.
263 | ///
264 | public int CustomPattern { get { return customPattern; } set { customPattern = value; Invalidate(); } }
265 |
266 | ///
267 | /// Specifies if the decimal point LED is displayed.
268 | ///
269 | public bool DecimalShow { get { return showDot; } set { showDot = value; Invalidate(); } }
270 | ///
271 | /// Specifies if the decimal point LED is active.
272 | ///
273 | public bool DecimalOn { get { return dotOn; } set { dotOn = value; Invalidate(); } }
274 |
275 | ///
276 | /// Specifies if the colon LEDs are displayed.
277 | ///
278 | public bool ColonShow { get { return showColon; } set { showColon = value; Invalidate(); } }
279 | ///
280 | /// Specifies if the colon LEDs are active.
281 | ///
282 | public bool ColonOn { get { return colonOn; } set { colonOn = value; Invalidate(); } }
283 |
284 | private void SevenSegment_Paint(object sender, PaintEventArgs e)
285 | {
286 | int useValue = customPattern;
287 |
288 | Brush brushLight = new SolidBrush(colorLight);
289 | Brush brushDark = new SolidBrush(colorDark);
290 |
291 | // Define transformation for our container...
292 | RectangleF srcRect;
293 |
294 | int colonWidth = gridWidth / 4;
295 |
296 | if(showColon){
297 | srcRect = new RectangleF(0.0F, 0.0F, gridWidth + colonWidth, gridHeight);
298 | }else{
299 | srcRect = new RectangleF(0.0F, 0.0F, gridWidth, gridHeight);
300 | }
301 | RectangleF destRect = new RectangleF(Padding.Left, Padding.Top, Width - Padding.Left - Padding.Right, Height - Padding.Top - Padding.Bottom);
302 |
303 | // Begin graphics container that remaps coordinates for our convenience
304 | GraphicsContainer containerState = e.Graphics.BeginContainer(destRect, srcRect, GraphicsUnit.Pixel);
305 |
306 | Matrix trans = new Matrix();
307 | trans.Shear(italicFactor, 0.0F);
308 | e.Graphics.Transform = trans;
309 |
310 | e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
311 | e.Graphics.PixelOffsetMode = PixelOffsetMode.Default;
312 |
313 | // Draw elements based on whether the corresponding bit is high
314 | e.Graphics.FillPolygon((useValue & 0x1) == 0x1 ? brushLight : brushDark, segPoints[0]);
315 | e.Graphics.FillPolygon((useValue & 0x2) == 0x2 ? brushLight : brushDark, segPoints[1]);
316 | e.Graphics.FillPolygon((useValue & 0x4) == 0x4 ? brushLight : brushDark, segPoints[2]);
317 | e.Graphics.FillPolygon((useValue & 0x8) == 0x8 ? brushLight : brushDark, segPoints[3]);
318 | e.Graphics.FillPolygon((useValue & 0x10) == 0x10 ? brushLight : brushDark, segPoints[4]);
319 | e.Graphics.FillPolygon((useValue & 0x20) == 0x20 ? brushLight : brushDark, segPoints[5]);
320 | e.Graphics.FillPolygon((useValue & 0x40) == 0x40 ? brushLight : brushDark, segPoints[6]);
321 |
322 | if (showDot)
323 | e.Graphics.FillEllipse(dotOn ? brushLight : brushDark, gridWidth - 1, gridHeight - elementWidth + 1, elementWidth, elementWidth);
324 |
325 | if (showColon)
326 | {
327 | e.Graphics.FillEllipse(colonOn ? brushLight : brushDark, gridWidth + colonWidth - 4, gridHeight / 4 - elementWidth + 8, elementWidth, elementWidth);
328 | e.Graphics.FillEllipse(colonOn ? brushLight : brushDark, gridWidth + colonWidth - 4, gridHeight * 3 / 4 - elementWidth + 4, elementWidth, elementWidth);
329 | }
330 |
331 | e.Graphics.EndContainer(containerState);
332 | }
333 |
334 | }
335 | }
336 |
--------------------------------------------------------------------------------
/SevenSegment/SevenSegment.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0-windows7.0
4 | Library
5 | false
6 | true
7 | true
8 | Dmitry Brant
9 | A full-featured seven-segment control for Windows Forms.
10 | Copyright © 2009- Dmitry Brant
11 | https://dmitrybrant.com
12 |
13 |
14 |
15 | UserControl
16 |
17 |
18 | UserControl
19 |
20 |
21 |
--------------------------------------------------------------------------------
/SevenSegment/SevenSegmentArray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using System.Drawing;
4 |
5 | /*
6 | * Seven-segment LED array control for .NET
7 | * (uses the original seven-segment LED control)
8 | *
9 | * Copyright 2009-2019 Dmitry Brant. All Rights Reserved.
10 | * me@dmitrybrant.com
11 | * http://dmitrybrant.com
12 | *
13 | * This component is free for personal use.
14 | * If you would like to use it in a commercial application, please
15 | * e-mail me at the address above.
16 | * This software comes as-is, with no warranty.
17 | *
18 | * Features:
19 | * - Arbitrary number of array elements
20 | * - All the customizable settings of the original 7-seg control
21 | * - Accepts a string as a value, and distributes the characters
22 | * among the array elements, automatically handling decimal points.
23 | *
24 | */
25 |
26 | namespace DmitryBrant.CustomControls
27 | {
28 | public class SevenSegmentArray : UserControl
29 | {
30 | ///
31 | /// Array of segment controls that are currently children of this control.
32 | ///
33 | private SevenSegment[] segments = null;
34 |
35 | private int elementWidth = 10;
36 | private float italicFactor = 0.0F;
37 | private Color colorBackground = Color.DarkGray;
38 | private Color colorDark = Color.DimGray;
39 | private Color colorLight = Color.Red;
40 | private bool showDot = true;
41 | private Padding elementPadding;
42 |
43 | private string theValue = null;
44 |
45 | public SevenSegmentArray()
46 | {
47 | SuspendLayout();
48 | Name = "SevenSegmentArray";
49 | Size = new Size(100, 25);
50 | Resize += new EventHandler(SevenSegmentArray_Resize);
51 | ResumeLayout(false);
52 |
53 | TabStop = false;
54 | elementPadding = new Padding(4, 4, 4, 4);
55 | RecreateSegments(4);
56 | }
57 |
58 | ///
59 | /// Change the number of elements in our LED array. This destroys
60 | /// the previous elements, and creates new ones in their place, applying
61 | /// all the current options to the new ones.
62 | ///
63 | /// Number of elements to create.
64 | private void RecreateSegments(int count)
65 | {
66 | if (segments != null)
67 | for (int i = 0; i < segments.Length; i++) { segments[i].Parent = null; segments[i].Dispose(); }
68 |
69 | if (count <= 0) return;
70 | segments = new SevenSegment[count];
71 |
72 | for (int i = 0; i < count; i++)
73 | {
74 | segments[i] = new SevenSegment();
75 | segments[i].Parent = this;
76 | segments[i].Top = 0;
77 | segments[i].Height = Height;
78 | segments[i].Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
79 | segments[i].Visible = true;
80 | }
81 |
82 | ResizeSegments();
83 | UpdateSegments();
84 | Value = theValue;
85 | }
86 |
87 | ///
88 | /// Align the elements of the array to fit neatly within the
89 | /// width of the parent control.
90 | ///
91 | private void ResizeSegments()
92 | {
93 | int segWidth = Width / segments.Length;
94 | for (int i = 0; i < segments.Length; i++)
95 | {
96 | segments[i].Left = Width * (segments.Length - 1 - i) / segments.Length;
97 | segments[i].Width = segWidth;
98 | }
99 | }
100 |
101 | ///
102 | /// Update the properties of each element with the properties
103 | /// we have stored.
104 | ///
105 | private void UpdateSegments()
106 | {
107 | for (int i = 0; i < segments.Length; i++)
108 | {
109 | segments[i].ColorBackground = colorBackground;
110 | segments[i].ColorDark = colorDark;
111 | segments[i].ColorLight = colorLight;
112 | segments[i].ElementWidth = elementWidth;
113 | segments[i].ItalicFactor = italicFactor;
114 | segments[i].DecimalShow = showDot;
115 | segments[i].Padding = elementPadding;
116 | }
117 | }
118 |
119 | private void SevenSegmentArray_Resize(object sender, EventArgs e) { ResizeSegments(); }
120 |
121 | protected override void OnPaintBackground(PaintEventArgs e) { e.Graphics.Clear(colorBackground); }
122 |
123 | ///
124 | /// Background color of the LED array.
125 | ///
126 | public Color ColorBackground { get { return colorBackground; } set { colorBackground = value; UpdateSegments(); } }
127 | ///
128 | /// Color of inactive LED segments.
129 | ///
130 | public Color ColorDark { get { return colorDark; } set { colorDark = value; UpdateSegments(); } }
131 | ///
132 | /// Color of active LED segments.
133 | ///
134 | public Color ColorLight { get { return colorLight; } set { colorLight = value; UpdateSegments(); } }
135 |
136 | ///
137 | /// Width of LED segments.
138 | ///
139 | public int ElementWidth { get { return elementWidth; } set { elementWidth = value; UpdateSegments(); } }
140 | ///
141 | /// Shear coefficient for italicizing the displays. Try a value like -0.1.
142 | ///
143 | public float ItalicFactor { get { return italicFactor; } set { italicFactor = value; UpdateSegments(); } }
144 | ///
145 | /// Specifies if the decimal point LED is displayed.
146 | ///
147 | public bool DecimalShow { get { return showDot; } set { showDot = value; UpdateSegments(); } }
148 |
149 | ///
150 | /// Number of seven-segment elements in this array.
151 | ///
152 | public int ArrayCount { get { return segments.Length; } set { if ((value > 0) && (value <= 100)) RecreateSegments(value); } }
153 | ///
154 | /// Padding that applies to each seven-segment element in the array.
155 | /// Tweak these numbers to get the perfect appearance for the array of your size.
156 | ///
157 | public Padding ElementPadding { get { return elementPadding; } set { elementPadding = value; UpdateSegments(); } }
158 |
159 | ///
160 | /// The value to be displayed on the LED array. This can contain numbers,
161 | /// certain letters, and decimal points.
162 | ///
163 | public string Value
164 | {
165 | get { return theValue; }
166 | set
167 | {
168 | theValue = value;
169 | for (int i = 0; i < segments.Length; i++) { segments[i].CustomPattern = 0; segments[i].DecimalOn = false; }
170 | if (theValue != null)
171 | {
172 | int segmentIndex = 0;
173 | for (int i = theValue.Length - 1; i >= 0; i--)
174 | {
175 | if (segmentIndex >= segments.Length) break;
176 | if (theValue[i] == '.') segments[segmentIndex].DecimalOn = true;
177 | else segments[segmentIndex++].Value = theValue[i].ToString();
178 | }
179 | }
180 | }
181 | }
182 |
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/SevenSegment/bin/Release/SevenSegment.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbrant/SevenSegment/ebcc5b59da5479dccf199483b2d304ff885f8af4/SevenSegment/bin/Release/SevenSegment.dll
--------------------------------------------------------------------------------