OK, I have tried to reproduce this problem, but I am unable to do so. The PNG image files my app is writing tend to be over 50K wide. Here’s what at the far right side in Photo Viewer:
This is with WPF 4.0 and VS2010 on a Windows 7 x64 system.
And here’s the code:
[code]
<UserControl.Resources>
<go:NodeShape x:Name=“ICON”
go:NodePanel.Figure=“Triangle”
Fill="{Binding Path=Data.Color}"
Stroke=“Black” StrokeThickness=“1”
Width="{Binding Path=Data.Width}"
Height="{Binding Path=Data.Height}"
go:Node.PortId="" />
</UserControl.Resources>
[/code]
[code]/* Copyright © Northwoods Software Corporation, 2008-2013. All Rights Reserved. */
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using Northwoods.GoXam.Model;
namespace BigTree {
public partial class BigTree : UserControl {
public BigTree() {
InitializeComponent();
var nodes = new ObservableCollection<NodeData>() { };
var links = new ObservableCollection<LinkData>() { };
// create the node data and the link data for the model
GenerateNodes(nodes);
GenerateLinks(nodes, links);
// create the model with the data
var model = new GraphLinksModel<NodeData, String, String, LinkData>();
model.LinksSource = links;
model.NodesSource = nodes;
myDiagram.Model = model;
myDiagram.InitialLayoutCompleted += (s, e) => {
myStatus.Text = myDiagram.Panel.DiagramBounds.ToString();
};
}
void GenerateImage(Object sender, EventArgs e) {
Rect bounds = myDiagram.Panel.DiagramBounds;
double w = bounds.Width;
double h = bounds.Height;
double s = 1.0;
//if (w > 2000) s = 2000/w;
//if (h > 2000) s = Math.Min(s, 2000/h);
//w *= s;
//h *= s;
myDiagram.Panel.MakeBitmap(new Size(w, h), 96, new Point(bounds.X, bounds.Y), s,
bmp => {
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(bmp));
using (System.IO.Stream stream = System.IO.File.Create(@"C:\temp\BigTree.png")) {
png.Save(stream);
}
});
}
// Creates a collection of randomly colored NodeData objects.
private void GenerateNodes(IList<NodeData> nodes) {
int numNodes = 1999;
Random rand = new Random();
for (int i = 0; i < numNodes; i++) {
var d = new NodeData() {
Key = i.ToString(),
Location = new Point(0, 0),
// Width and Height could be set based on the Category
// or other information available when creating this node data object
// assume VirtualTreeLayout will assign the Location
Color = String.Format("#{0:X}{1:X}{2:X}", 120+rand.Next(100), 120+rand.Next(100), 120+rand.Next(100))
};
if (i == 0) d.Location = new Point(0, 0); // locate root node
nodes.Add(d);
}
}
// Takes the collection of nodes and creates a random tree with them by creating LinkData objects
private void GenerateLinks(IList<NodeData> nodes, IList<LinkData> links) {
int maxLinks = 2;
var available = new HashSet<NodeData>(nodes);
Random rand = new Random();
foreach (NodeData next in nodes) {
available.Remove(next);
int children = rand.Next(maxLinks)+1;
for (int i = 0; i < children; i++) {
NodeData to = available.FirstOrDefault();
if (to == null) return;
available.Remove(to);
links.Add(new LinkData() { From = next.Key, To = to.Key });
}
}
}
}
public class NodeData : GraphLinksModelNodeData {
// assume this won’t change dynamically, so don’t need to call RaisePropertyChanged
public String Color { get; set; }
public double Width {
get { return _Width; }
set { if (_Width != value) { double old = _Width; _Width = value; RaisePropertyChanged("Width", old, value); } }
}
private double _Width = 30;
public double Height {
get { return _Height; }
set { if (_Height != value) { double old = _Height; _Height = value; RaisePropertyChanged("Height", old, value); } }
}
private double _Height = 30;
}
public class LinkData : GraphLinksModelLinkData<String, String> { }
}[/code]
Could you help me reproduce the problem?