/common/src/core/Utils/IO/TouchNotification.cs

https://github.com/matiasw/vvvv-sdk
C# | 101 lines | 87 code | 14 blank | 0 comment | 3 complexity | 9388ce135f29034627b111886925e785 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. namespace VVVV.Utils.IO
  7. {
  8. public enum TouchNotificationKind
  9. {
  10. TouchDown,
  11. TouchUp,
  12. TouchMove
  13. }
  14. public class TouchNotification : Notification
  15. {
  16. public readonly TouchNotificationKind Kind;
  17. public readonly Point Position;
  18. public readonly Size ClientArea;
  19. public readonly int Id;
  20. public readonly bool Primary;
  21. public readonly Size ContactArea;
  22. public readonly long TouchDeviceID;
  23. public TouchNotification(TouchNotificationKind kind, Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID)
  24. {
  25. Kind = kind;
  26. Position = position;
  27. ClientArea = clientArea;
  28. Id = id;
  29. Primary = primary;
  30. ContactArea = contactArea;
  31. TouchDeviceID = touchDeviceID;
  32. }
  33. public TouchNotification(TouchNotificationKind kind, Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID, object sender)
  34. : base(sender)
  35. {
  36. Kind = kind;
  37. Position = position;
  38. ClientArea = clientArea;
  39. Id = id;
  40. Primary = primary;
  41. ContactArea = contactArea;
  42. TouchDeviceID = touchDeviceID;
  43. }
  44. public bool IsTouchDown { get { return Kind == TouchNotificationKind.TouchDown; } }
  45. public bool IsTouchUp { get { return Kind == TouchNotificationKind.TouchUp; } }
  46. public bool IsTouchMove { get { return Kind == TouchNotificationKind.TouchMove; } }
  47. }
  48. public class TouchDownNotification : TouchNotification
  49. {
  50. public TouchDownNotification(Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID)
  51. : base(TouchNotificationKind.TouchDown, position, clientArea, id, primary, contactArea, touchDeviceID)
  52. {
  53. }
  54. public TouchDownNotification(Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID, object sender)
  55. : base(TouchNotificationKind.TouchDown, position, clientArea, id, primary, contactArea, touchDeviceID, sender)
  56. {
  57. }
  58. public override INotification WithSender(object sender)
  59. => new TouchDownNotification(Position, ClientArea, Id, Primary, ContactArea, TouchDeviceID, sender);
  60. }
  61. public class TouchMoveNotification : TouchNotification
  62. {
  63. public TouchMoveNotification(Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID)
  64. : base(TouchNotificationKind.TouchMove, position, clientArea, id, primary, contactArea, touchDeviceID)
  65. {
  66. }
  67. public TouchMoveNotification(Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID, object sender)
  68. : base(TouchNotificationKind.TouchMove, position, clientArea, id, primary, contactArea, touchDeviceID, sender)
  69. {
  70. }
  71. public override INotification WithSender(object sender)
  72. => new TouchMoveNotification(Position, ClientArea, Id, Primary, ContactArea, TouchDeviceID, sender);
  73. }
  74. public class TouchUpNotification : TouchNotification
  75. {
  76. public TouchUpNotification(Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID)
  77. : base(TouchNotificationKind.TouchUp, position, clientArea, id, primary, contactArea, touchDeviceID)
  78. {
  79. }
  80. public TouchUpNotification(Point position, Size clientArea, int id, bool primary, Size contactArea, long touchDeviceID, object sender)
  81. : base(TouchNotificationKind.TouchUp, position, clientArea, id, primary, contactArea, touchDeviceID, sender)
  82. {
  83. }
  84. public override INotification WithSender(object sender)
  85. => new TouchUpNotification(Position, ClientArea, Id, Primary, ContactArea, TouchDeviceID, sender);
  86. }
  87. }