Ejemplo n.º 1
0
        private Bitmap GetPicture()
        {
            if (downHitInfo == null)
            {
                return(null);
            }
            LayoutViewCard layoutCard = downHitInfo.HitCard;

            if (layoutCard == null)
            {
                return(null);
            }
            Rectangle r = new Rectangle(0, 0, Width * 2, Height * 2);

            using (Bitmap bmp = new Bitmap(r.Width, r.Height, PixelFormat.Format32bppArgb))
            {
                using (Graphics imgGraphics = Graphics.FromImage(bmp))
                {
                    using (XtraBufferedGraphics bufferedGraphics = XtraBufferedGraphicsManager.Current.Allocate(imgGraphics, r))
                    {
                        ObjectPainter cardPainter = (layoutView1 as ILayoutControl).PaintStyle.GetPainter(layoutCard);
                        bufferedGraphics.Graphics.Clear(Color.White);
                        layoutCard.ViewInfo.Cache = new GraphicsCache(new DXPaintEventArgs(bufferedGraphics.Graphics, r));
                        PropertyInfo property = typeof(LayoutView).GetProperty("DrawCard", BindingFlags.Instance | BindingFlags.NonPublic);
                        property.SetValue(layoutView1, layoutCard, null);
                        cardPainter.DrawObject(layoutCard.ViewInfo);
                        layoutCard.ViewInfo.Cache = null;
                        bufferedGraphics.Render();
                    }
                    Bitmap newImage = Copy(bmp, layoutCard.Bounds);
                    return(newImage);
                }
            }
        }
        public Bitmap GetRowDragBitmap(int rowHandle)
        {
            Bitmap       bmpView     = null;
            Bitmap       bmpRow      = null;
            GridViewInfo info        = _view.GetViewInfo() as GridViewInfo;
            Rectangle    totalBounds = info.Bounds;
            GridRowInfo  ri          = info.GetGridRowInfo(rowHandle);
            Rectangle    imageBounds = new Rectangle(new Point(0, 0), ri.Bounds.Size);

            try
            {
                bmpView = new Bitmap(totalBounds.Width, totalBounds.Height);
                using (Graphics gView = Graphics.FromImage(bmpView))
                {
                    using (XtraBufferedGraphics grView = XtraBufferedGraphicsManager.Current.Allocate(gView, new Rectangle(Point.Empty, bmpView.Size)))
                    {
                        Color color = ri.Appearance.BackColor == Color.Transparent ? Color.White : ri.Appearance.BackColor;
                        grView.Graphics.Clear(color);
                        IntPtr           handle    = View.GridControl.Handle;
                        DXPaintEventArgs paintArgs = new DXPaintEventArgs(new PaintEventArgs(grView.Graphics, totalBounds), handle);
                        DevExpress.Utils.Drawing.GraphicsCache cache = new DevExpress.Utils.Drawing.GraphicsCache(paintArgs);
                        GridViewDrawArgs args = new GridViewDrawArgs(cache, info, totalBounds);
                        DrawRow(args, ri);
                        grView.Graphics.FillRectangle(args.Cache.GetSolidBrush(Color.Transparent), ri.Bounds);
                        grView.Render();
                        bmpRow = new Bitmap(ri.Bounds.Width, ri.Bounds.Height);
                        using (Graphics gRow = Graphics.FromImage(bmpRow))
                        {
                            using (XtraBufferedGraphics grRow = XtraBufferedGraphicsManager.Current.Allocate(gRow, new Rectangle(Point.Empty, bmpRow.Size)))
                            {
                                grRow.Graphics.Clear(color);
                                grRow.Graphics.DrawImage(bmpView, imageBounds, ri.Bounds, GraphicsUnit.Pixel);
                                grRow.Render();
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            return(bmpRow);
        }