Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Undo Redo, Ctrl-z, Ctrl-Y (Read 4497 times)
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Undo Redo, Ctrl-z, Ctrl-Y
Oct 7th, 2013 at 11:15am
Print Post  
Hi there,

Is it possible to undo and redo actions with Ctrl-z and Ctrl-Y in a Diagram?

Greets,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo Redo, Ctrl-z, Ctrl-Y
Reply #1 - Oct 7th, 2013 at 11:30am
Print Post  
Hi,

Set Diagram.UndoManager.UndoEnabled = true and handle ApplicationCommands.Undo/Redo:

Code
Select All
<Window.CommandBindings>
	<CommandBinding Command="ApplicationCommands.Undo"
          Executed="UndoCmdExecuted" />
</Window.CommandBindings>

private void UndoCmdExecuted(object sender, ExecutedRoutedEventArgs e)
{
	diagram.UndoManager.Undo();
} 



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


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Undo Redo, Ctrl-z, Ctrl-Y
Reply #2 - Oct 7th, 2013 at 12:03pm
Print Post  

Hi Stoyan,

For some reason i get this error.

Error      1      'MindFusionDemo2.MainWindow' does not contain a definition for 'UndoCmdExecuted' and no extension method 'UndoCmdExecuted' accepting a first argument of type 'MindFusionDemo2.MainWindow' could be found (are you missing a using directive or an assembly reference?)      

Greets,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo Redo, Ctrl-z, Ctrl-Y
Reply #3 - Oct 7th, 2013 at 12:11pm
Print Post  
Hi,

From the snippet above, copy the <window...> code to your window's Xaml file, and the private void UndoCmdExecuted ... code to the window's code-behind .cs file.

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


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Undo Redo, Ctrl-z, Ctrl-Y
Reply #4 - Oct 7th, 2013 at 12:27pm
Print Post  

Hi there,

Ah, i was under the impression i had to place in my diagram class. Is this a .NET framework basic function or something?

It works like a charm.

Greets,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo Redo, Ctrl-z, Ctrl-Y
Reply #5 - Oct 7th, 2013 at 12:36pm
Print Post  
Hi,

Yes, WPF provides some predefined commands with standard key bindings associated with them:
http://msdn.microsoft.com/en-us/library/system.windows.input.applicationcommands...

Apart from the keyboard shortcut, you can also add menu items or toolbar buttons whose Command property is set to one of them.

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