protected override void OnPaint(PaintEventArgs e) { GraphicsState gs = e.Graphics.Save(); GraphicsState gsCur = null; e.Graphics.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y); foreach (DrawingLayer lstDrawings in DrawingLayers) { if (lstDrawings.Visible) { foreach (DrawingItem obj in lstDrawings) { if (curDrawing != null) { if (obj.DrawingId == curDrawing.DrawingId) { gsCur = e.Graphics.Save(); } } obj.Draw(e.Graphics); } } } if (curDrawing != null) { if (gsCur != null) { e.Graphics.Restore(gsCur); } //draw coordinate lines e.Graphics.DrawLine(System.Drawing.Pens.CadetBlue, -600, 0, 600, 0); e.Graphics.DrawLine(System.Drawing.Pens.CadetBlue, 0, -600, 0, 600); curDrawing.Draw(e.Graphics); } e.Graphics.Restore(gs); if (formHS != null) { e.Graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Blue, 8), formHS.Left - 8, formHS.Top - 8, formHS.Width + 16, formHS.Height + 16); } if (sHelp.Length > 0) { e.Graphics.DrawString(sHelp, ftHelp, System.Drawing.Brushes.LightGreen, xH, yH); } }