12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ProjectBase.Controls
- {
- public enum LedState
- {
- NG = 0,
- OK = 1,
- DEFAULT = -1,
- }
- public partial class CircleLabel : UserControl
- {
- public CircleLabel()
- {
- InitializeComponent();
- }
- //protected override void OnResize(EventArgs e)
- //{
- // base.OnResize(e);
- // int x = (int)(0.5 * (this.Width - label1.Width));
- // int y = label1.Location.Y;
- // label1.Location = new System.Drawing.Point(x, y);
- //}
- private LedState m_WorkState;
- [Browsable(true)]
- public LedState WorkState
- {
- get
- {
- return m_WorkState;
- }
- set
- {
- m_WorkState = value;
- SetBackgroundImage();
- Refresh();
- }
- }
- private void SetBackgroundImage()
- {
- switch (WorkState)
- {
- case LedState.OK:
- BackgroundImage = Properties.Resources.绿色指示灯5;
- break;
- case LedState.NG:
- BackgroundImage = Properties.Resources.红色指示灯;
- break;
- default:
- BackgroundImage = Properties.Resources.灰色指示灯;
- break;
- }
- }
-
- private void CircleLabel_FontChanged(object sender, EventArgs e)
- {
- label1.Font = this.Font;
- }
- [Browsable(true)]
- public override string Text
- {
- get { return label1.Text; }
- set { label1.Text = value; }
- }
- }
- }
|