移动时图像的可视化画笔的 WPF 问题



我有图像,当我将对象从一个点移动到另一个点时,我已经为图像创建了视觉画笔。 但我在视觉画笔上看不到图像。 如果你看到我的矩形,它应该显示图像。

查看图片 : http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/e8833983-3d73-45e1-8af1-3bc27846441d

这是代码:

internal static VisualBrush GetVisualBrushByObject(LabelObject obj, Rect objectRect, int quality, FlowDirection flowdirection)
    {
        DrawingVisual drawingVisual = new DrawingVisual();
        DrawingContext drawingContext = drawingVisual.RenderOpen();
        Rect objectbounds = new Rect(0, 0, objectRect.Width, objectRect.Height);
        if (obj is TextObject)
        {
            TextObject txtObj = obj.Clone() as TextObject;
            DymoTextBlock txtBlock = txtObj.DymoTextBlock as DymoTextBlock;
            objectbounds = new Rect(txtBlock.GetNaturalSize(txtBlock.GetFormattedText(flowdirection)));
        }
        if (obj is ImageObject)
        {
            drawingContext.DrawImage(((ImageObject)obj).Image, objectbounds);
        }
        LabelObject.RenderParams lrp = new LabelObject.RenderParams(drawingContext, new Common.Resolution(96, 96), false, objectbounds, flowdirection);
        obj.Render(lrp);
        VisualBrush vBrush = new VisualBrush();
        vBrush.TileMode = TileMode.None;
        vBrush.Stretch = Stretch.Fill;
        if (obj is ImageObject)
        {
            vBrush.Opacity = 0.4;
        }
        drawingContext.Close();
        vBrush.Visual = drawingVisual;
        return vBrush;
    }

请帮助我

谢谢

如果您使用转换(翻译转换)移动图像,则必须在视觉画笔阶段撤消它。

最新更新