// Handle a paint event from Xsharp. protected override void OnPaint(Xsharp.Graphics graphics) { if (sink != null) { System.Drawing.Region clip = RegionToDrawingRegion(graphics.ExposeRegion); DrawingGraphics g = new DrawingGraphics(toolkit, graphics); using (System.Drawing.Graphics gr = ToolkitManager.CreateGraphics(g, clip)) { sink.ToolkitExpose(gr); } } }
// Start printing a page, and return a "Graphics" object for it. public Graphics StartPage(PrintPageEventArgs e) { // Make sure that the previous page was closed. EndPage(e); // Output the page header information. writer.WriteLine("%%Page: {0} {0}", pageNum, pageNum); writer.WriteLine("%%BeginPageSetup"); // Save the current VM state, so that we can // discard temporary definitions at the end // of the page. writer.WriteLine("/pagelevel save def"); // Flip the co-ordinate system so that the top-left // margin position on the page is the origin. double temp; if (e.PageSettings.Landscape) { // TODO: rotate the co-ordinate system for landscape mode. } else { temp = (e.PageBounds.Height * 72.0) / 100.0; #if CONFIG_EXTENDED_NUMERICS writer.WriteLine("0 {0} translate 1 -1 scale", temp); #else writer.WriteLine("0 {0} translate 1 -1 scale", (int)temp); #endif } // Mark the end of the page header information. writer.WriteLine("%%EndPageSetup"); // We are now on a page. onPage = true; // Save the graphics state. It will be restored and // re-saved every time a pen or brush is changed. writer.WriteLine("gsave"); // Create a "Graphics" object for this page and return it. return(ToolkitManager.CreateGraphics (new PostscriptGraphics(toolkit, writer, this))); }
// WM_PAINT Message internal void Paint() { Win32.Api.PAINTSTRUCT myPS = new System.Drawing.Win32.Api.PAINTSTRUCT(); hdc = Win32.Api.BeginPaint(hwnd, ref myPS); if (sink != null) { DrawingGraphics g = new DrawingGraphics(toolkit, hdc); Region clip = new Region(Rectangle.FromLTRB(myPS.rcPaintLeft, myPS.rcPaintTop, myPS.rcPaintRight, myPS.rcPaintBottom)); System.Drawing.Graphics gr = ToolkitManager.CreateGraphics(g, clip); try { sink.ToolkitExpose(gr); } finally { // EndPaint deletes the hdc but that doesnt matter. Win32.Api.EndPaint(hwnd, ref myPS); gr.Dispose(); } //Console.WriteLine( "DrawingWindow.Paint "+ sink +","+gr.ClipBounds.ToString()); } }