Hi Stoyan,
Right, I've just taken my custom node class and directly replaced your EmployeeNode class with it so that I can send you a "broken" project to play with.
What I immediately noticed was that now, when i create new nodes on vbnetTest, that the nodes are as i am seeing the copies - blank and white! So, I can now see that's due to the context xml which, for you, is populated and for me is essentially blank! I fill in all of the details at creation time.
My LoadFrom and SaveTo methods are:
Protected Overrides Sub SaveTo(writer As System.IO.BinaryWriter, context As MindFusion.Diagramming.PersistContext)
MyBase.SaveTo(writer, context)
Dim StrTag As New StringTag
StrTag.Description = Text
StrTag.Title = Title
StrTag.titleFont = TitleFont.Name
StrTag.titleSize = TitleFont.Size
StrTag.descFont = TextFont.Name
StrTag.descSize = TextFont.Size
context.SaveTag(StrTag)
context.SaveImage(Image)
context.SavePen(Stroke)
context.SaveBrush(Fill)
context.SaveColor(glowColor)
End Sub
Protected Overrides Sub LoadFrom(reader As System.IO.BinaryReader, context As MindFusion.Diagramming.PersistContext)
MyBase.LoadFrom(reader, context)
Dim StrTag As New StringTag
StrTag = context.LoadTag()
Title = StrTag.Title
Text = StrTag.Description
TitleFont = New Font(StrTag.titleFont, StrTag.titleSize)
TextFont = New Font(StrTag.descFont, StrTag.descSize)
If Title IsNot Nothing Then 'If flow node
Image = context.LoadImage()
Stroke = context.LoadPen()
Fill = context.LoadBrush()
glowColor = context.LoadColor()
End If
End Sub
As you can see, the colors and images etc i am loading from the context - which will take it from the blank XML! It should really be saving the actual image and colours etc of the copied node.
I can't seem to see how i can change these methods to copy the actual contents of the current node so any guidance for that would be great!
For reference, my "context" xml is:
content = _
"<SimplePanel>" & _
"" & _
" <Shape Name=""Shape"" Shape=""RoundRect"" />" & _
"" & _
" <Border Padding=""2"">" & _
" <GridPanel>" & _
" <GridPanel.Columns>" & _
" <GridColumn Width=""5"" />" & _
" <GridColumn />" & _
" </GridPanel.Columns>" & _
" <GridPanel.Rows>" & _
" <GridRow />" & _
" </GridPanel.Rows>" & _
"" & _
" <Image Name=""Image"" ImageAlign=""Fit"" />" & _
"" & _
" <StackPanel Orientation=""Vertical"" GridColumn=""1"">" & _
" <Text Name=""Title"" Font=""Arial, 10pt, style=Bold"" TextAlignment=""Near"" Text="" "" />" & _
" <Text Name=""Text"" Font=""Arial, 8pt"" TextAlignment=""Near"" Text="" "" />" & _
" </StackPanel>" & _
" </GridPanel>" & _
" </Border>" & _
"" & _
"</SimplePanel>"
Thanks,
Rich