This is a migrated thread and some comments may be shown as answers.

Print, copy...

1 Answer 97 Views
Map
This is a migrated thread and some comments may be shown as answers.
Rieni De Rijke
Top achievements
Rank 1
Rieni De Rijke asked on 17 Nov 2010, 08:33 PM
What is the best way to print the Radmap or to copy a RadMap to the clipboard (so you can paste the image in for inst.paint) ?

1 Answer, 1 is accepted

Sort by
0
Rieni De Rijke
Top achievements
Rank 1
answered on 18 Nov 2010, 12:56 PM
I found a way to copy the RadMap to the clipboard. 
So you can paste the image in word, Paint and more.
Of course you can also use it to copy other controls.

private void ControlToClipboard(FrameworkElement obj)
{
    Transform transform = obj.LayoutTransform;
    obj.LayoutTransform = null;
    Thickness margin = obj.Margin;
    obj.Margin = new Thickness(0, 0, margin.Right - margin.Left,
                                     margin.Bottom - margin.Top);
    Size size = new Size(obj.ActualWidth, obj.ActualHeight);
    obj.Measure(size);
    obj.Arrange(new Rect(size));
 
    RenderTargetBitmap bmp = new RenderTargetBitmap((int)obj.ActualWidth,
        (int)obj.ActualHeight, 96, 96, PixelFormats.Pbgra32);
 
    bmp.Render(obj);
    obj.LayoutTransform = transform;
    obj.Margin = margin;
    Clipboard.SetImage(bmp);
}

Tags
Map
Asked by
Rieni De Rijke
Top achievements
Rank 1
Answers by
Rieni De Rijke
Top achievements
Rank 1
Share this question
or