Link preventing showed by a stop sign


#1

I’d like to know if there’s any possibility to change the mouse cursor to one of a kind with no hotspot while the user tries to create a prohibited link.
How could I achieve this?


#2

Ok figured out how to do this. Easy. :-)


#3

Can you share with Us how you did this?

thanks
DA


#4

It’s easy to get this done.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

You need to do the changes in your RelationshipTool class.

I’ve just taken it from the FlowCharter sample.

I’ve manipulated the constructor, so the class itself could change the cursor whether if the action is allowed or not.

private GoView view = null;

public RelationshipTool(GoView _view) : base(_view)

{

view = _view; //we need to do this to be able to //change the cursor by GoView.Cursor = …

}

public override void Start()

{

//view.Cursor = Cursors.No; //You might apply this in the First line //if you want a “prohibited sign” at the //very beginning

[…]

}

We’ve already done half the job now.

Let’s change FindNearestPort:

Public GoPort FindNearestPort()

{

GraphNode gnFrom = (this.Predecessor.BottomPort.Node as GraphNode);

GraphNode gnTo = gn;

//this is just an example to create a rule,

//this is the place where you should ask for your own rules.

//if no collection is allowed at the current point you will not

//be able to draw a connection here.

//might be something here like:

//if (!view.ViewDefinition.RuleIsValid(gnFrom,gnTo)

if ((gnTo.Text.StartsWith("Node1")))

{

//hier Regel überprüfen...

view.Cursor = Cursors.No;

if (view.Cursor == Cursors.No)

{

return null;

}

}

view.Cursor = Cursors.Default;

[…]

}


#5
You have to provide the view now to the RelationshipTool. view.Tool = new RelationshipTool(view); To try the example above you have to create at least one node containing the text "Node1".

#6

You shouldn’t need to keep a copy of the view in your own field, when it is already available to you by means of the GoTool.View property.


#7

Looks Good will try it.
Thanks
DA


#8

Walter is right. Didn’t see it at first.
You don’t need to apply GoView because it’s already available by
GoTool.View