Initial commit
This commit is contained in:
		
							
								
								
									
										88
									
								
								Handler/Project_form2/UIControl/CtlSensor.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								Handler/Project_form2/UIControl/CtlSensor.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| 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 : CtlBase | ||||
|     { | ||||
|  | ||||
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] | ||||
|         public PinInfo arPin { get { return PinList[0]; } set { PinList[0] = value; } } | ||||
|        | ||||
|         Font font_ = new Font("맑은 고딕", 10); | ||||
|  | ||||
|         [Browsable(true)] | ||||
|         public new Font Font { get { return font_; } set { font_ = value; this.Invalidate(); } } | ||||
|        | ||||
|         public Boolean RectShape { get; set; } | ||||
|         public Color ColorOn { get; set; } | ||||
|         public Color ColorOff { get; set; } | ||||
|         | ||||
|         public CtlSensor() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
|  | ||||
|             SetPinCount(1); | ||||
|            | ||||
|             //this.MaximumSize = new Size(80, 80); | ||||
|             this.MinimumSize = new Size(4, 4); | ||||
|             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; | ||||
|            | ||||
|         } | ||||
|  | ||||
|         public override void MakeRect() | ||||
|         { | ||||
|              | ||||
|         } | ||||
|         public override void UpdateValue() | ||||
|         { | ||||
|  | ||||
|         } | ||||
|         protected override void OnPaint(PaintEventArgs pe) | ||||
|         { | ||||
|             base.OnPaint(pe); | ||||
|             pe.Graphics.DrawRectangle(Pens.Gray, DisplayRectangle.Left, DisplayRectangle.Top, DisplayRectangle.Width - 1, DisplayRectangle.Height - 1); | ||||
|  | ||||
|  | ||||
|             var baseRect = new Rectangle(DisplayRectangle.Left + Padding.Left, | ||||
|                 DisplayRectangle.Top + Padding.Top, | ||||
|                 DisplayRectangle.Width - Padding.Left - Padding.Right, | ||||
|                 DisplayRectangle.Height - Padding.Top - Padding.Bottom); | ||||
|  | ||||
|  | ||||
|             var rect = new Rectangle(baseRect.Left + 1, baseRect.Top + 1, baseRect.Width - 2, baseRect.Height - 2); | ||||
|  | ||||
|             if (RectShape) | ||||
|             { | ||||
|                 if (arPin.Value) pe.Graphics.FillRectangle(new SolidBrush(ColorOn), rect); | ||||
|                 else pe.Graphics.FillRectangle(new SolidBrush(ColorOff), rect); | ||||
|                 pe.Graphics.DrawRectangle(Pens.Black, rect); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 if (arPin.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, | ||||
|                     baseRect, | ||||
|                     new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 ChiKyun Kim
					ChiKyun Kim