private void SelectObject(object obj) { if (obj == null) { throw(new ArgumentNullException("obj")); } if (obj is GdiPen) { GdiPen pen = (GdiPen)obj; _currentPen = pen; Win32.SelectObject(_hdc, pen.NativePen); } else if (obj is GdiBrush) { GdiBrush brush = (GdiBrush)obj; _currentBrush = brush; Win32.SelectObject(_hdc, brush.NativeBrush); } else if (obj is GdiFont) { GdiFont font = (GdiFont)obj; _currentFont = font; Win32.SelectObject(_hdc, font.NativeFont); } else { throw(new Exception("Unknow gdi object")); } }
public GdiPen SelectPen(GdiPen pen) { if (pen == null) { throw(new ArgumentNullException("pen")); } if (pen.NativePen != IntPtr.Zero) { this.SelectObject(pen); return(pen); } GdiPen gdiPen = null; _penTable.TryGetValue(pen.Key, out gdiPen); if (gdiPen == null) { gdiPen = pen; _penTable.Add(pen.Key, pen); } this.CheckNativePen(gdiPen); this.SelectObject(gdiPen); return(gdiPen); }
private void CheckNativePen(GdiPen gdiPen) { if (gdiPen.NativePen == IntPtr.Zero) { gdiPen.SetNativePen(Win32.CreatePen(gdiPen.GdiStyle, gdiPen.Width, gdiPen.GdiColor)); } }
internal void SelectGridPen(ChartGraphics g) { if (_gridPen == null || _gridPen.Color != this.Owner.GridColor) { _gridPen = new GdiPen(this.Owner.GridColor, 1, System.Drawing.Drawing2D.DashStyle.Dot); } g.SelectPen(_gridPen); }
public void DrawRectangleExt(GdiPen gdiPen, int x, int y, int width, int height) { if (gdiPen == null) { throw (new ArgumentNullException("gdiPen")); } this.CheckNativePen(gdiPen); Win32.FrameRect(this._hdc, x, y, width + 1, height + 1, gdiPen.NativePen); }
public void DrawLineExt(GdiPen gdiPen, int x1, int y1, int x2, int y2) { if (gdiPen == null) { throw (new ArgumentNullException("gdiPen")); } this.CheckNativePen(gdiPen); Win32.SelectObject(_hdc, gdiPen.NativePen); this.DrawLine(x1, y1, x2, y2); Win32.SelectObject(_hdc, _currentPen.NativePen); }
public void DrawRectangleExt(GdiPen pen, Rectangle rect) { this.DrawRectangleExt(pen, rect.X, rect.Y, rect.Width, rect.Height); }