Slavcho wrote on Oct 26
th, 2016 at 8:27am:
If you are creating the links on server side, make sure the JavaScript constructor takes (diagram,origin,destination) arguments and passes them to base constructor as in
http://mindfusion.eu/Forum/YaBB.pl?num=1475674482&3#3 or otherwise they won't deserialize correctly from JSON.
Regards,
Slavcho
Mindfusion
Constructor seems to be correct, but it's still drawing standart DiagramingLink, maybe I need to set something
My class js file: CustomDiagramLink = function (parent, origin, destination) {
CustomDiagramLink .initializeBase(this, [parent, origin, destination]);
}
CustomDiagramLink .prototype =
{
initialize: function () {
CustomDiagramLink.callBaseMethod(this, 'initialize');
},
dispose: function () {
CustomDiagramLink.callBaseMethod(this, 'dispose');
},
toJson: function () {
var data = CustomDiagramLink.callBaseMethod(this, "toJson");
return data;
}
};
if (typeof (Sys) !== 'undefined')
Sys.Application.notifyScriptLoaded();
My .cs Link class: public class CustomDiagramLink : DiagramLink
{
private string _sqlCondition;
public string SQLCondition
{
get
{
return _sqlCondition;
}
set
{
_sqlCondition = value;
}
}
private string _bindableText;
public string BindableText
{
get
{
return _bindableText;
}
set
{
Text = _bindableText = value;
}
}
public CustomDiagramLink(Diagram parent) : base(parent)
{
Init();
}
public CustomDiagramLink(Diagram parent, DiagramNode origin, Point point)
: base(parent, origin, point)
{
Init();
}
public CustomDiagramLink(Diagram parent, DiagramNode origin, DiagramNode destination)
: base(parent, origin, destination)
{
Init();
}
private void Init()
{
SetStyle();
}
private void SetStyle()
{
MindFusion.Drawing.Brush defaultBrush = new MindFusion.Drawing.SolidBrush(Color.Black);
Brush = defaultBrush; //arrow head background
Pen = new MindFusion.Drawing.Pen(Color.Pink, 5); //arrow line
BaseShape = Shapes.Alternative;
HeadShape = Shapes.Alternative;
HeadPen.Brush = defaultBrush; //arrow head border
TextBrush = defaultBrush;
}
protected override void SaveToXml(XmlElement xmlElement, XmlPersistContext context)
{
base.SaveToXml(xmlElement, context);
context.WriteString(SQLCondition, "SQLCondition", xmlElement);
context.WriteObjectCollection(Actions, "Actions", xmlElement);
}
protected override void LoadFromXml(XmlElement xmlElement, XmlPersistContext context)
{
base.LoadFromXml(xmlElement, context);
SQLCondition = context.ReadString("SQLCondition", xmlElement);
Actions = context.ReadObjectCollection("Actions", xmlElement);
SetStyle();
}
}