/Main/src/DynamicDataDisplay/ViewportConstraints/ViewportConstraint.cs

# · C# · 37 lines · 18 code · 2 blank · 17 comment · 0 complexity · 3c1b77fe58c6a01d5a3ed0e1249dece4 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using Microsoft.Research.DynamicDataDisplay.Common;
  7. namespace Microsoft.Research.DynamicDataDisplay.ViewportConstraints
  8. {
  9. /// <summary>
  10. /// Represents a base class for all constraints that are being applied to viewport's visible rect.
  11. /// </summary>
  12. public abstract class ViewportConstraint
  13. {
  14. /// <summary>
  15. /// Applies the constraint.
  16. /// </summary>
  17. /// <param name="previousDataRect">Previous data rectangle.</param>
  18. /// <param name="proposedDataRect">Proposed data rectangle.</param>
  19. /// <param name="viewport">The viewport, to which current restriction is being applied.</param>
  20. /// <returns>New changed visible rectangle.</returns>
  21. public abstract DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport);
  22. /// <summary>
  23. /// Raises the changed event.
  24. /// </summary>
  25. protected void RaiseChanged()
  26. {
  27. Changed.Raise(this);
  28. }
  29. /// <summary>
  30. /// Occurs when constraint changes.
  31. /// Causes update of <see cref="Viewport"/>'s Visible property.
  32. /// </summary>
  33. public event EventHandler Changed;
  34. }
  35. }