protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); _root.Draw(e.Graphics); if (_autoSize) { SizeF sf = _root.DrawSize; Size sz = new Size((int)sf.Width, (int)sf.Height + 8); if (sz.Width != this.Size.Width || sz.Height != this.Size.Height) { this.Size = sz; } } else { SizeF size = _root.ExpSize; int nh = 0; while (size.Width - (nh * this.ClientSize.Width) > this.ClientSize.Width) { if (this.ClientSize.Height > (nh + 1) * (size.Height + 8) + size.Height) { GraphicsState gt0 = e.Graphics.Save(); e.Graphics.TranslateTransform(-(this.ClientSize.Width * (nh + 1)), (nh + 1) * (size.Height + 8)); _root.Draw(e.Graphics); e.Graphics.Restore(gt0); } else { break; } nh++; } } }
//FormDebug frmDebug; protected override void OnPaint(PaintEventArgs e) { if (mathExp != null) { mathExp.AutoScrollPosition = this.AutoScrollPosition; System.Drawing.Drawing2D.GraphicsState gt0 = e.Graphics.Save(); e.Graphics.TranslateTransform(this.AutoScrollPosition.X, 0); mathExp.Draw(e.Graphics); e.Graphics.Restore(gt0); SizeF size = mathExp.ExpSize; // if (size.Width > 0 && size.Height > 0) { // int left = (int)Math.Floor(size.Width); if (left != _lblForScroll.Left) { _lblForScroll.Left = left; } int nh = 0; while (size.Width + this.AutoScrollPosition.X - (nh * this.ClientSize.Width) > this.ClientSize.Width) { if (this.ClientSize.Height > (nh + 1) * (size.Height + 8) + size.Height) { gt0 = e.Graphics.Save(); e.Graphics.TranslateTransform(this.AutoScrollPosition.X - (this.ClientSize.Width * (nh + 1)), (nh + 1) * (size.Height + 8)); mathExp.Draw(e.Graphics); e.Graphics.Restore(gt0); } else { break; } nh++; } } } }