Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic BoxEvent raised when loading from File? (Read 3957 times)
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
BoxEvent raised when loading from File?
Apr 19th, 2007 at 9:22am
Print Post  
Hallo,

simple question: When I load a previously saved diagram, is the BoxCreated event raised while drawing?

Best regards,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BoxEvent raised when loading from File?
Reply #1 - Apr 19th, 2007 at 10:03am
Print Post  
Hi,

It should be raised. Have you found a situation in which it isn't?

Best regards,
Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: BoxEvent raised when loading from File?
Reply #2 - Apr 19th, 2007 at 10:44am
Print Post  
Hmm, seems like.

I do the following:

Code
Select All
        public DrawArea(String name, Project p, String fileName)
        {
            InitializeComponent();
            this.project = p;
            this.processName = name;
            this.fileName = Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToString() + "\\FPEditor\\" + processName + ".fpp";
            this.TabText = name;
            this.flowChart.BoxCreated += new BoxEvent(flowChart_BoxCreated);
            this.flowChart.BoxClicked += new BoxMouseEvent(flowChart_BoxClicked);
            if (File.Exists(this.fileName))
            {
                this.flowChart.LoadFromFile(this.fileName);
            }
        }


        void flowChart_BoxCreated(object sender, BoxEventArgs e)
        {
             MessageBox.Show("Box created");
        }
 



Problem is, the object is displayed, but no event is raised.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BoxEvent raised when loading from File?
Reply #3 - Apr 19th, 2007 at 10:59am
Print Post  
Does it work if you attach the event handler after loading the file, or if you do not load a file at all?

A different Behavior value might be loaded from the file too; so what you draw in the flowchart could be a table or control-host node, for which you wouldn't get a BoxCreated event?

Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: BoxEvent raised when loading from File?
Reply #4 - Apr 19th, 2007 at 11:11am
Print Post  
The BoxCreated Event works even when the file is loaded (I drag the Boxes from a ShapeListBox).

The Debugger tells me, that when I click this loaded object, it is still a Box (so a BoxCreated Event should have been raised, right?).

So with my code the following works:
drag an object from ShapeListBox to Flowchart ==> BoxEvent raised;
save the diagram;
close application;
open application;
load diagram ==> BoxEvent not raised;
drag another object from ShapeListBox to Flowchart ==> BoxEvent raised;

Any further ideas?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BoxEvent raised when loading from File?
Reply #5 - Apr 19th, 2007 at 11:55am
Print Post  
>> load diagram ==> BoxEvent not raised;

Do you expect the event to be raised for the boxes being loaded from a file?

Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: BoxEvent raised when loading from File?
Reply #6 - Apr 19th, 2007 at 12:55pm
Print Post  
Exactly, that's what I kind of hoped Smiley

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BoxEvent raised when loading from File?
Reply #7 - Apr 19th, 2007 at 1:11pm
Print Post  
Ok, unfortunately BoxCreated is not raised while loading a file or creating boxes through the API. You only get it when users create boxes interactively Cry
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: BoxEvent raised when loading from File?
Reply #8 - Apr 21st, 2007 at 11:11am
Print Post  
OK, no big deal, I just wanted to know if I can use the same functions for user created and automaticly created objects, because I need to store meta information.
Just a quick question then. I'm still kind of new to the whole .NET stuff. Is it possible to store whole object information in .TAG property of a box ( let's say a class Product). Is all the information of the "Product" stored as well, if I call FlowChart.SaveToFile(String name)?

So is it possible to retrieve this information after loading it from file back into my application?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BoxEvent raised when loading from File?
Reply #9 - Apr 22nd, 2007 at 7:32am
Print Post  
You could create your own InitBox(Box) method and call it both from the BoxCreated handler and from a 'foreach box' loop after loading the file.

You can assign any object to the Box.Tag, and it will be saved automatically if the tag class is marked with the [Serializable] attribute.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint