/// <summary> /// Saves the current state of the device context by copying data describing selected objects and graphic /// modes (such as the bitmap, brush, palette, font, pen, region, drawing mode, and mapping mode) to a /// context stack. /// The SaveDC function can be used any number of times to save any number of instances of the DC state. /// A saved state can be restored by using the RestoreHdc method. /// See MSDN for more details. /// </summary> public int SaveHdc() { HandleRef hdc = new HandleRef(this, Hdc); int state = IntUnsafeNativeMethods.SaveDC(hdc); if (contextStack == null) { contextStack = new Stack(); } GraphicsState g = new GraphicsState(); g.hBitmap = hCurrentBmp; g.hBrush = hCurrentBrush; g.hPen = hCurrentPen; g.hFont = hCurrentFont; g.font = new WeakReference(selectedFont); contextStack.Push(g); #if TRACK_HDC Debug.WriteLine(DbgUtil.StackTraceToStr(String.Format("state[0]=DC.SaveHdc(hDc=0x{1:x8})", state, unchecked ((int)this.hDC)))); #endif return(state); }
public int SaveHdc() { HandleRef hDC = new HandleRef(this, this.Hdc); int num = IntUnsafeNativeMethods.SaveDC(hDC); if (this.contextStack == null) { this.contextStack = new Stack(); } GraphicsState state = new GraphicsState { hBitmap = this.hCurrentBmp, hBrush = this.hCurrentBrush, hPen = this.hCurrentPen, hFont = this.hCurrentFont, font = new WeakReference(this.selectedFont) }; this.contextStack.Push(state); return(num); }