Hi,
I want to extend ShapeNode, I have this class:
Imports Microsoft.VisualBasic
Imports MindFusion.Diagramming
Public Class ShapeNodeExtension
Inherits ShapeNode
#Region "[Variable]"
Private _prop1 As String = String.Empty
#End Region
#Region "[Properties]"
Public Property Prop1() As String
Get
Return _prop1
End Get
Set(ByVal Value As String)
_prop1 = Value
End Set
End Property
#End Region
#Region "[Constructor]"
Shared Sub New()
End Sub
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal diagram As Diagram)
MyBase.New(diagram)
_prop1 = String.Empty
End Sub
Public Sub New(prototype As ShapeNode)
MyBase.New(prototype)
_prop1 = String.Empty
End Sub
#End Region
#Region "[Events]"
Public Overrides Sub Draw(graphics As MindFusion.Drawing.IGraphics, options As MindFusion.Diagramming.RenderOptions)
MyBase.Draw(graphics, options)
End Sub
Public Overrides Sub DrawShadow(graphics As MindFusion.Drawing.IGraphics, options As MindFusion.Diagramming.RenderOptions)
MyBase.DrawShadow(graphics, options)
End Sub
Protected Overrides Sub SaveToXml(xmlElement As System.Xml.XmlElement, context As MindFusion.Diagramming.XmlPersistContext)
MyBase.SaveToXml(xmlElement, context)
context.WriteString(_prop1, "Prop1", xmlElement)
End Sub
Protected Overrides Sub LoadFromXml(xmlElement As System.Xml.XmlElement, context As MindFusion.Diagramming.XmlPersistContext)
MyBase.LoadFromXml(xmlElement, context)
_prop1 = context.ReadString("Prop1", xmlElement)
End Sub
Protected Overrides Sub SaveTo(ByVal writer As System.IO.BinaryWriter, ByVal ctx As PersistContext)
MyBase.SaveTo(writer, ctx)
writer.Write(_prop1)
End Sub
Protected Overrides Sub LoadFrom(reader As System.IO.BinaryReader, context As MindFusion.Diagramming.PersistContext)
MyBase.LoadFrom(reader, context)
_prop1 = reader.ReadString()
End Sub
#End Region
End Class
in the Page_Load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim diagram As Diagram = diagramView.Diagram
diagram.SelectAfterCreate = False
If TryCast(diagram, IItemFactory).TypeTable(GetType(ShapeNodeExtension)) Is Nothing Then
diagram.RegisterItemClass(GetType(ShapeNodeExtension), "ShapeNodeExtension", 1)
End If
diagramView.CustomNodeType = GetType(ShapeNodeExtension)
Dim start As ShapeNode = diagram.Factory.CreateShapeNode(10, 10, 20, 15)
start.Shape = Shapes.Start
start.Text = "Start"
Dim start2 As New ShapeNode()
start2.Bounds = New System.Drawing.RectangleF(30, 30, 20, 15)
start2.Shape = Shapes.Start
start2.Text = "Start2"
diagram.Nodes.Add(start2)
Dim start3 As New ShapeNodeExtension()
start3.Bounds = New System.Drawing.RectangleF(60, 60, 20, 15)
start3.Shape = Shapes.Start
start3.Text = "Start3"
start3.Prop1 = "prop1..."
diagram.Nodes.Add(start3)
End If
End Sub
I have not got anything!!
If I remove this line: diagram.Nodes.Add(start3) I have the start1 and start2 ShapeNode...
What's the problem? ??? (I'm using ClientSideMode="JavaApplet")
Thanks,
Alberto