protected override void OnPaint(System.Windows.Forms.PaintEventArgs pe) { base.OnPaint(pe); //Graphics g = pe.Graphics; //g.DrawLine(System.Drawing.Pens.Red, this.Left, this.Top, this.Right, this.Bottom); if (graphicsList != null) { graphicsList.Draw(pe.Graphics, this.ZoomFactor); } }
/// <summary> /// Draw graphic objects and /// group selection rectangle (optionally) /// </summary> private void DrawArea_Paint(object sender, PaintEventArgs e) { //SolidBrush brush = new SolidBrush(Color.FromArgb(255, 255, 255)); //e.Graphics.FillRectangle(brush, // this.ClientRectangle); if (graphicsList != null) { graphicsList.Draw(e.Graphics); } //DrawNetSelection(e.Graphics); //brush.Dispose(); }
/// <summary> /// Handles the Paint event /// </summary> /// <param name="pe"></param> protected override void OnPaint(PaintEventArgs e) { try { if (PictureBoxPaintedEvent != null) { Rectangle controlClientRect = ClientRectangle; controlClientRect.X -= OffsetX; controlClientRect.Y -= OffsetY; PictureBoxPaintedEvent(controlClientRect, this.ClientRectangle); } if (this.Image != null) { e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.ScaleTransform(zoom, zoom); e.Graphics.TranslateTransform(OffsetX, OffsetY); e.Graphics.DrawImage(this.Image, 0, 0); } if (GraphicsList != null) { GraphicsList.Draw(e.Graphics, this); } if (rulers != null) { rulers.Draw(e.Graphics); } if (LaserFunction) { if (laser != null) { laser.OnPaint(e); } } } catch (Exception ex) { LogHelper.GetLogger <ZWPictureBox>().Error(ex.Message); LogHelper.GetLogger <ZWPictureBox>().Error(ex.StackTrace); } }
internal void Draw(Graphics g) { _graphicsList.Draw(g); }
protected override void OnPaint(PaintEventArgs e) { try { lock (sync) { if (PictureBoxPaintedEvent != null) { Rectangle controlClientRect = ClientRectangle; controlClientRect.X -= OffsetX; controlClientRect.Y -= OffsetY; PictureBoxPaintedEvent(controlClientRect, this.ClientRectangle); } if (this.Picture != null) { e.Graphics.ScaleTransform(Zoom, Zoom); e.Graphics.TranslateTransform(OffsetX, OffsetY); //this.ToHighQuality(e.Graphics); this.ToLowQuality(e.Graphics); //ToHighQuality(e.Graphics); e.Graphics.DrawImage(this.Picture, 0, 0, RealSize.Width, RealSize.Height); e.Graphics.ResetTransform(); } if (LaserFunction) { if (Program.EntryForm.Laser != null && Program.SysConfig.Function == SystemFunction.Laser) { e.Graphics.ScaleTransform(Zoom, Zoom); e.Graphics.TranslateTransform(OffsetX, OffsetY); Program.EntryForm.Laser.OnPaint(e); e.Graphics.ResetTransform(); } } if (GraphicsList != null && Program.SysConfig.Function == SystemFunction.Measure) { GraphicsList.Draw(e.Graphics, this); } if (this.restrictArea != null) { Color drawColor = Color.FromArgb(200, Color.Blue); using (Pen pen = new Pen(drawColor, 2f)) { //模拟模式不需要绘制限制区域 if (Program.SysConfig.LiveMode) { //激光校准不需要绘制限制区域 var laserAlignment = CtrlFactory.GetCtrlFactory().GetCtrlByType <LaserAlignment>(CtrlType.LaserAlignment); if (laserAlignment != null && !laserAlignment.Visible) { this.restrictArea.TestDrawMotorRectangle(e.Graphics, pen); } } } } if (this.CaptureVideo) { Color drawColor = Color.FromArgb(200, Color.Red); using (Pen pen = new Pen(drawColor, 2f)) using (Font font = new Font("宋体", 25f, FontStyle.Bold)) using (SolidBrush sb = new SolidBrush(drawColor)) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; Circle circle = new Circle(new PointF(98, 60), new SizeF(40, 40)); //e.Graphics.DrawEllipse(pen, circle.Rectangle); var size = e.Graphics.MeasureString("REC", font); e.Graphics.DrawString("REC", font, sb, circle.CenterPoint.X + 30 + 48, 60 - size.Height / 2); e.Graphics.FillEllipse(sb, circle.Rectangle); string time = GetRecordTime(); var tSize = e.Graphics.MeasureString(time, font); e.Graphics.DrawString(time, font, sb, new PointF(circle.CenterPoint.X + 30 + size.Width + 48, 60 - tSize.Height / 2)); } } if (rulers != null) { rulers.Draw(e.Graphics); } } } catch (Exception ex) { } }