1. You may want to expand the logic that determines if the line can dock to the shape it is over. You can do this by overriding the Runtime.CanDock method and providing your own implementation.
In the example below we prevent docking to any element with an Opacity less than 100%:
public class MyRuntime: Runtime
{
public override bool CanDock(Diagram.MouseElements mouseElements)
{
if (mouseElements.MouseMoveElement != null && mouseElements.MouseMoveElement.Opacity < 100) return false;
return base.CanDock(mouseElements);
}
}
2. Then make sure you set the Model.Runtime property to an instance of your runtime class.
model1.Runtime =
new MyRuntime();
3. You need to cancel an action if it is invalid. This can be done simply by clearing the elements involved in the action before it is updated. To do this create a Model subclass and override UpdateElements, clearing the Actions collection.
public class MyModel: Model
{
protected override void UpdateElements()
{
//Clear the list of actions so that they are not updated.
if (CurrentMouseElements.MouseStartOrigin != null && !Runtime.CanDock(CurrentMouseElements)) RenderDesign.Actions.Clear();
//Call the base implementation
base.UpdateElements();
}
}
(Please see the Advanced section of the help file for more information regarding subclassing the Model control)