Ejemplo n.º 1
0
        private void WithExtraCanvas(Rectangle rect, Action <X11Canvas> action)
        {
            using (X11Image tempImage = X11Image.Create(display, visual, drawableId, rect.Width, rect.Height))
            {
                var gcValues = new XGCValues();
                gcValues.foreground = ToPArgb(Color.Transparent);
                var gcValueMask = XGCValueMask.GCForeground;
                var gc          = LibX11.XCreateGC(display, drawableId, gcValueMask, ref gcValues);
                try
                {
                    // todo: check int -> uint conversion
                    LibX11.XFillRectangle(display, tempImage.PixmapId, gc, 0, 0, (uint)rect.Width, (uint)rect.Height);
                }
                finally
                {
                    LibX11.XFreeGC(display, gc);
                }

                using (var innerCanvas = X11Canvas.CreateForDrawable(display, screenNum, objectCache, visual, colormap, pictFormatPtr, tempImage.PixmapId))
                {
                    action(innerCanvas);
                    DrawImage(tempImage, rect.X + origin.X, rect.Y + origin.Y);
                }
            }
        }