Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Really simple/stupid save/load question (Read 2704 times)
SavyCat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Really simple/stupid save/load question
Feb 18th, 2008 at 2:26pm
Print Post  
Hi guys, I cant seem to get this to work. I have read the manual, tried the forums and now I have to ask someone. I cant get the SaveToFile and LoadFromFile to work. I created a really simple app - but no luck. Could any one please point out whats wrong with this? It seems really simple, so its driving me mad. If there is no obvious mistake - the IDE raises a null exception on the LoadFrom(System.IO.BinaryReader reader, PersistContext ctx) function. Here is my code:

Code
Select All
public class TestNode : ShapeNode
    {
        public TestNode()
            : base()
        {
        }

        protected override void SaveTo(System.IO.BinaryWriter writer, PersistContext ctx)
        {
            base.SaveTo(writer, ctx);
        }

        protected override void LoadFrom(System.IO.BinaryReader reader, PersistContext ctx)
        {
            base.LoadFrom(reader, ctx);
        }
    } 



Code
Select All
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            Diagram.RegisterItemClass(typeof(TestNode), "TestNode", 1);

            TestNode test = new TestNode();
            diagram1.Nodes.Add(test);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //A save button
            diagram1.SaveToFile("Test");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //A load button
            diagram1.LoadFromFile("Test");
        }
    } 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Really simple/stupid save/load question
Reply #1 - Feb 19th, 2008 at 6:35am
Print Post  
Hi,

This looks like a bug - the ShapeNode deserialization code expects that its parent diagram should be already set. To work around that, add this constructor to TestNode

Code
Select All
public TestNode(Diagram parent) : base(parent)
{
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
SavyCat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Re: Really simple/stupid save/load question
Reply #2 - Feb 19th, 2008 at 8:32am
Print Post  
Ah ha, that would why then Smiley I changed it and it worked out fine. Thanks Stoyo!
  
Back to top
 
IP Logged
 
SavyCat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Re: Really simple/stupid save/load question
Reply #3 - Feb 19th, 2008 at 3:36pm
Print Post  
Hi Stoyo, this might be related or I might be doing it wrong; but I cant seem to get a controlNode to save or load - even if I do provide the diagram and have made sure the control has no constructor parameters. Any ideas? Thanks again Smiley
  
Back to top
 
IP Logged
 
SavyCat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Re: Really simple/stupid save/load question
Reply #4 - Feb 19th, 2008 at 3:44pm
Print Post  
oh - forgot to say that the control is a user control with a few buttons, a list view, a checkbox and is [serialized].
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Really simple/stupid save/load question
Reply #5 - Feb 19th, 2008 at 4:59pm
Print Post  
Flowchart.NET saves automatically only the public properties of hosted controls, and only if they are of serializable types. You could handle the SerializeControl event to implement your own serialization, or just create public properties for all pieces of data that should be saved.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint