Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Undo Text Edited (Read 3096 times)
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Undo Text Edited
Dec 10th, 2008 at 1:39pm
Print Post  
Hi again,

I would like to know how to ask the UndoManager to record text editing (cells & captions in tableNode).

I could use diagram.CellEditing & diagram .CellEdited, but if the user presses ESC or doesn't change anything, how do I erase the ChangeItemCmd?

Thanks,
Marie
« Last Edit: Dec 10th, 2008 at 4:38pm by marie »  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Undo Text Edited
Reply #1 - Dec 10th, 2008 at 2:52pm
Print Post  
I have another question on the same subject (undo/redo).

When I delete a table node and undo that action, the shapenodes attached to that node do not disappear...

The shape nodes are linked to the table node using the following code:

Code
Select All
ShapeNode btn = this.diagram.Factory.CreateShapeNode(x, y, width, height);
btn.AttachTo(node, AttachToNode.TopLeft);
node.SubordinateGroup.AutoDeleteItems = true; 



How can I make them reappear?

Thank you,
Marie
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Undo Text Edited
Reply #2 - Dec 10th, 2008 at 3:09pm
Print Post  
Another issue I have:

TableNode.ResizeToFitText doesn't seem to be a recorded action. If I resize the node manually, it's fine, but with that method it's not.

I'm not totally sure this is the cause of a problem I have, so I will describe it:
I have the following code that adds a cell to a table node:
Code
Select All
// Count the number of items in that column
int count = 0;
for (int i = 0; i < tableNode.RowCount; i++)
{
    TableNode.Cell cell = tableNode[column, i];
    if (cell != null && cell.Text != null && cell.Text != string.Empty)
	  count++;
}

ChangeItemCmd changeItem = new ChangeItemCmd(tableNode, "Add " + text);

// Add row if necessary
if ((count + 1) >= tableNode.RowCount)
    tableNode.RowCount++;

// Add anchor point
AnchorPoint anchorPoint = GetAnchorPoint(column);
if (anchorPoint == null)
    return;

if (tableNode.Rows[count].AnchorPattern == null)
    tableNode.Rows[count].AnchorPattern = new AnchorPattern();
AnchorPattern anchorPattern = tableNode.Rows[count].AnchorPattern;

anchorPattern.Points.Add((AnchorPoint)anchorPoint.Clone());

// Set text & alignment
int number = count + 1;
tableNode[column, count].Text = text + " " + number;

if (column == OUT_COLUMN)
    tableNode[column, count].TextFormat.Alignment = StringAlignment.Far;

tableNode.ResizeToFitText(false, true);
changeItem.Execute(); 



Everything's fine, except that if I undo the change, my shapeNode button is painted outside the table's borders. That shapenode is attached to the bottom-right corner of the tablenode. After undo, it gets painted at the same position it used to be before the undoing of the cell's addition (outside the table's boundaries since it got smaller). This of course happens only in the case that the cell is added on a new row.

How can I fix those 2 problems (painting of the shapenode + resizeToFixText that is not recorded)?

Thank you,
Marie
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo Text Edited
Reply #3 - Dec 11th, 2008 at 6:37am
Print Post  
Hi,

Simply don't call the command's Execute method if the text hasn't changed.

You should create a composite command that encapsulates the creation of the TableNode and all attached ShapeNodes, and then undoing/redoing the delete operation will make all related nodes appear or disappear at the same time.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Undo Text Edited
Reply #4 - Dec 11th, 2008 at 2:04pm
Print Post  
Hi Stoyan,

-1- About the ChangeItemCmd: If it never gets executed nor disposed, it's fine? When is it going to be unloaded? I don't want to have memory problems...

-2- About the disappearing nodes after undoing delete: I'll try the composite command, but I think this should already be recorded by UndoManager. If this could be fixed this in future releases, it would be helpful.

-3- About ResizeToFitText that is not recorded: Is it normal or am I doing something wrong? How can I fix this?

-4- About ShapeNode that gets painted outside TableNode's boundaries: What can I do about it?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo Text Edited
Reply #5 - Dec 11th, 2008 at 3:33pm
Print Post  
Hi Marie,

1) the control does not keep any references to the command object, as long as you do not call Execute, so it will be GC-ed once the GC runs.

2) I believe it is recorded, but you get a command for each node, instead of a single command for the whole group, and would have to call Undo many time to restore all items.

3 & 4) Our developer could not reproduce it. Please save a diagram containing a table with the attached items and email it to support@mindfusion.eu so we can try that with the same settings as yours.

Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Undo Text Edited
Reply #6 - Dec 11th, 2008 at 4:25pm
Print Post  
Hi Stoyan,

Thanks for you answer!

1) Perfect!

2) It is not recorded (no matter how many times I press undo). The only thing I do is
Code
Select All
this.diagram.Nodes.Remove(NodeClicked); 


Its attached shape nodes are deleted by themselves (I think it is because of the node.SubordinateGroup.AutoDeleteItems parameter set to true). Could you try it? If you can't reproduce it, I'll add it to the 3) & 4) demo.

3) & 4) I will do that. Unfortunately, my priority have changed and since undo/redo is not as easy as I thought (but I understand, it's a really complex functionnality), it will take some time. Maybe I will find the answer doing that demo, if so I will post it here.

Regards,
Marie
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint