protected override void OnPaint(PaintEventArgs pe) { Color color = Color.Yellow; double rot = 0.0; base.OnPaint(pe); Graphics g = pe.Graphics; double valveRotation = 0.0; pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; if (m_SteeringMode == Helper.SteeringMode.Analog) { color = Color.Black; if (m_Rotation < 0.0) { this.Rotation = 0.0; } if (m_Rotation > 100.0) { this.Rotation = 100.0; } valveRotation = 90.0 / 100.0 * m_Rotation; } else { if (m_State == ValveState.Open) { color = Color.Black; valveRotation = 0.0; } if (m_State == ValveState.Close) { color = Color.Black; valveRotation = 90.0; } if (m_State == ValveState.Undefine) { color = Color.Black; valveRotation = 45.0 + 90.0; } } if (m_State == ValveState.Error) { color = Color.Red; valveRotation = 45.0; } if (m_FlowDirection == ValveDirection.Horizontal) { rot = 0.0; } if (m_FlowDirection == ValveDirection.Vertical) { rot = 90.0; } double heightBar = 10.0; if (m_Type == ValveType.Normal) { heightBar = 10.0; this.Width = 40; this.Height = 40; } if (m_Type == ValveType.Small) { heightBar = 6.0; this.Width = 30; this.Height = 30; } if (m_Type == ValveType.Big) { heightBar = 12.0; this.Width = 50; this.Height = 50; } rot = rot + valveRotation; int height = this.Height; int width = this.Width; Point pointCenter = new Point(); pointCenter.X = height / 2; pointCenter.Y = width / 2; int center = height / 2; double widthImage = this.Width; double heightImage = this.Height; double radius = heightImage / 2.0; double x_1 = 0.0; double x_2 = 0.0; double x_3 = 0.0; double x_4 = 0.0; double y_1 = 0.0; double y_2 = 0.0; double y_3 = 0.0; double y_4 = 0.0; double widthBar = (Math.Sqrt((radius * radius) - (heightBar / 2.0 * heightBar / 2.0))); x_1 = radius - widthBar; y_1 = heightImage / 2.0 - heightBar / 2.0; x_2 = x_1; y_2 = y_1 + heightBar; x_3 = x_2 + widthBar * 2.0; y_3 = y_2; x_4 = x_3; y_4 = y_1; int x1 = Convert.ToInt32(x_1); int x2 = Convert.ToInt32(x_2); int x3 = Convert.ToInt32(x_3); int x4 = Convert.ToInt32(x_4); int y1 = Convert.ToInt32(y_1); int y2 = Convert.ToInt32(y_2 - 1); int y3 = Convert.ToInt32(y_3 - 1); int y4 = Convert.ToInt32(y_4); Point[] point = { new Point(x1, y1), new Point(x2, y2), new Point(x3, y3), new Point(x4, y4) }; //rot = 10.0; point[0] = FuncGeneral.RotatePoint(point[0], pointCenter, rot); point[1] = FuncGeneral.RotatePoint(point[1], pointCenter, rot); point[2] = FuncGeneral.RotatePoint(point[2], pointCenter, rot); point[3] = FuncGeneral.RotatePoint(point[3], pointCenter, rot); Color colorValve = Color.White; if (this.m_Mode == ValveMode.Automatic) { colorValve = Color.White; } if (this.m_Mode == ValveMode.Manuell) { colorValve = Color.Gainsboro; } SolidBrush brush = new SolidBrush(colorValve); int penWidth = 3; Pen pen = new Pen(Color.Black, penWidth); int left = penWidth / 2; int top = left; Rectangle rec = new Rectangle(left, top, width - penWidth, height - penWidth); pe.Graphics.DrawEllipse(pen, rec); pe.Graphics.FillEllipse(brush, rec); Pen penTriangle = new Pen(color); SolidBrush brushTriangle = new SolidBrush(color); pe.Graphics.DrawPolygon(penTriangle, point); pe.Graphics.FillPolygon(brushTriangle, point); Font f = new Font("Arial", 14f, FontStyle.Bold); StringFormat strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Center; strFormat.LineAlignment = StringAlignment.Center; g.DrawString(this.Caption, f, Brushes.Black, rec, strFormat); }
protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; Color color = Color.Yellow; double rot = 0.0; base.OnPaint(pe); Graphics g = pe.Graphics; if (m_State == PumpState.NotUsed) { color = Color.Gray; } if (m_State == PumpState.Ready) { color = Color.Yellow; } if (m_State == PumpState.Running) { color = Color.Lime; } if (m_State == PumpState.Error) { color = Color.Red; } if (m_FlowDirection == PumpFlowDirection.Right) { rot = 0.0; } if (m_FlowDirection == PumpFlowDirection.Down) { rot = 90.0; } if (m_FlowDirection == PumpFlowDirection.Left) { rot = 180.0; } if (m_FlowDirection == PumpFlowDirection.Up) { rot = 270.0; } int height = this.Height; int width = this.Width; Point pointCenter = new Point(); pointCenter.X = height / 2; pointCenter.Y = width / 2; int center = height / 2; double radius = height / 2.0; double a = Math.Sqrt(Math.Pow(radius, 2.0) / 2.0); double y = radius - a; int y1 = Convert.ToInt32(y); int x1 = y1; int y2 = Convert.ToInt32(2.0 * a + y); int x2 = y1; int y3 = Convert.ToInt32(height / 2.0); int x3 = width; Point[] point = { new Point(x1, y1), new Point(x2, y2), new Point(x3, y3) }; point[0] = FuncGeneral.RotatePoint(point[0], pointCenter, rot); point[1] = FuncGeneral.RotatePoint(point[1], pointCenter, rot); point[2] = FuncGeneral.RotatePoint(point[2], pointCenter, rot); SolidBrush brush = new SolidBrush(Color.White); int penWidth = 3; Pen pen = new Pen(Color.White, penWidth); int left = penWidth / 2; int top = left; Rectangle rec = new Rectangle(left, top, width - penWidth, height - penWidth); pe.Graphics.DrawEllipse(pen, rec); pe.Graphics.FillEllipse(brush, rec); Pen penTriangle = new Pen(color); SolidBrush brushTriangle = new SolidBrush(color); pe.Graphics.DrawPolygon(penTriangle, point); pe.Graphics.FillPolygon(brushTriangle, point); Font f = new Font("Arial", 14f, FontStyle.Bold); StringFormat strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Center; strFormat.LineAlignment = StringAlignment.Center; g.DrawString(this.Caption, f, Brushes.Black, rec, strFormat); }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); Graphics g = pe.Graphics; pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; int nr = 0; int startPosX = 40; int startPosY = 20; int hoeheBalken = 20; int breiteBalken = 40; int radiusKreis = 15; this.SetXY(startPosX, startPosY, true); m_PointRotate.Y = m_Points[0].Y - 10; m_PointRotate.X = m_Points[0].X; int LinksKreis = m_PointRotate.X - radiusKreis; int ObenKreis = m_PointRotate.Y - radiusKreis; this.m_Rec.X = LinksKreis - 1; this.m_Rec.Y = ObenKreis - 1; this.m_Rec.Width = radiusKreis * 2; this.m_Rec.Height = radiusKreis * 2; m_Pen.Color = Color.White; for (int i = 0; i < 7; i++) { this.SetXY(startPosX + nr * breiteBalken, startPosY, true); this.SetXY(startPosX + nr * breiteBalken, startPosY + hoeheBalken); this.SetXY(startPosX + nr * breiteBalken + breiteBalken, startPosY + hoeheBalken); this.SetXY(startPosX + nr * breiteBalken + breiteBalken, startPosY); m_Points[0] = FuncGeneral.RotatePoint(m_Points[0], m_PointRotate, m_rotation); m_Points[1] = FuncGeneral.RotatePoint(m_Points[1], m_PointRotate, m_rotation); m_Points[2] = FuncGeneral.RotatePoint(m_Points[2], m_PointRotate, m_rotation); m_Points[3] = FuncGeneral.RotatePoint(m_Points[3], m_PointRotate, m_rotation); double asd = i % 2; if (i % 2 == 0) { m_Pen.Color = Color.Red; } else { m_Pen.Color = Color.White; } m_Brush.Color = m_Pen.Color; g.DrawPolygon(m_Pen, m_Points.ToArray()); g.FillPolygon(m_Brush, m_Points.ToArray()); nr++; this.m_Pen.Color = Color.Black; m_Brush.Color = m_Pen.Color; g.DrawEllipse(m_Pen, m_Rec); g.FillEllipse(m_Brush, m_Rec); } }