using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace UIControl { public partial class CtlSensor : Control { string text_ = string.Empty; Font font_ = new Font("맑은 고딕", 10); [Browsable(true)] public new string Text { get { return text_; } set { text_ = value; this.Invalidate(); } } [Browsable(true)] public new Font Font { get { return font_; } set { font_ = value; this.Invalidate(); } } public Color ColorOn { get; set; } public Color ColorOff { get; set; } public Boolean Value { get; set; } public CtlSensor() { InitializeComponent(); this.MaximumSize = new Size(80, 80); this.MinimumSize = new Size(40, 40); this.ColorOn = Color.Lime; this.ColorOff = Color.DimGray; //if (this.Font == null) this.Font = new Font("맑은 고딕", 10); //if (this.Text == null) this.Text = string.Empty; Value = false; } protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); // pe.Graphics.DrawRect( this.DisplayRectangle,Color.Gray,2); var rect = new Rectangle(this.DisplayRectangle.Left + 1, DisplayRectangle.Top + 1, DisplayRectangle.Width - 2, DisplayRectangle.Height - 2); if (Value) pe.Graphics.FillEllipse(new SolidBrush(ColorOn), rect); else pe.Graphics.FillEllipse(new SolidBrush(ColorOff), rect); pe.Graphics.DrawEllipse(Pens.Black, rect); if (string.IsNullOrEmpty(Text) == false) { pe.Graphics.DrawString(Text, this.Font, Brushes.Black, DisplayRectangle, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } } } }