Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) Copy/Paste multiple compositeNodes (Read 12367 times)
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy/Paste multiple compositeNodes
Reply #15 - Aug 26th, 2014 at 10:10am
Print Post  
Hi Rich,

Apparently TextComponent does not initialize its Text property and then BinaryWriter throws an exception for null strings. You will have to set it to an empty string from your node's constructor or XML template for time being.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: Copy/Paste multiple compositeNodes
Reply #16 - Aug 27th, 2014 at 6:05am
Print Post  
Hi Stoyan,

Yes! You're right. The Text property of my TextComponents are showing as Nothing. For some reason, if I change these in the constructor to be empty strings then they still show as Nothing during a copy operation (Like they're being reloaded from the context or something)! If I force them to be an empty String at that stage then I no longer get the error but, as before, the new nodes are appearing as blank, white nodes - with no Text, Colour, Effects or Image showing.

Is it possible that all Components of the Composite Node are not initializing properly during a copy operation? Because, if I save the diagram with the blank nodes and reload it then they all appear perfectly fine - which would make sense in that case because the nodes have all been recreated using the New(Diagram) constructor....

That being said, I can't see why your example code wouldn't have the same problem...!

Cheers,

Rich
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy/Paste multiple compositeNodes
Reply #17 - Aug 27th, 2014 at 6:56am
Print Post  
Could you attach here a test project that shows the problem, or email it to our support email address?
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: Copy/Paste multiple compositeNodes
Reply #18 - Aug 27th, 2014 at 10:02am
Print Post  
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:

Code
Select All
    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:

Code
Select All
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 Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy/Paste multiple compositeNodes
Reply #19 - Aug 27th, 2014 at 10:26am
Print Post  
Hi Rich,

Then the content will disappear indeed if you load the template XML after calling base copy constructor. If you are using the same approach to load the XML and set component references via a Load method, try adding a boolean argument that will let you skip the XML part and set it to false when calling from copy constructor:

Code
Select All
Private Sub Load(loadTemplate as Boolean)
    if loadTemplate then
        Components.Clear()
        Components.Add(XmlLoader.Load(Content, Me, Nothing))
    end if

    shape = TryCast(FindComponent("Shape"), ShapeComponent)
    m_image = TryCast(FindComponent("Image"), ImageComponent)
.... 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: Copy/Paste multiple compositeNodes
Reply #20 - Aug 27th, 2014 at 11:30am
Print Post  
Hi Stoyan,

Brilliant, works a treat! Thanks very much for all your help!

The effects on the node are still not feeding through at copy time (Aero/Glass/etc) but that's trivial and i should be able to work that out... The text and colours etc are coming through properly now though. Thanks again for your help!

Rich Smiley
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: Copy/Paste multiple compositeNodes
Reply #21 - Sep 17th, 2014 at 9:12am
Print Post  
Hi Stoyan,

Sorry to bump this thread back up to the top again but as it's exactly the same issue as my last post it seemed silly to create a new thread.

When I copy and paste composite nodes the Effects are not coming across with them Huh ... When I look into the object the Effect list is full and they're all there as i would expect but they're not appearing on the diagram (i'm using Aero and Glass). Oddly, when i save the diagram with the new copied nodes and load it back, they do appear with their Effects like the rest of the nodes do...

Any ideas on why this could be? I've tried clearing the Events list and re-adding the Effect instances but that's not working either.

Thanks,
Rich  Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy/Paste multiple compositeNodes
Reply #22 - Sep 18th, 2014 at 12:22pm
Print Post  
Hi,

Copy / paste seems to work well with effects in our test project here:
https://mindfusion.eu/_samples/VbnetCopyPaste.zip

Please let me know what we should change to reproduce the problem.

Stoyan
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: Copy/Paste multiple compositeNodes
Reply #23 - Sep 18th, 2014 at 1:47pm
Print Post  
Hi Stoyan,

Thanks for the test project. As you say, it works perfectly well on there so i'm not sure why it's not behaving on mine. Our system is different in that the Glass/Aero effects are preferences that the user can enable / disable but that shouldn't really affect anything. The important parts of the code all seem to be identical so i'm not sure where i'm going wrong...

We do our Save/Load differently as we use "context.SaveTag" for example, whereas you do "writer.Write". Not sure the relevance of that though.

Anyway, thanks for the project, i'm obviously missing something obvious.

Rich Smiley
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: Copy/Paste multiple compositeNodes
Reply #24 - Sep 18th, 2014 at 2:24pm
Print Post  
Hi Stoyan!

Sorted it!  Cool

You are obviously using a separate XML file to hold the content of the object, whereas i was declaring my XML as a constant in the constructor of the object itself.

For the constructor which takes in a prototype (i.e. for the copy operations) the content was Nothing and so I was trying to rebuild it from the prototype itself, which must work other than for the Effects.

Anyway, declared the XML in there too and it works a treat.

Thanks for your help,

Rich Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint