|
| | |||||||
| Tablet PC Developers Show off your work while discussing with others how to create ink enabled applications. |
| | LinkBack | Thread Tools |
| |||
| Newbie confused by InkOverley.Renderer.Draw() I have a control that looks like a checkered piece of notepaper, to which an InkOverlay is attached. When trying to print this control, including the InkOverlay's ink, I call the following member: public void Print(object sender, PaintEventArgs e) { Paper_Paint(sender, e); inkOverlay.Renderer.Draw(e.Graphics, inkOverlay.Ink.Strokes); } Where Paper_Paint is just the member that draws the notepaper's grid, like this: protected void Paper_Paint(object sender, PaintEventArgs e) { // draw grid, if required if (!showGrid) return; Pen pen = new Pen(gridColor); for (int y = 0; y < Height; y += gridSpacing) e.Graphics.DrawLine(pen, 0, y, Width, y); for (int x = 0; x < Width; x += gridSpacing) e.Graphics.DrawLine(pen, x, 0, x, Height); pen.Dispose(); } Now, in order to scale the notepaper correctly for printing, and in order to account for the margins, I first apply a suitable transform to the Graphics member of the PrintPageEventArgs before handing it to Paper_Paint() above (wrapped into a new PaintEventArgs object, of course). What I do not understand is this: the grid part of the notepaper *does* get drawn at the right position, and at the right scale, whereas the ink does *not*. Is it true, that InkOverlay.Renderer.Draw() does *not* recognize the transform that the Graphics it receives as its first argument specifies? I have also tried to use Renderer.SetViewTransform() to *force* it to recognize the Graphics object's transform, but without apparent success. So *how* am I expected to make the InkOverlay.Renderer.Draw() method apply the right transformation (that accounts for margins and scale) when printing? Thanks in advance for any words of wisdom, Christian |
| |||
| Re: Newbie confused by InkOverley.Renderer.Draw() Hi Christian. Basically, Renderer uses GDI, not GDI+ so it won't get the transform set on the graphics object. Furthermore, the same transform wouldn't be suitable for both drawing operations anyway - one is screen coordinates and the other is ink space coordinates. Instead, what you need to do is create a new renderer ( Renderer r = new Renderer() )and transform it appropriately. I don't have an example off hand, but I'll try to remember to check back later when I'm not on the train. -- Josh Einstein (Tablet PC MVP) Einstein Technologies Tablet Enhancements for Outlook - Try it free: www.tabletoutlook.com "Christian Stapfer" <nil@dev.nul> wrote in message news:41e33$464741f0$4d3848c0$15652@news.hispeed.ch ... >I have a control that looks like a checkered piece > of notepaper, to which an InkOverlay is attached. > When trying to print this control, including > the InkOverlay's ink, I call the following member: > > public void Print(object sender, PaintEventArgs e) > { > Paper_Paint(sender, e); > inkOverlay.Renderer.Draw(e.Graphics, inkOverlay.Ink.Strokes); > } > > Where Paper_Paint is just the member that draws > the notepaper's grid, like this: > > protected void Paper_Paint(object sender, PaintEventArgs e) > { > // draw grid, if required > if (!showGrid) > return; > > Pen pen = new Pen(gridColor); > for (int y = 0; y < Height; y += gridSpacing) > e.Graphics.DrawLine(pen, 0, y, Width, y); > > for (int x = 0; x < Width; x += gridSpacing) > e.Graphics.DrawLine(pen, x, 0, x, Height); > pen.Dispose(); > } > > Now, in order to scale the notepaper correctly > for printing, and in order to account for the > margins, I first apply a suitable transform > to the Graphics member of the PrintPageEventArgs > before handing it to Paper_Paint() above (wrapped > into a new PaintEventArgs object, of course). > What I do not understand is this: the grid > part of the notepaper *does* get drawn at the right > position, and at the right scale, whereas the > ink does *not*. Is it true, that InkOverlay.Renderer.Draw() > does *not* recognize the transform that the Graphics > it receives as its first argument specifies? > > I have also tried to use Renderer.SetViewTransform() > to *force* it to recognize the Graphics object's transform, > but without apparent success. So *how* am I expected to > make the InkOverlay.Renderer.Draw() method apply the > right transformation (that accounts for margins and scale) > when printing? > > Thanks in advance for any words of wisdom, > > Christian |
| |||
| Re: Newbie confused by InkOverley.Renderer.Draw() "Christian Stapfer" <nil@dev.nul> wrote in message news:41e33$464741f0$4d3848c0$15652@news.hispeed.ch ... >I have a control that looks like a checkered piece > of notepaper, to which an InkOverlay is attached. > When trying to print this control, including > the InkOverlay's ink, I call the following member: > > public void Print(object sender, PaintEventArgs e) > { > Paper_Paint(sender, e); > inkOverlay.Renderer.Draw(e.Graphics, inkOverlay.Ink.Strokes); > } > > Where Paper_Paint is just the member that draws > the notepaper's grid, like this: > > protected void Paper_Paint(object sender, PaintEventArgs e) > { > // draw grid, if required > if (!showGrid) > return; > > Pen pen = new Pen(gridColor); > for (int y = 0; y < Height; y += gridSpacing) > e.Graphics.DrawLine(pen, 0, y, Width, y); > > for (int x = 0; x < Width; x += gridSpacing) > e.Graphics.DrawLine(pen, x, 0, x, Height); > pen.Dispose(); > } > > Now, in order to scale the notepaper correctly > for printing, and in order to account for the > margins, I first apply a suitable transform > to the Graphics member of the PrintPageEventArgs > before handing it to Paper_Paint() above (wrapped > into a new PaintEventArgs object, of course). > What I do not understand is this: the grid > part of the notepaper *does* get drawn at the right > position, and at the right scale, whereas the > ink does *not*. Is it true, that InkOverlay.Renderer.Draw() > does *not* recognize the transform that the Graphics > it receives as its first argument specifies? To answer my own question: the answer is yes. "In most cases, you could apply a translation to the Graphics Transform, but unfortunately the Renderer's Draw method only uses the HDC of the Graphics and does not make use of its transformation. (This may changes in future releases of the SDK.)" http://msdn2.microsoft.com/en-us/library/ms812505.aspx > I have also tried to use Renderer.SetViewTransform() > to *force* it to recognize the Graphics object's transform, > but without apparent success. So *how* am I expected to > make the InkOverlay.Renderer.Draw() method apply the > right transformation (that accounts for margins and scale) > when printing? I understand now that I have to work with ink-space coordinates when calculating the margin shift. Regards, Christian |
| Bookmarks |
| Thread Tools | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bluetooth Audio Renderer doesn't stop when I turned off my headset | Minime | Vista Hardware | 0 | 07-25-2008 07:41 AM |
| draw function | sthole | Microsoft Office | 2 | 06-24-2008 06:50 AM |
| Anti-Aliasing Problem with Ink Renderer on Memory DC - Again... | Ignoramus | Tablet PC Developers | 1 | 12-27-2007 08:50 AM |
| How do I draw a number line (from -10 to 10)? | Marcos | Microsoft Office | 1 | 09-04-2007 07:10 AM |
| Renderer Problems with InkPicture | matt | Windows XP Tablet PC Newsgroup | 1 | 03-17-2005 09:15 AM |
| New To Technology Questions? | Do You Need Help with Your Computer or Device? | Do You Need Help with this site? |