/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { if (this.backgroundImage != null) { e.CPaint.DrawImage(this.backgroundImage, base.Rectangle); } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { if (points != null && points.Length == 4) { //多边形 if (this.isMouseEnter || hasChoose) { e.CPaint.FillPolygon(PolygonForeColor, points); } //文字 if (this.Text != null && this.Text.Length > 0) { for (int i = 0; i < this.Text.Length; i++) { int a = e.CPaint.TextSize(this.Text, this.Font).cy; string text = this.Text[i].ToString(); e.CPaint.DrawText(text, this.Font, drawForeColor, new RECT(Rectangle.left + (Rectangle.right - Rectangle.left) / 2 - e.CPaint.TextSize(text, this.Font).cx / 2 + 1 , Rectangle.top + ((Rectangle.bottom - Rectangle.top - (this.Text.Length * a)) / 2) + (a + 2) * i , Rectangle.right , Rectangle.bottom)); } } } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { //if (!Redraw) { return; } Image currentImage = image; if (currentImage != null) { if (imageSIZE.cx > 0 && imageSIZE.cy > 0) { e.CPaint.DrawImage(image, new RECT(this.Rectangle.left, this.Rectangle.bottom - ImageSIZE.cy, this.Rectangle.left + ImageSIZE.cx, this.Rectangle.bottom)); } else { e.CPaint.DrawImage(image, this.Rectangle); } } else if ((Rectangle.right - Rectangle.left) >= 2 && (Rectangle.bottom - Rectangle.top) >= 2) { if (hasChoose) { e.CPaint.FillRect(MouseClickBackColor, Rectangle); } else if (isMouseEnter) { e.CPaint.FillRect(MouseBackColor, Rectangle); } else { e.CPaint.FillRect(BackColor, Rectangle); } if (hasFrame) { //画渐变背景 e.CPaint.DrawGradientRect(TopColor, TopColor2, new RECT(Rectangle.left, Rectangle.top, Rectangle.right, Rectangle.bottom / 2), 90); e.CPaint.DrawGradientRect(TopColor, TopColor2, new RECT(Rectangle.left, Rectangle.top + (Rectangle.bottom - Rectangle.top) / 2, Rectangle.right, Rectangle.bottom), 90); //画边框 e.CPaint.DrawLine(COLOR.RGB(Color.White), 1, 0, Rectangle.left - 1, Rectangle.top - 1, Rectangle.right + 1, Rectangle.top - 1); e.CPaint.DrawLine(COLOR.RGB(Color.White), 1, 0, Rectangle.left - 1, Rectangle.top - 1, Rectangle.left - 1, Rectangle.bottom + 1); e.CPaint.DrawLine(COLOR.RGB(Color.White), 1, 0, Rectangle.right + 1, Rectangle.top - 1, Rectangle.right + 1, Rectangle.bottom + 1); e.CPaint.DrawLine(COLOR.RGB(Color.White), 1, 0, Rectangle.left - 1, Rectangle.bottom + 1, Rectangle.right + 1, Rectangle.bottom + 1); e.CPaint.DrawLine(COLOR.RGB(166, 166, 166), 1, 0, Rectangle.left + 1, Rectangle.top + 1, Rectangle.right - 1, Rectangle.top + 1); e.CPaint.DrawLine(COLOR.RGB(166, 166, 166), 1, 0, Rectangle.left + 1, Rectangle.top + 1, Rectangle.left + 1, Rectangle.bottom - 1); e.CPaint.DrawLine(COLOR.RGB(166, 166, 166), 1, 0, Rectangle.right - 1, Rectangle.top + 1, Rectangle.right - 1, Rectangle.bottom - 1); e.CPaint.DrawLine(COLOR.RGB(166, 166, 166), 1, 0, Rectangle.left + 1, Rectangle.bottom - 1, Rectangle.right - 1, Rectangle.bottom - 1); } //文字 if (this.Text != null && this.Text.Length > 0) { e.CPaint.DrawText(this.Text, this.Font, drawForeColor, new RECT(Rectangle.left + (Rectangle.right - Rectangle.left) / 2 - e.CPaint.TextSize(this.Text, this.Font).cx / 2 + 1 , Rectangle.top + (Rectangle.bottom - Rectangle.top - e.CPaint.TextSize(this.Text, this.Font).cy) / 2 - 1 , Rectangle.right , Rectangle.bottom)); } } //this.Redraw = false; }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { if (reRectangle) { reRectangle = false; if (LeftAligned) { textRECT.left = base.Rectangle.left; textRECT.top = base.Rectangle.top + (base.Rectangle.bottom - base.Rectangle.top) / 2 - e.CPaint.TextSize(base.Text, base.Font).cy / 2; textRECT.right = base.Rectangle.right; textRECT.bottom = base.Rectangle.bottom; } else { textRECT.left = base.Rectangle.left + (base.Rectangle.right - base.Rectangle.left) / 2 - e.CPaint.TextSize(base.Text, base.Font).cx / 2; textRECT.top = base.Rectangle.top + (base.Rectangle.bottom - base.Rectangle.top) / 2 - e.CPaint.TextSize(base.Text, base.Font).cy / 2; textRECT.right = base.Rectangle.right; textRECT.bottom = base.Rectangle.bottom; } } if (BackColor > 0) { e.CPaint.FillRect(BackColor, base.Rectangle); } if (!string.IsNullOrEmpty(base.Text)) { int color = base.ForeColor; if (isMouseEnter) { color = base.MouseForeColor; } if (!base.Text.Contains("\r\n")) { e.CPaint.DrawText(base.Text, base.Font, color, textRECT); } else { string[] array = base.Text.Split(new string[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries); if (array != null) { for (int i = 0; i < array.Length; i++) { if (array[i] != null) { int h = textRECT.bottom - textRECT.top; int drift = 8; RECT rect = new RECT(textRECT.left, textRECT.top + (h - drift) * i, textRECT.right, textRECT.bottom + (h - drift) * i); e.CPaint.DrawText(array[i], base.Font, color, rect); array[i] = null; } } } } if (Underline && isMouseEnter) { e.CPaint.DrawLine(color, 1, 0, textRECT.left, textRECT.bottom + 1, textRECT.right, textRECT.bottom + 1); } } }
/// <summary> /// 执行绘制事件 /// </summary> /// <param name="e"></param> public void DoPaint(MPaintEventArgs e) { this.OnPaint(e); if (this.Paint != null) { this.Paint(this, e); } }
protected override void OnPaint(MPaintEventArgs e) { CalculationTable(); #region 绘制数据 mrt1.DoPaint(e); //绘卖 foreach (var v in sellData) { if (v.data.Visible) { v.data.DoPaint(e); if (v.data1image != null) { v.data1image.DoPaint(e); } } } //保存 //Graphics gc = e.CPaint.GetGraphics(); //GraphicsState gs = gc.Save(); //g.Restore(gs); mrt2.DoPaint(e); //绘买 for (int i = 0; i < buyData.Count; i++) { var v = buyData[i]; if (v.data.Visible) { v.data.DoPaint(e); if (v.data1image != null) { v.data1image.DoPaint(e); } } } ////恢复绘图 //RECT rect = new RECT(500, 100, 300, 200); //e.CPaint.DrawImage(bmp,rect); #endregion tableHeader.DoPaint(e); image2.DoPaint(e); line1.DoPaint(e); if (scrollbar1.Visible) { scrollbar1.DoPaint(e); } if (scrollbar2.Visible) { scrollbar2.DoPaint(e); } if (image3.Visible) { image3.DoPaint(e); } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { foreach (var v in btns) { v.DoPaint(e); } foreach (var v in vlines) { v.DoPaint(e); } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { if (!isMouseEnter) { e.CPaint.FillRect(BackColor, Rectangle); } else { e.CPaint.FillRect(MouseBackColor, Rectangle); } foreach (var v in lbs) { v.DoPaint(e); } }
/// <summary> /// 构造方法 /// </summary> public MBorad() { this.cp = new GdiPlusPaint(); //this.cp = new GdiPaint(); this.SizeChanged += new EventHandler(CBorad_SizeChanged); this.graphics = this.CreateGraphics(); this.Paint += new PaintEventHandler(CBoard_Paint); this.MouseMove += new MouseEventHandler(CBoard_MouseMove); this.MouseDown += new MouseEventHandler(CBoard_MouseDown); this.MouseUp += new MouseEventHandler(CBoard_MouseUp); this.MouseEnter += new EventHandler(CBorad_MouseEnter); this.MouseLeave += new EventHandler(CBoard_MouseLeave); this.MouseWheel += new MouseEventHandler(CBoard_MouseWheel); args = new MPaintEventArgs(cp, this); }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { Image currentImage = image; if (currentImage != null) { e.CPaint.DrawImage(image, imageRectangle); //文字 if (this.Text != null && this.Text.Length > 0) { e.CPaint.DrawText(this.Text, this.Font, ForeColor, new RECT(imageRectangle.left + 10 , imageRectangle.top + (imageRectangle.bottom - imageRectangle.top - e.CPaint.TextSize(this.Text, this.Font).cy) / 2 - 1 , imageRectangle.right , imageRectangle.bottom)); } if (hasChoose) { //下拉框 RECT rect1 = new RECT(imageRectangle.left, imageRectangle.bottom + 2, imageRectangle.right + 10, imageRectangle.bottom + 2 + 30 * Items.Count); e.CPaint.FillRect(dropDownBoxBackColor, rect1); if (XY.x != int.MaxValue && XY.y != int.MaxValue) { //选中的行 for (int i = 0; i < Items.Count; i++) { RECT rect2 = new RECT(rect1.left, rect1.top + 30 * i, rect1.right, rect1.top + 30 * (i + 1)); if (rect2.Contains(XY)) { e.CPaint.FillRect(dropDownBoxRowMouseEnterColor, rect2); currentObj = Items[i]; break; } } } //绘制下拉框中的文字 for (int i = 0; i < Items.Count; i++) { e.CPaint.DrawText(Items[i], this.Font, dropDownBoxForeColor, new RECT(rect1.left + 10, rect1.top + 30 * i + (30 - e.CPaint.TextSize(Items[i], this.Font).cy) / 2 - 1 , rect1.right, rect1.top + 30 * i + 30)); } } } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { if ((Rectangle.right - Rectangle.left) >= 2 && (Rectangle.bottom - Rectangle.top) >= 2) { //文字 if (this.Text != null && this.Text.Length > 0) { e.CPaint.DrawText(this.Text, this.Font, drawForeColor, new RECT(Rectangle.left + (Rectangle.right - Rectangle.left) / 2 - e.CPaint.TextSize(this.Text, this.Font).cx / 2 + 1 , Rectangle.top + (Rectangle.bottom - Rectangle.top - e.CPaint.TextSize(this.Text, this.Font).cy) / 2 , Rectangle.right , Rectangle.bottom)); } if (hasChoose) { e.CPaint.DrawLine(drawForeColor, lineWidth, 0, Rectangle.left + 1, Rectangle.bottom - 1, Rectangle.right - 1, Rectangle.bottom - 1); } } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { if ((Rectangle.right - Rectangle.left) >= 2 && (Rectangle.bottom - Rectangle.top) >= 2) { if (isMouseDown) { e.CPaint.FillRect(MouseClickBackColor, Rectangle); e.CPaint.FillRect(ForeColor, sliderRectangle); } else if (isMouseEnter) { e.CPaint.FillRect(MouseBackColor, Rectangle); e.CPaint.FillRect(MouseForeColor, sliderRectangle); } else { e.CPaint.FillRect(BackColor, Rectangle); e.CPaint.FillRect(ForeColor, sliderRectangle); } } }
/// <summary> /// 绘制 /// </summary> /// <param name="e"></param> protected virtual void OnPaint(MPaintEventArgs e) { }
/// <summary> /// 执行绘制事件 /// </summary> /// <param name="e"></param> public void DoPaint(MPaintEventArgs e) { this.OnPaint(e); this.Paint?.Invoke(this, e); }
/// <summary> /// 绘画 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { e.CPaint.DrawLine(lineColor, width, 0, this.firstPoint, this.secondPoint); }
/// <summary> /// 绘画 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { //if (!Redraw) return; e.CPaint.DrawLine(lineColor, width, 0, this.firstPoint, this.secondPoint); //Redraw = false; }
/// <summary> /// 绘画 /// </summary> /// <param name="e"></param> protected override void OnPaint(MPaintEventArgs e) { e.CPaint.FillRect(BackColor, Rectangle); }