示例#1
0
 // 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);
         }
     }
 }
示例#2
0
 // Set this window's icon.
 void IToolkitTopLevelWindow.SetIcon(Icon icon)
 {
     DotGNU.Images.Frame frame    = ToolkitManager.GetImageFrame(icon);
     Xsharp.Image        origIcon = Icon;
     if (frame != null)
     {
         Icon = new Xsharp.Image(Screen, frame);
     }
     else
     {
         Icon = null;
     }
     if (origIcon != null)
     {
         origIcon.Dispose();
     }
 }
示例#3
0
        // 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)));
        }
示例#4
0
        // Create an HICON handle from an icon.
        // "DeleteObject" must be called on it when no longer needed.
        IntPtr HandleFromIcon(Icon icon)
        {
            Frame frame = ToolkitManager.GetImageFrame(icon);

            Win32.Api.ICONINFO iconInfo = new System.Drawing.Win32.Api.ICONINFO();
            iconInfo.fIcon = true;
            // Hotspot is always the middle for an icon.
            iconInfo.xHotspot = iconInfo.yHotspot = 0;

            // Create the mono bitmap mask using CreateBitmap rather than CreateDIBitmap, its faster.
            // CreateBitmap expects the mask data to be word aligned, not int aligned and the mask is inverted.
            int frameBytes = (frame.Width + 7) / 8;
            int newStride  = (frameBytes + 1) & ~1;

            byte[] inverseMask = new byte[frame.Height * newStride];
            int    prevOldPos  = 0;
            int    prevNewPos  = 0;

            for (int y = 0; y < frame.Height; y++)
            {
                int oldPos = prevOldPos;
                int newPos = prevNewPos;
                for (int b = 0; b < frameBytes; b++)
                {
                    inverseMask[newPos++] = (byte)~frame.Mask[oldPos++];
                }
                prevOldPos += frame.MaskStride;
                prevNewPos += newStride;
            }
            iconInfo.hbmMask = Win32.Api.CreateBitmap(frame.Width, frame.Height, 1, 1, inverseMask);

            iconInfo.hbmColor = HandleFromBitmap(frame, true);

            IntPtr iconHandle = Win32.Api.CreateIconIndirect(ref iconInfo);

            Win32.Api.DeleteObject(iconInfo.hbmMask);
            Win32.Api.DeleteObject(iconInfo.hbmColor);
            return(iconHandle);
        }
示例#5
0
 // 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());
     }
 }