Select to view content in your preferred language

Printing in SL 2.0 comparsion

7314
59
10-04-2010 05:27 AM
LakshmananVenkatesan
Frequent Contributor
Dear All:

We have developed Print functionality in Web application using ESRI SL 1.2, ArcGIS 9.3.1. Client application willl send all visible layers, graphics (poly,line and point) as string , text symbols as string to server side and recreate a map document and construct geometry from string and generate a image and display in web page.

If we have say 100 lines as graphics, string which we generate is very big and unable to process( or send via http). Server side is done using GP Tool. Question is we have planned to move to ArcGIS 10 and SL 2.0.

What are all advantages in print functionality using ArcGIS 10 and SL 2.0  (MS SL 4.0) or rather how easy to print the map with graphics and other options ?

Please throw light on this
0 Kudos
59 Replies
DominiqueBroux
Esri Frequent Contributor
Unfortunately I had not planned to go to the dev conference.
Now if there is some beer, I might change my mind :cool:
0 Kudos
NathalieNeagle
Regular Contributor
Not going to the Deve; how can they leave you behind?

Now I know I'm asking for alot with only promises of Beer (maybe at the User Conf) but I now have everything up and firing.  I'm took your combo box example to change the layouts (I excluded the text) and got that up and running great. 

The only problem I'm having is my printing dialog isn't refreshing when my map extent changes and I'm not sure why.  I thought that was the binding code in the xaml.  (my map is named Map, yours is MyMap).

So here's my xaml I'm I doing something wrong?

 <!--MapPrinter Dialog Panel-->
        <userControls:CollapsiblePanel x:Name="MapPrinterDialogPanel" Width="340" Height="405"
                HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,60,10,0" Effect="{StaticResource dropShadow}">

        

                            <Grid>

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>


                <StackPanel Orientation="Horizontal" Background="{StaticResource CommonPanelBorderBackgroundBrush}" Effect="{StaticResource miniDropShadow}"    >
                            <TextBlock Foreground="White" FontSize="12" 
                 Text="Page Style : " TextWrapping="NoWrap" VerticalAlignment="Center" />

                            <ComboBox Name="comboPrintStyle" SelectionChanged="comboPrintStyle_SelectionChanged" Margin="5,2" MinWidth="80" SelectedIndex="0" VerticalAlignment="Center">
                                <ComboBox.Items>
                                    <sys:String>(Default)</sys:String>
                                    <sys:String>Basic</sys:String>
                                    <sys:String>WithOverview</sys:String>
                                    <sys:String>WithClonedMapAsOverview</sys:String>
                                    <sys:String>WithLegend</sys:String>

                                </ComboBox.Items>
                            </ComboBox>
                        </StackPanel>

                  
                                
                <printing:MapPrinterDialog x:Name="MapPrinterDialog" Background="{StaticResource CommonPanelBorderBackgroundBrush}" BorderBrush="{StaticResource CommonBorderBrush}" Grid.Row="1">
                            <printing:MapPrinter x:Name="mapPrinterWithDialog" Map="{Binding ElementName=Map}" Title="Map Title"
                           IsScaleFixed="True" Scale="2000000" />
                        </printing:MapPrinterDialog>

                  
            </Grid>

                       
        </userControls:CollapsiblePanel>



I had to wrap my code in a userControls:CollapsiblePanel instead of a userControls:WindowPanel like you were doing and I noticed when I was playing around with your example/sample the printing dialog screen refresed if I toggled the WindowPanel on/off so I'm thinking that was this code you had here:

<userControls:WindowPanel x:Name="MapPrinterDialogPanel" Width="340" Height="405"
                            IsOpen="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked, Mode=TwoWay}"
                            HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,60,10,0">


So is there something I'm missing or something that I can change?

Thanks a bunch.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

The only problem I'm having is my printing dialog isn't refreshing when my map extent changes

The print sample doesn't wire up the map extent changes.
The print extent is defined when 'IsActive' is set to true and then is frozen (except by the 'ChangePrintextent' command inside the preview window).

In the sample, the print extent is defined when the windowpanel is being opened. This is done by this binding :
IsActive="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked }"
i.e. when the print button is checked, the map printer captures the current extent and the current layers.

Additionaly IsOpen="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked, Mode=TwoWay}"
binds the visibility of the window panel to the same button.

0 Kudos
NathalieNeagle
Regular Contributor
Thanks Dominique,

That is what I thought but the Togglebutton is giving me a problem that why I moved over to using a simple Button and then had to drop the IsActive because it did not apply to a button...just a togglebutton I think.

When I try to use a toggle I'm getting the error:


Failed to assign to property 'System.Windows.FrameworkElement.Style'. [Line: 3219 Position: 93]

System.Windows.Application.LoadComponent(this, new System.Uri("/TabbedRibbon;component/MainPage.xaml", System.UriKind.Relative));


I'm I missing a ref or something?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
it did not apply to a button...just a togglebutton I think.

Right, 'IsChecked' applies for ToggleButton only.

If you are not a MVVM "purist" in terms of following "no code behind for the View" guideline, I would just toggle the IsActive property by code when the user clicks on your print button (at the same that you toggle the preview visibility).... otherwise it is probably possible to use binding/actions/... without code but I would need more infos about the container you are using.
0 Kudos
NathalieNeagle
Regular Contributor
Thanks again Dominique for all the time you are spending with me.

