Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Using referenced deleted objects (Read 3790 times)
feugen24
YaBB Newbies
*
Offline



Posts: 27
Joined: Sep 22nd, 2006
Using referenced deleted objects
Nov 21st, 2006 at 1:28pm
Print Post  
Hi,
In short I want to create a list of boxes with different properties(shape,color...etc). When I browse the list I want flowchart to show 1 box with the coresponding properties.

How can use a deleted box reference?

For example:
Box box = _flowChart.CreateBox(....);
_flowChart.DeleteObject(box);
_flowChart.Add(box);
throws null ref exception in flowchart at draw.

Box box = _flowChart.CreateBox(....);
_flowChart.DeleteObject(box);
newB = new Box(box);  //throws null ref

I think something modifies the box when DeleteObject is called. I could serialize/deserialize the object but are there other options?

Also - each box has a "setReference(int refId,IPersists obj)" wich I could not find in documentation. what does it do?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using referenced deleted objects
Reply #1 - Nov 21st, 2006 at 1:52pm
Print Post  
Hi,

Deleting a node will dispose and set to null its Brush. The +/- buttons of expandable nodes and the scroll buttons of tables will be deleted too. So you might need to set the Brush before reusing a box, and possibly set Expandable = true. There might be some other side effects though, especially with undo/redo enabled. Why do you want to reuse a deleted box - can't you keep the box around and set it Visible = true/false according to whether it's needed or not?

SetReference is used for serialization, but we are reworking the serialization code for the next version anyway and the method won't be available anymore, so better do not touch it.

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



Posts: 27
Joined: Sep 22nd, 2006
Re: Using referenced deleted objects
Reply #2 - Nov 21st, 2006 at 4:52pm
Print Post  
"Why do you want to reuse a deleted box - can't you keep the box around and set it Visible = true/false according to whether it's needed or not?"

I could use Visible...but for 100+ boxes it would mean that I have on flowchart 99 boxes hiden and 1 box visible at the same position instead of 1 box on flowchart and 99 in a list. I don't know if this won't generate problems(I think the real number will be more than 30 less than 500 depending on the user). Other than this I would prefer working with Visible because it's easier.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using referenced deleted objects
Reply #3 - Nov 22nd, 2006 at 6:12am
Print Post  
Ok, setting back the Brush should help you then. It might be better to keep your prototype boxes in a separate collection outside of the flowchart, and clone them when you need to show a box, using the fc.Add(new Box(Box prototype)) method and copy constructor. Then you can delete the cloned box and still have the original prototype remain intact.

Stoyan
  
Back to top
 
IP Logged
 
feugen24
YaBB Newbies
*
Offline



Posts: 27
Joined: Sep 22nd, 2006
Re: Using referenced deleted objects
Reply #4 - Nov 22nd, 2006 at 8:02am
Print Post  
For now it works but I have another problem with serialization....flowchart objects are not serializable...Sad. Now I need to save that list of objects on disc an load the nodes for usage when designing a diagram on another flowchart...so I can think of 2 options:
1. I serialize the first flowchart with all nodes and keep on my list only the id of a node....deserialize after and take the data from flowchart by id from the list
2. Save in the list using reflection all the properties of a node so i can change a new node by using them...and serialize the list

Are there other options to serialize(xml or binary) data without flowchart?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using referenced deleted objects
Reply #5 - Nov 22nd, 2006 at 8:31am
Print Post  
I can't think of any way to serialize individual objects. Instead of keeping the prototype nodes in a list, you might keep them in a hidden FlowChart instance, and serialize that hidden flowchart.

Stoyan
  
Back to top
 
IP Logged
 
feugen24
YaBB Newbies
*
Offline



Posts: 27
Joined: Sep 22nd, 2006
Re: Using referenced deleted objects
Reply #6 - Nov 23rd, 2006 at 2:10pm
Print Post  
Ok...I've serialized that hidden flowchart(1)....but now I have a box in this flowchart(1) that I want to put in another flowchart(2).
If I use flowchart2.Add(new Box(flowchart1_box))
the boxes collection in flowchart2 show that a box has been added but no box apears on the screen.

How can I do this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using referenced deleted objects
Reply #7 - Nov 23rd, 2006 at 2:18pm
Print Post  
Try setting the BoundingRect and Visible properties of the "new Box(flowchart1_box)".

Stoyan
  
Back to top
 
IP Logged
 
feugen24
YaBB Newbies
*
Offline



Posts: 27
Joined: Sep 22nd, 2006
Re: Using referenced deleted objects
Reply #8 - Nov 24th, 2006 at 12:43pm
Print Post  
This was my mistake...I forgot visible was set to false. Thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint