private void control_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if (m_visible) { bool disposeOfTransform = false; Matrix transform; if (m_transformAdapter != null) { transform = m_transformAdapter.Transform; } else { transform = new Matrix(); disposeOfTransform = true; } RectangleF clientRect = AdaptedControl.ClientRectangle; RectangleF canvasRect = GdiUtil.InverseTransform(transform, clientRect); // draw horizontal lines ChartUtil.DrawHorizontalGrid(transform, canvasRect, m_verticalGridSpacing, m_gridColor, e.Graphics); // draw vertical lines ChartUtil.DrawVerticalGrid(transform, canvasRect, m_horizontalGridSpacing, m_gridColor, e.Graphics); if (disposeOfTransform) { transform.Dispose(); } } }
// draw dragged events private void control_DrawingD2d(object sender, EventArgs e) { if (m_visible) { var d2dControl = AdaptedControl as D2dAdaptableControl; Matrix3x2F xform = d2dControl.D2dGraphics.Transform; d2dControl.D2dGraphics.Transform = Matrix3x2F.Identity; Matrix transform = m_transformAdapter.Transform; RectangleF clientRect = AdaptedControl.ClientRectangle; RectangleF canvasRect = GdiUtil.InverseTransform(transform, clientRect); D2dAntialiasMode oldAA = d2dControl.D2dGraphics.AntialiasMode; d2dControl.D2dGraphics.AntialiasMode = D2dAntialiasMode.Aliased; // draw horizontal lines ChartUtil.DrawHorizontalGrid(transform, canvasRect, m_verticalGridSpacing, m_gridColor, d2dControl.D2dGraphics); // draw vertical lines ChartUtil.DrawVerticalGrid(transform, canvasRect, m_horizontalGridSpacing, m_gridColor, d2dControl.D2dGraphics); d2dControl.D2dGraphics.Transform = xform; d2dControl.D2dGraphics.AntialiasMode = oldAA; } }