SnapObstacleController.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Drawing;
  2. namespace PaintDotNet
  3. {
  4. public sealed class SnapObstacleController
  5. : SnapObstacle
  6. {
  7. /// <summary>
  8. /// Used for the obstacle to report changes in the obstacles size and/or location.
  9. /// </summary>
  10. public void SetBounds(Rectangle bounds)
  11. {
  12. if (this.bounds != bounds)
  13. {
  14. OnBoundsChanging();
  15. this.previousBounds = this.bounds;
  16. this.bounds = bounds;
  17. OnBoundsChanged();
  18. }
  19. }
  20. /// <summary>
  21. /// Raised when the SnapManager is requesting that the obstacle move and/or resize itself.
  22. /// Usually this happens in response to another snap container with "sticky edges" changing
  23. /// its boundary.
  24. /// </summary>
  25. public event HandledEventHandler<Rectangle> BoundsChangeRequested;
  26. protected override void OnBoundsChangeRequested(Rectangle newBounds, ref bool handled)
  27. {
  28. if (BoundsChangeRequested != null)
  29. {
  30. HandledEventArgs<Rectangle> e = new HandledEventArgs<Rectangle>(handled, newBounds);
  31. BoundsChangeRequested(this, e);
  32. handled = e.Handled;
  33. }
  34. base.OnBoundsChangeRequested(newBounds, ref handled);
  35. }
  36. public SnapObstacleController(string name, Rectangle bounds, SnapRegion snapRegion, bool stickyEdges)
  37. : base(name, bounds, snapRegion, stickyEdges)
  38. {
  39. }
  40. public SnapObstacleController(string name, Rectangle bounds, SnapRegion snapRegion, bool stickyEdges, int snapProximity, int snapDistance)
  41. : base(name, bounds, snapRegion, stickyEdges, snapProximity, snapDistance)
  42. {
  43. }
  44. }
  45. }