Hi Stoyan,
Your recommendation solved my problem to some extent but there are 2 problems: 1. The overlap is still there inspite of having same custome shape 2. The node icons are very stretched out. I want them to be of same size as they appear in Silverlight Application.
Here is my code, please help urgently. I will also send the screen shots showing the issue in the email to you.:
Silverlight side code for node creation: private Shape GetRectTextShape() { var rrs = new MindFusion.Diagramming.Silverlight.Shape( new ElementTemplate[] { new RoundRectangleTemplate(0, 0, 140, 110, 0) }, null, new Rect(0, 65, 200, 80), FillRule.Nonzero, "RectText"); return rrs; }
public static ShapeNode CreateNode(Diagram graph, NodeProps nodeProps) { BitmapImage nodeImage = null; string iconURL = string.Empty;
ShapeNode child = new ShapeNode(graph); child.Shape = GetRectTextShape();
StringFormat sfmt = new StringFormat(); sfmt.Alignment = StringAlignment.Near; sfmt.LineAlignment = StringAlignment.Near; child.TextFormat = sfmt;
iconURL = "images/CI/" + nodeProps.Icon; child.Tag = nodeProps.Type.ToString();
child.Text = nodeProps.Label; child.ImageWebLocation = iconURL; child.EnabledHandles = AdjustmentHandles.Move; child.ImageAlign = ImageAlign.TopCenter; child.FontSize = 9; child.FontFamily = new FontFamily("MS Sans Serif,Tahoma"); child.Transparent = true; child.TabNavigation = KeyboardNavigationMode.Cycle; return child; }
SERVER SIDE CODE for loading and export: private Shape GetRectTextShape() { var rrs = new MindFusion.Diagramming.Shape( new ElementTemplate[] { new RoundRectangleTemplate(0, 0, 140, 110, 0) }, null, new ElementTemplate[] { new RoundRectangleTemplate(0, 65, 200, 80, 0) }, System.Drawing.Drawing2D.FillMode.Winding , "RectText"); return rrs; }
CreateImagefromXMLUsingNetDiagram(...) { Diagram diagram = new Diagram(); diagram.LoadFromString(xmlString);
Shape custShape = GetRectTextShape(); Font font = new Font("MS Sans Serif,Tahoma", 7);
ShapeNode shapeNode = null; string imageLocation;
IEnumerator iterator = diagram.Nodes.GetEnumerator();
while (iterator.MoveNext()) { shapeNode = iterator.Current as ShapeNode; shapeNode.Shape = custShape; StringFormat sfmt = new StringFormat(); sfmt.Alignment = StringAlignment.Near; sfmt.LineAlignment = StringAlignment.Near; shapeNode.TextFormat = sfmt; shapeNode.ImageAlign = ImageAlign.TopCenter;
imageLocation = "ClientBin/" + shapeNode.Tag as string; imageLocation = Server.MapPath(imageLocation); shapeNode.Image = System.Drawing.Image.FromFile(imageLocation);
shapeNode.Font = font; shapeNode.Transparent = true;
}
diagram.ResizeToFitItems(0, true); System.Drawing.Image image = diagram.CreateImage(); image.Save(@"D:\Temp\export.jpeg");
}
|