Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows.Media;
- using System.Windows.Shapes;
- using System.Windows;
- namespace WPF_LED
- {
- class LightEmittingDiode
- {
- public LightEmittingDiode(int Diameter, int PosX, int PosY, Color ColorOn)
- {
- _diameter = Diameter;
- _posX = PosX;
- _posY = PosY;
- _ledColor = ColorOn;
- _currentColor = Colors.LightGray;
- }
- private int _diameter;
- private int _posX;
- private int _posY;
- private Color _ledColor;
- private Color _currentColor;
- private bool _isOn = true;
- public int Diameter
- {
- get
- {
- return _diameter;
- }
- set
- {
- _diameter = value;
- }
- }
- public int PosX
- {
- get
- {
- return _posX;
- }
- set
- {
- _posX = value;
- }
- }
- public int PosY
- {
- get
- {
- return _posY;
- }
- set
- {
- _posY = value;
- }
- }
- public Color LedColor
- {
- get
- {
- return _ledColor;
- }
- set
- {
- _ledColor = value;
- }
- }
- public Ellipse toEllipse()
- {
- Ellipse newLed = new Ellipse();
- newLed.Width = Diameter;
- newLed.Height = Diameter;
- newLed.Margin = new Thickness(_posX, _posY, 0, 0);
- newLed.Fill = new SolidColorBrush(_currentColor);
- return newLed;
- }
- public void Toggle()
- {
- if (_isOn)
- {
- _currentColor = _ledColor;
- _isOn = false;
- }
- else
- {
- _currentColor = Colors.LightGray;
- _isOn = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement