Die DLL enthält 3 (eig 4) Controls:
- Eine einfache 7-Segmentanzeige, als Wert ist ein einfacher Integer zuweisbar.
- Ein passendes Control, das einen Doppelpunkt und ein Komma bereitstellt
- Ein Uhrzeiten-Panel, dass 6 7-Segmentanzeigen und 2 Doppelpunkte enthält, man kann jedes Segment einzeln ansprechen oder dem Control ein DateTime zuweisen. Außerdem hat es ein MouseClick-ähnliches Event.
Allen Controls ist ein "LedLayout" zuweisbar, außerdem kann man auswählen ob inaktive Segmente angezeigt werden sollen. Jedes Control hat eine nichtveränderbare Größe (vll arbeite lass ich mir da aber noch was einfallen^^).
Die 7-Segmentanzeige arbeitet nach folgender Logik (hatte wohl nen guten Tag, sonst wäre mir sowas nie eingefallen^^):
Siehe Anhang
Hier ein paar Screenshots der Controls:
Siehe Anhang
Viel Spaß damit, Kritik und Verbesserungsvorschläge aller Art sind natürlich erwünscht ;-)
Der Quellcode ist etwas zu umfangreich, um ihn hier zu posten, am besten mal in der Entwicklungsumgebung angucken :-)
Hier nur einmal die Basisklasse:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LedControls
{
public class LedControl : Control
{
bool _bPaintDarkControls = false;
Color _col = new Color();
Color _colDark = new Color();
public LedControl()
{
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.SupportsTransparentBackColor |
ControlStyles.ResizeRedraw, true);
this.BackColor = Color.Black;
this.LedLayout = LedControls.LedLayout.BlueLayout;
}
/// <summary>
/// Gets or sets a value whether the visibility for all segments is enabled.
/// </summary>
public bool ShowDisenabledSegments
{
get { return _bPaintDarkControls; }
set
{
_bPaintDarkControls = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the main color for all enabled segments.
/// </summary>
public Color EnabledColor
{
get { return _col; }
set
{
_col = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the main color of all disenabled segments.
/// </summary>
public Color DisenabledColor
{
get { return _colDark; }
set
{
_colDark = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets both colors for all segments.
/// </summary>
public Color[] LedLayout
{
get { return new Color[2] { _col, _colDark }; }
set
{
_col = value[0];
_colDark = value[1];
this.Invalidate();
}
}
}
}
Schlagwörter: LedControl, 7-Segmentanzeige, Siebensegmentanzeige, 7Segmentanzeige
Das Demoprojekt hat wegen 5KB (!) leider nicht mehr in diesen Anhang gepasst und folgt im nächsten Beitrag/Anhang