public virtual bool DoCollisionDetection(DragableVerticalLabeledLine anotherVerticalLabeledLine, int xStep) { if (anotherVerticalLabeledLine != null && anotherVerticalLabeledLine.Visible) { if (!anotherVerticalLabeledLine.LabelBounds.HasValue || !LabelBounds.HasValue) { return(false); } if (anotherVerticalLabeledLine == this) { return(false); } RectangleF bounds1 = anotherVerticalLabeledLine.Bounds; bounds1.Inflate(-3.5f, 0.0f); RectangleF bounds2 = Bounds; bounds2.Inflate(-3.5f, 0.0f); return(bounds1.IntersectsWith(bounds2)); //return anotherVerticalLabeledLine.Bounds.IntersectsWith(Bounds) //|| anotherVerticalLabeledLine.Bounds.IntersectsWith(LabelBounds.Value) //|| anotherVerticalLabeledLine.LabelBounds.Value.IntersectsWith(Bounds) //|| anotherVerticalLabeledLine.LabelBounds.Value.IntersectsWith(LabelBounds.Value) //; } return(false); }
public override bool DoCollisionDetection(DragableVerticalLabeledLine anotherVerticalLabeledLine, int xStep) { Debug.Assert(anotherVerticalLabeledLine != null); Debug.Assert(xStep != 0); int relation = string.Compare(Label, anotherVerticalLabeledLine.Label); // Do collison detection only when two lines are approaching. if (xStep > 0 && relation < 0 || xStep < 0 && relation > 0) { return(base.DoCollisionDetection(anotherVerticalLabeledLine, xStep)); } return(false); }