Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Diagram.CommandBindings (Read 7703 times)
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Diagram.CommandBindings
Jul 16th, 2008 at 9:45pm
Print Post  
How can I do Diagram.CommandBindings
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #1 - Jul 17th, 2008 at 8:57am
Print Post  
The Diagram object automatically registers the following command bindings:

ApplicationCommands.Delete
ApplicationCommands.Cut
ApplicationCommands.Copy
ApplicationCommands.Paste
Diagram.NavigateLeft
Diagram.NavigateRight
Diagram.NavigateUp
Diagram.NavigateDown

Just assign to the Command property of your UI elements one of the listed commands.

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



Posts: 37
Joined: Jan 18th, 2008
Re: Diagram.CommandBindings
Reply #2 - Jul 17th, 2008 at 3:25pm
Print Post  
I have custom slider control with custom command and I am trying to bind DIagram as the target of the slider.
So I am trying to put Excecute command to Diagram.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #3 - Jul 17th, 2008 at 3:58pm
Print Post  
I don't know why you'd need command binding in that case. You could bind the slider's Value with some dependency property of the Diagram, but there aren't any bindable properties in version 1.0. We have made ZoomFactor bindable in v1.0.1, and I can send you our daily build if ZoomFactor is what you need to bind to.

Stoyan
  
Back to top
 
IP Logged
 
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Re: Diagram.CommandBindings
Reply #4 - Jul 17th, 2008 at 5:44pm
Print Post  
That would be great.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #5 - Jul 18th, 2008 at 9:24am
Print Post  
You can find the download link on the private messages page.

In this version we have changed the MeasureUnit default value - now it is WpfPoint - and all size related default property values, such as TableCaptionHeight, LinkHeadSize, etc. You might have to adjust some of these properties depending on what MeasureUnit you are using.

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


I <3 MindFusion

Posts: 32
Location: CA
Joined: Dec 10th, 2008
Re: Diagram.CommandBindings
Reply #6 - Jan 6th, 2009 at 5:27am
Print Post  
What would be the best way to override these bindings? I need to implement my own copy and paste commands, but when I try to override the binding by just creating a new one:

[code]
myDiagram.CommandBindings.Clear();
myDiagram.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, Copy_Executed));
[/code]

The copy and paste operations still use the default commands.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #7 - Jan 6th, 2009 at 9:40am
Print Post  
This worked fine for me; CTRL+C calls Copy_Executed after running that code. If you have more than one Diagram object, check whether you are adding the binding to the correct diagram.

Stoyan
  
Back to top
 
IP Logged
 
benm
YaBB Newbies
*
Offline


I <3 MindFusion

Posts: 32
Location: CA
Joined: Dec 10th, 2008
Re: Diagram.CommandBindings
Reply #8 - Jan 6th, 2009 at 9:58am
Print Post  
Thanks for checking on that. I see now that it does work, however in the mean time I would like to disable the binding all together, which is where the strange behavior was coming from I guess.

I tried:

[code]
myDiagram.CommandBindings.Clear();
myDiagram.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, Copy_Executed, CanExecute_False));[/code]

Where CanExecute_False always returns false. I also just tried:

[code]
myDiagram.CommandBindings.Clear();[/code]

But in either case, the "Copy" option on the menu is always enabled when the diagram control is focused. Is there another way to clear the bindings altogether?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #9 - Jan 6th, 2009 at 2:36pm
Print Post  
In the CanExecuteRoutedEventHandler set

e.CanExecute = false;
e.Handled = true;

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


I <3 MindFusion

Posts: 32
Location: CA
Joined: Dec 10th, 2008
Re: Diagram.CommandBindings
Reply #10 - Jan 6th, 2009 at 10:05pm
Print Post  
e.Handled = true;

Is what I was missing.  Thank you!
  
Back to top
WWW  
IP Logged
 
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Re: Diagram.CommandBindings
Reply #11 - Mar 16th, 2009 at 11:53am
Print Post  
Hi,

I tried following code for binding "Ctrl+C" command

Code
Select All
diagram.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy,new ExecutedRoutedEventHandler(copy_Executed),
                new CanExecuteRoutedEventHandler(CanExecute_False)));  



but when I pressed "Ctrl+C" nothing is happened (copy_Executed is not executing) whereas when I select "Copy" option from the context menu "copy_Executed" function is executed.

I dont know what I am missing, how can "copy_Executed" function be binded with "Ctrl+C" (shortcut of Copy ) command?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #12 - Mar 16th, 2009 at 12:52pm
Print Post  
Hi,

If your CanExecute_False method always returns false, Ctrl+C will never work. Remove this argument and Ctrl+C should work as long as the keyboard focus is on the diagram.

I hope that helps,
Stoyan

  
Back to top
 
IP Logged
 
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Re: Diagram.CommandBindings
Reply #13 - Mar 16th, 2009 at 2:08pm
Print Post  
Thanks for your reply...

I tried that one but still its not working. For tracing further I debug it by inserting break point to both functions (copy_Executed and CanExecute_False ) but it never came in that function on pressing "Ctrl+C".

And CanExecute_False method has void return type.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.CommandBindings
Reply #14 - Mar 16th, 2009 at 2:31pm
Print Post  
The keyboard focus might not be on the diagram. If you add the binding to the root panel, Ctrl+C should work even if the focus is on another control. Otherwise, you must TAB a few times to bring the focus to the diagram, or call the Diagram.Focus() mthod, e.g. in response to a MouseDown event.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint