Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Change Mouse Pointer (Read 1684 times)
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Change Mouse Pointer
Aug 12th, 2011 at 12:56pm
Print Post  
Hi
Is there any way to change the mouse pointer of diagram to selection mode & Draw mode ?

[ If Selection Mode then user can only select all node by dragging mouse pointer or selection by clicking on nodes.

If Draw mode then only draw a diagram with default behaviour. ]

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change Mouse Pointer
Reply #1 - Aug 12th, 2011 at 2:28pm
Print Post  
To implement a select-only behavior in the Diagram, follow these steps:

Create a custom behavior class:

Code
Select All
private class SelectBehavior : BehaviorBase
{
      public SelectBehavior(Diagram diagram)
            : base(diagram)
      {
      }

      protected override bool OnMouseDown(MouseButtonEventArgs e)
      {
            return base.OnMouseDown(e);
      }

      public override Cursor SetMouseCursor(Point point, out bool startInteraction)
      {
            startInteraction = false;
            return Cursors.Arrow;
	}

      public override InteractionState StartDraw(Point point)
      {
            return new InteractionState(Diagram.Selection, Action.Create, -1, point);
      }
} 


Assign an instance of this class as behavior of the diagram:

Code
Select All
diagram.CustomBehavior = new SelectBehavior(diagram);
diagram.Behavior = Behavior.Custom; 


Finally handle the SelectionMoving, NodeModifying and LinkModifying events and cancel dragging in each of them:

Code
Select All
e.CancelDrag(); 


Now you can switch back and forth between the default diagram behavior and the newly implemented behavior.

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