Printing Issues

I can’t seem to get printing to work properly for me. It appears that nodes that are based on a particular node template that I have are causing issues.

My diagram object looks like this:


<go:Diagram x:Name="myDiagram" Padding="10"
   SelectionChanged="myDiagram_SelectionChanged"
   HorizontalContentAlignment="Stretch"
   VerticalContentAlignment="Stretch"
   GridSnapEnabled="True"
   ContextMenuEnabled="True"
   NodeTemplateDictionary="{StaticResource NodeTemplateDictionary}" 
   AllowDrop="True"
   KeyDown="myDiagram_KeyDown"
   LinkTemplate="{StaticResource LinkTemplate}" Grid.Column="1" Margin="0,3,-0.5,3"
   Grid.Row="2" MinWidth="100">
      <go:Diagram.DefaultTool>
         <go:ToolManager WheelBehavior="Zooms" />
      </go:Diagram.DefaultTool>
      <go:Diagram.PrintManager>
         <go:PrintManager Scale="NaN"/>
      </go:Diagram.PrintManager>
</go:Diagram>

And I’m linking to the Print command by simply:

PrintButton.Command = myDiagram.CommandHandler.PrintCommand;

So to me it seems as basic as the printing setup could be.

My issue is that the diagram looks like this:
Actual Diagram

but outputs this when I print:

I’ve tried setting the bound:

myDiagram.PrintManager.Bounds = myDiagram.Panel.DiagramBounds;

…same result.

What I did notice though is that if I drop on a custom node that I created (that’s based on a different template), it works fine:

but as soon as I drop on one of my ‘Component’ nodes, I get this:

The node template that’s causing these issues looks like this:


        <DataTemplate x:Key="DiagramNodeTemplateConnector">
            <StackPanel go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
                  go:Part.SelectionAdorned="True" go:Part.SelectionElementName="Icon"
                  go:Part.SelectionAdornmentTemplate="{StaticResource NodeSelectionAdornmentTemplate}"
                  go:Node.RotationAngle="{Binding Path=Data.RotationAngle, Mode=TwoWay}"
                  MouseEnter="Node_MouseEnter" MouseLeave="Node_MouseLeave">
                <go:SpotPanel x:Name="Icon">
                    <Image x:Name="Image" Source="{Binding Data.OBJECT_IMAGE}"
                            Width="{Binding Data.DIAGRAM_WIDTH}" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <FrameworkElement.RenderTransform>
                            <ScaleTransform ScaleX="1" />
                        </FrameworkElement.RenderTransform>
                    </Image>
                    <Rectangle x:Name="C" Width="8" Height="8" go:Node.PortId="T" 
                             Stroke="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}"
                             Fill="{Binding Node.Tag, Converter={StaticResource theBooleanBrushConverter}}"
                             go:SpotPanel.Spot="{Binding Data.OBJECT_SPOT}" go:SpotPanel.Alignment="{Binding Data.OBJECT_SPOT}"
                             go:Node.FromSpot="{Binding Data.OBJECT_SPOT}" go:Node.ToSpot="{Binding Data.OBJECT_SPOT}"
                             go:Node.LinkableFrom="True" go:Node.LinkableTo="True"
                             go:Node.LinkableMaximum="1"/>
                </go:SpotPanel>
                <Grid x:Name="grdBottomConnectorLabels" Margin="-20,0,0,0" VerticalAlignment="Top">
                    <Grid.Background>
                        <ImageBrush Stretch="Uniform" ImageSource="/Configurator;component/Assets/Images/IDBubble.png"/>
                    </Grid.Background>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition x:Name="LeftColumn" Width="0.5*"/>
                        <ColumnDefinition x:Name="CenterColumn" Width="0.5*"/>
                        <ColumnDefinition x:Name="RightColumn" Width="0.5*"/>
                    </Grid.ColumnDefinitions>
                    <Image x:Name="imgPlugOrSocket"
                        Source="{Binding Data.PLUG_OR_SOCKET}"
                        HorizontalAlignment="Left" VerticalAlignment="Top" 
                        Height="20" Width="20" 
                        Grid.Column="0" />
                    <TextBlock x:Name="txtKeyLabel" 
                        FontWeight="Bold" FontSize="14" 
                        Text="{Binding Data.Key}" 
                        HorizontalAlignment="Center" VerticalAlignment="Top" 
                        Margin="0,20,0,0"  Grid.Column="1"/>
                </Grid>
            </StackPanel>
        </DataTemplate>

Can you see anything in my node template definition that might cause this? or any other suggestions?

Is this WPF or Silverlight? What version of GoXam? (If you are using Silverlight, you definitely should be at least at version 1.2.6.)

I would guess that it’s a problem with images. Where does the image data reside? There is a lot of asynchrony in both WPF and Silverlight, and perhaps the rendering of images causes an exception during printing if the image data isn’t immediately available.

You were correct about the images causing the issue. I replaced the images with black rectangles and now at least something is printing…

This is for Silverlight using GoXam 1.3.2.5

I’ll be looking into a better way to load images I guess…

Thanks for your help.