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

Print Map

2 Answers 129 Views
Map
This is a migrated thread and some comments may be shown as answers.
Aurelio Righetti
Top achievements
Rank 1
Aurelio Righetti asked on 05 Aug 2012, 09:56 AM
Hi, i need to print the RadMap on a Paper with format A0 (big dimension), it's possibile ?
Actually for print the map use the code on the post:http://www.telerik.com/community/forums/wpf/map/print-copy.aspx
it's work but the dimension of the map is the dimension on the screen resolution.

Thanks
Aurelio

2 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 08 Aug 2012, 08:35 AM
Hello Aurelio,

Using this approach you can't create image with pixel size more than original control has. But you can temporary increase size of the RadMap control, print it, and then restore original size. For example:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
 
    <telerik:RadMap Name="radMap"
            ZoomLevel="5"
            Center="25,45">
        <telerik:RadMap.Providers>
            <telerik:OpenStreetMapProvider />
        </telerik:RadMap.Providers>
        <telerik:InformationLayer Name="informationLayer">
        </telerik:InformationLayer>
    </telerik:RadMap>
         
    <StackPanel Grid.Column="1">
        <Button Click="ChangeSize">
            <TextBlock Text="Change size" />
        </Button>
             
        <Button Click="CopyToClipboard">
            <TextBlock Text="Copy To Clipboard" />
        </Button>
 
        <Button Click="RestoreSize">
            <TextBlock Text="Restore size" />
        </Button>
    </StackPanel>
</Grid>



private double originalWidth;
private double originalHeight;
 
private void ChangeSize(object sender, RoutedEventArgs e)
{
    originalWidth = this.radMap.Width;
    originalHeight = this.radMap.Height;
 
    this.radMap.Width = 2500;
    this.radMap.Height = 2500;
 
    this.radMap.InvalidateVisual();
}
 
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);
}
 
private void CopyToClipboard(object sender, RoutedEventArgs e)
{
    this.ControlToClipboard(this.radMap);
}
 
private void RestoreSize(object sender, RoutedEventArgs e)
{
    this.radMap.Width = originalWidth;
    this.radMap.Height = originalHeight;
 
    this.radMap.InvalidateVisual();
}

Greetings,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Aurelio Righetti
Top achievements
Rank 1
answered on 08 Aug 2012, 09:29 AM
Hi..Andrey...thanks for the solution it's is Ok...

Aurelio
Tags
Map
Asked by
Aurelio Righetti
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Aurelio Righetti
Top achievements
Rank 1
Share this question
or