So I was able to get the togglebutton to compile but it is not opening and closing my



                                <ToggleButton x:Name="btnToggleMapPrinterDialogPanel" IsChecked="True"
                     ToolTipService.ToolTip="Print Dialog">
                                    <ToggleButton.Content>
                                        <Image Source="/MapPrintingControls;component/Images/i_print.png" Stretch="Fill" />
                                    </ToggleButton.Content>
                                </ToggleButton>




and this is my user control in my xaml


<!--MapPrinter Dialog Panel-->
        <userControls:CollapsiblePanel x:Name="MapPrinterDialogPanel" Width="340" Height="405"
 IsExpanded="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked, Mode=TwoWay}"
                HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,60,10,0" Effect="{StaticResource dropShadow}">

            <Grid>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>


                <StackPanel Orientation="Horizontal" Background="{StaticResource CommonPanelBorderBackgroundBrush}" Effect="{StaticResource miniDropShadow}"    >
                    <TextBlock Foreground="White" FontSize="12" 
                 Text="Page Style : " TextWrapping="NoWrap" VerticalAlignment="Center" />

                    <ComboBox Name="comboPrintStyle" SelectionChanged="comboPrintStyle_SelectionChanged" Margin="5,2" MinWidth="80" SelectedIndex="0" VerticalAlignment="Center">
                        <ComboBox.Items>
                            <sys:String>(Default)</sys:String>
                            <sys:String>Basic</sys:String>
                            <sys:String>WithOverview</sys:String>
                            <sys:String>WithClonedMapAsOverview</sys:String>
                            <sys:String>WithLegend</sys:String>

                        </ComboBox.Items>
                    </ComboBox>
                </StackPanel>


                <printing:MapPrinterDialog x:Name="MapPrinterDialog" Background="{StaticResource CommonPanelBorderBackgroundBrush}" BorderBrush="{StaticResource CommonBorderBrush}" Grid.Row="1">
                    <printing:MapPrinter x:Name="mapPrinterWithDialog" Map="{Binding ElementName=Map}" Title="Map Title"
                           IsScaleFixed="True" Scale="2000000" IsActive="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked }"/>/>
                </printing:MapPrinterDialog>

            </Grid>
          
        </userControls:CollapsiblePanel>
        <!--END MapPrinter Dialog Panel-->



So since I'm trying to use a collapisble panel instead of userControls:WindowPanel that you created I'm having to change IsOpen to something and I was trying IsExpanded.  The code complies and everything seems good but the toggle button is not closing and opening the print dialog.

IsOpen="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked, Mode=TwoWay}"


IsExpanded="{Binding ElementName=btnToggleMapPrinterDialogPanel, Path=IsChecked, Mode=TwoWay}"


Thanks again for all the time and help.  I really appreciate.

Nathalie.
0 Kudos
SamuelDantas
Emerging Contributor
Hi Dominique,

I'm trying to print a GraphicsLayer that has customized MarkerSymbols (binding one of the graphic's attributes, which has a TextBlock, to the child border inside the control template):

<Grid.Resources>
 <esri:MarkerSymbol x:Name="CustomSymbol1">
  <esri:MarkerSymbol.ControlTemplate>
   <ControlTemplate>
    <Border Child="{Binding Attributes[MyTextBlock]}"/>
   </ControlTemplate>
  </esri:MarkerSymbol.ControlTemplate>
 </esri:MarkerSymbol>
</Grid.Resources>


When this layer is empty, the printing works fine.
When it is not, an unhandled exception ("Value does not fall within the expected range") appears.

I tried to debug the MapPrintringControls project from the solution but I can't find where the exception occurs.

Any ideas?
Thanks a lot.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Nathalie,

At first glance, I don't see why your button would not collapse the dialog panel.

Just a reminder : the button and the panel have to be in the same xaml file. is it your case?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Samuel,

Your attributes contain UIElements that we try to reuse in the printmap.
That's likely your issue since an UIElement can't be reused.

The print sample doesn't clone the attributes but you can extent it to clone the UIElements included in the attributes.

The actual cloning code is this one:
private static Layer CloneLayer(Layer layer)
{
    ....... 
        var graphicCollection = new GraphicCollection();
        foreach (var graphic in fromLayer.Graphics)
        {
            var clone = new Graphic();
 
            foreach (var kvp in graphic.Attributes)
            {
                clone.Attributes.Add(kvp);
            }
...........
This one should clone the UIElements:
private static Layer CloneLayer(Layer layer)
{
    ....... 
        var graphicCollection = new GraphicCollection();
        foreach (var graphic in fromLayer.Graphics)
        {
            var clone = new Graphic();
 
            foreach (var kvp in graphic.Attributes)
            {
                if (kvp.Value is DependencyObject)
                {
                    // If the attribute is a dependency object --> clone it
                    var clonedkvp = new KeyValuePair<string, object>(kvp.Key, (kvp.Value as DependencyObject).Clone());
                    clone.Attributes.Add(clonedkvp);
                }
                else
                    clone.Attributes.Add(kvp);
            }........


Hope this help.
0 Kudos
SamuelDantas
Emerging Contributor
Thank you, Dominique. It's working now.
0 Kudos