Thanks for the quick reply. That worked well. I’m having a performance problem that I just can’t track down, however. If I load a default background node in my Diagram, everything is fine. If I then load a new image into the background, it makes my machine slow to a crawl. Granted, I have about 200 nodes, and I’m about a 5000x5000 area in my Diagram, but if I load the default image at 5000x5000, the performance is still fine.
I’m running the 1.3 beta of GoWPF.
Here’s the relevent information for my background node:
<go:Node MouseLeftButtonDown="Background_MouseLeftButtonDown" Id="BackgroundImage">
<Image x:Name ="ImageData" Source="C:\Users\Dan\Documents\GoWPF 1.3.1.4\Samples\GoWpfBasic\argentina-flag.Png"
Width ="4000" Height="4000" go:Node.Location="0 0"
go:Part.LayerName="Background"
go:Part.LayoutId="None" go:Node.Avoidable="False"
go:Part.Selectable="True"
/>
<ContextMenuService.ContextMenu>
<ContextMenu>
<MenuItem Header="Page Setup" Click="PageSetup"/>
<MenuItem Header="Float Background Image" Click="FloatBackground"/>
<MenuItem Header="Lock Background Image" Click="LockBackground"/>
<MenuItem Header="Change Background" Click="ChangeBackground"/>
<MenuItem Header="----------------------"/>
<MenuItem Header="Clear Background" Click="ClearBackground"/>
</ContextMenu>
</ContextMenuService.ContextMenu>
</go:Node>
<ContextMenuService.ContextMenu>
<ContextMenu>
<MenuItem Header="Change Background" Click="ChangeBackground"/>
</ContextMenu>
</ContextMenuService.ContextMenu>
</go:Diagram>
And the code that loads the new image:
private void ChangeBackground(object sender, RoutedEventArgs e)
{
Node backg = OasisDiagram.PartsModel.FindNodeByKey("BackgroundImage");
//Image img = backg.VisualElement as Image;
String filename = OpenDialog("Background.jpg", ".jpg", "Images (.jpg)|*.jpg|(.png)|*.png");
if (filename != null && filename != "")
{
//Load the image file here
BitmapImage bi = new BitmapImage();
bi.BeginInit();
//bi.DecodePixelHeight = 1024;
//bi.DecodePixelWidth = 1024;
bi.CacheOption = BitmapCacheOption.OnDemand;
bi.UriSource = new Uri(filename);
bi.EndInit();
Rect b = OasisDiagram.Panel.DiagramBounds;
(backg.Content as Image).Width = b.Width;
(backg.Content as Image).Height = b.Height; ;
(backg.Content as Image).Source = bi;
bi = null;
}
backg.Selectable = false;
}
It’s not just loading the new image, but doing ANYTHING to the background image causes the stalling - even setting myBackground.Selectable = false; causes it.
It appears that I’m spending most of my time in these functions:
Northwoods.GoXam.DiagramPanel.ArrangeOverride(valuetype System.Windows.Size)
NW.GX.DiagramPanel.#0q(class System.Collections.Generic.HashSet1<class Northdoows.GoXam.Part>, class System.Collections.Generic.HashSet
1)
I’m not having this problem on my sandbox project, but I don’t have the same structures.