private void ThingBeforeMovedEventHandler(object s, Point2DEventArgs e) { var thing = (ISpatial2DThing <T>)s; if (e.Points.Any(p => !Overlaps(p))) { throw new ObjectOutOfBoundsException(thing); } if (!AllowOverlapping && _items.Values.Any(m => m.Any(x => !x.Equals(thing) && x.Overlaps(e.Points)))) { throw new InvalidOperationException("Item overlaps existing item"); } var violations = _movementRules.Values.Where(r => r.Condition(thing, e.Points)).ToList(); var ev = RuleViolated; foreach (var rule in violations) { e.Abort = true; if (ev == null) { return; // No event listener } ev(this, new RuleViolationEvent(rule, thing)); } }
private void ThingMovedEventHandler(object s, Point2DEventArgs e) { RemoveObject((ISpatial2DThing <T>)s); SetObject((ISpatial2DThing <T>)s, false, false); FireItemMoved((ISpatial2DThing <T>)s); }