Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) How to select all the nodes on ctrl+A (Read 7985 times)
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
How to select all the nodes on ctrl+A
Mar 31st, 2009 at 12:34pm
Print Post  
Hi,

How can we have all the diagram items selected on  Ctrl+A key press.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to select all the nodes on ctrl+A
Reply #1 - Mar 31st, 2009 at 3:00pm
Print Post  
Set DiagramItem.Selected = true for each item in Diagram.Items.

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


I love YaBB 1G - SP1!

Posts: 28
Joined: Mar 7th, 2009
Re: How to select all the nodes on ctrl+A
Reply #2 - Mar 31st, 2009 at 8:20pm
Print Post  
I was just going to post on something similar - I get an ArgumentNullException when I do Ctrl-C with at least one node selected on my diagram, even if I am not capturing key events:

[Truncated Stack Trace]
"   at System.Collections.CollectionBase.OnValidate(Object value)\r\n   at System.Collections.CollectionBase.System.Collections.IList.set_Item(Int32 index, Object value)\r\n   at MindFusion.Diagramming.Wpf.DiagramItemCollection.set_Item(Int32 index, DiagramItem value)\r\n   at MindFusion.Diagramming.Wpf.Diagram.CopySelection(Diagram source, Boolean unconnectedLinks, Boolean copyGroups)\r\n   at MindFusion.Diagramming.Wpf.Diagram.CopyToClipboard(Boolean persist, Boolean groups)\r\n   at MindFusion.Diagramming.Wpf.Diagram.xf89f70209334cdd5(Object xe0292b9ed559da7d, ExecutedRoutedEventArgs xce8d8c7e3c2c2426)\r\n   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)\r\n   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)\r\n   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)\r\n   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)\r\n   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)\r\n   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)\r\n   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)\r\n   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)\r\n   at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)\r\n   at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)\r\n   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)\r\n   at System.Windows.Input.InputManager.ProcessStagingArea()\r\n   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)\r\n   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)\r\n   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)\r\n   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)\r\n   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)\r\n   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)\r\n   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)\r\n   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)\r\n   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)\r\n   at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage
(MSG& msg, Boolean& handled)\r\n   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)\r\n   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\r\n   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\r\n
  
Back to top
 
IP Logged
 
sydneyos
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 28
Joined: Mar 7th, 2009
Re: How to select all the nodes on ctrl+A
Reply #3 - Mar 31st, 2009 at 8:29pm
Print Post  
Also, when I do try to capture Mouse Events, I can only ever get the Ctrl Key and it is not considered a System Key, it's just the e.Key property is LeftCtrl - how can I get Ctrl-C?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to select all the nodes on ctrl+A
Reply #4 - Apr 1st, 2009 at 8:24am
Print Post  
Copy to clipboard won't work if you are using a custom node type that does not override the Clone method nor implements a copy constructor. The control automatically binds the ApplicationCommands.Copy command to the Diagram.CopyToClipboard() method. You could replace it with your own binding if you want to stop Ctrl+C.

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


I love YaBB 1G - SP1!

Posts: 28
Joined: Mar 7th, 2009
Re: How to select all the nodes on ctrl+A
Reply #5 - Apr 1st, 2009 at 2:02pm
Print Post  
Can you say more?  What would be the steps/code to replace the binding?  What does a Copy constructor look like?
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: How to select all the nodes on ctrl+A
Reply #6 - Apr 2nd, 2009 at 9:01am
Print Post  
To select all diagram elements in you suggested to have:
Set DiagramItem.Selected = true for each item in Diagram.Items.

i tried it on keydown event like this:
diagram.AddHandler(Diagram.KeyDownEvent, new KeyEventHandler(diagram_KeyDown),true);

Code
Select All
void diagram_KeyDown(object sender, KeyEventArgs e)
	  {
		if (flag && (e.Key == System.Windows.Input.Key.A))
		{
		    flag = false;
		    foreach (DiagramItem item in diagram.Items)
		    {
			  item.Selected = true;
		    }
		}
		if (e.Key == System.Windows.Input.Key.LeftCtrl)
		{
		    flag = true;
		}
	  }
 



but the problem i m facing is that the event is firing only when u press tab to get diagram in focus but when u click on diagram or select a diagram element and then press ctrl + A key the event do not fire.

How to solve this issue?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to select all the nodes on ctrl+A
Reply #7 - Apr 2nd, 2009 at 9:52am
Print Post  
You could call Diagram.Focus from the MouseDown event handler.

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


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: How to select all the nodes on ctrl+A
Reply #8 - Apr 2nd, 2009 at 10:42am
Print Post  
Thanks for the reply, I tried this but its not working.

Any other suggestion.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to select all the nodes on ctrl+A
Reply #9 - Apr 2nd, 2009 at 2:33pm
Print Post  
Isn't the event raised, or it is raised but the nodes are not selected?
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: How to select all the nodes on ctrl+A
Reply #10 - Apr 3rd, 2009 at 6:13am
Print Post  
Hi,

The event not raised at all. when we just click inside the diagram and press any key, the key down event is not getting raised at all.

but when we are coming to the diagram by tab and pressing any key, the keydown event is being raised.

Thanks for your concern.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to select all the nodes on ctrl+A
Reply #11 - Apr 3rd, 2009 at 8:16am
Print Post  
Are you creating a browser application? I think the Focus method is not allowed when running in a browser.
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: How to select all the nodes on ctrl+A
Reply #12 - Apr 3rd, 2009 at 8:19am
Print Post  
No it is a standard WPF application.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to select all the nodes on ctrl+A
Reply #13 - Apr 3rd, 2009 at 8:31am
Print Post  
Check if diagram.Focus() returns false, and take a look at the UIElement.Focus topic in the MSDN library to see in what cases the method returns false.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint