ManipulationEventSink.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #pragma once
  2. #include <ole2.h>
  3. #include <ocidl.h>
  4. #include <manipulations.h>
  5. namespace ManipulationHelper
  6. {
  7. /// <summary>
  8. /// _IManipulationEvents的ManipulationStarted接口回调函数类型
  9. /// <param name="X">x coordiante of the initial point of manipulation(1/100 of pixel)</param>
  10. /// <param name="Y">y coordiante of the initial point of manipulation(1/100 of pixel)</param>
  11. /// </summary>
  12. typedef void (*ManipulationStartedCallBack)(
  13. FLOAT x,
  14. FLOAT y);
  15. /// <summary>
  16. /// _IManipulationEvents的ManipulationDelta接口回调函数类型
  17. /// <param name="X">x coordiante of the initial point of manipulation(1/100 of pixel)</param>
  18. /// <param name="Y">y coordiante of the initial point of manipulation(1/100 of pixel)</param>
  19. /// <param name="translationDeltaX">shift of the x-coordinate (1/100 of pixel)</param>
  20. /// <param name="translationDeltaY">shift of the y-coordinate (1/100 of pixel)</param>
  21. /// <param name="scaleDelta">scale factor (zoom in/out)</param>
  22. /// <param name="expansionDelta">the current rate of scale change</param>
  23. /// <param name="rotationDelta">rotation angle in radians</param>
  24. /// <param name="cumulativeTranslationX">cumulative shift of x-coordinate (1/100 of pixel)</param>
  25. /// <param name="cumulativeTranslationY">cumulative shift of y-coordinate (1/100 of pixel)</param>
  26. /// <param name="cumulativeScale">cumulative scale factor (zoom in/out)</param>
  27. /// <param name="cumulativeExpansion">cumulative rate of scale change</param>
  28. /// <param name="cumulativeRotation">cumulative rotation angle in radians</param>
  29. /// </summary>
  30. typedef void (*ManipulationDeltaCallBack)(
  31. FLOAT x,
  32. FLOAT y,
  33. FLOAT translationDeltaX,
  34. FLOAT translationDeltaY,
  35. FLOAT scaleDelta,
  36. FLOAT expansionDelta,
  37. FLOAT rotationDelta,
  38. FLOAT cumulativeTranslationX,
  39. FLOAT cumulativeTranslationY,
  40. FLOAT cumulativeScale,
  41. FLOAT cumulativeExpansion,
  42. FLOAT cumulativeRotation);
  43. /// <summary>
  44. /// _IManipulationEvents的ManipulationCompleted接口回调函数类型
  45. /// <param name="X">x coordiante of the initial point of manipulation(1/100 of pixel)</param>
  46. /// <param name="Y">y coordiante of the initial point of manipulation(1/100 of pixel)</param>
  47. /// <param name="cumulativeTranslationX">cumulative shift of x-coordinate (1/100 of pixel)</param>
  48. /// <param name="cumulativeTranslationY">cumulative shift of y-coordinate (1/100 of pixel)</param>
  49. /// <param name="cumulativeScale">cumulative scale factor (zoom in/out)</param>
  50. /// <param name="cumulativeExpansion">cumulative rate of scale change</param>
  51. /// <param name="cumulativeRotation">cumulative rotation angle in radians</param>
  52. /// </summary>
  53. typedef void (*ManipulationCompletedCallBack)(
  54. FLOAT x,
  55. FLOAT y,
  56. FLOAT cumulativeTranslationX,
  57. FLOAT cumulativeTranslationY,
  58. FLOAT cumulativeScale,
  59. FLOAT cumulativeExpansion,
  60. FLOAT cumulativeRotation);
  61. class ManipulationEventSink : public _IManipulationEvents
  62. {
  63. public:
  64. ManipulationEventSink();
  65. virtual ~ManipulationEventSink();
  66. /// <summary>
  67. /// 连接到一个IManipulationProcessor上(参考微软例程)
  68. /// </summary>
  69. /// <param name="pManipProc">IManipulationProcessor实例</param>
  70. /// <returns></returns>
  71. bool Connect(IManipulationProcessor* pManipProc);
  72. bool Disconnect();
  73. /// <summary>
  74. /// 设置ManipulationStarted方法的回调函数
  75. /// </summary>
  76. /// <param name="">ManipulationStartedCallBack的函数指针</param>
  77. void SetManipulationStartedCallBack(ManipulationStartedCallBack);
  78. /// <summary>
  79. /// 设置ManipulationDelta方法的回调函数
  80. /// </summary>
  81. /// <param name="">ManipulationDeltaCallBack的函数指针</param>
  82. void SetManipulationDeltaCallBack(ManipulationDeltaCallBack);
  83. /// <summary>
  84. /// 设置ManipulationCompleted方法的回调函数
  85. /// </summary>
  86. /// <param name="">ManipulationCompletedCallBack的函数指针</param>
  87. void SetManipulationCompletedCallBack(ManipulationCompletedCallBack);
  88. // _IManipulationEvents需要实现的方法(这些方法会被回调)
  89. virtual HRESULT STDMETHODCALLTYPE ManipulationStarted(
  90. FLOAT x,
  91. FLOAT y);
  92. virtual HRESULT STDMETHODCALLTYPE ManipulationDelta(
  93. FLOAT x,
  94. FLOAT y,
  95. FLOAT translationDeltaX,
  96. FLOAT translationDeltaY,
  97. FLOAT scaleDelta,
  98. FLOAT expansionDelta,
  99. FLOAT rotationDelta,
  100. FLOAT cumulativeTranslationX,
  101. FLOAT cumulativeTranslationY,
  102. FLOAT cumulativeScale,
  103. FLOAT cumulativeExpansion,
  104. FLOAT cumulativeRotation);
  105. virtual HRESULT STDMETHODCALLTYPE ManipulationCompleted(
  106. FLOAT x,
  107. FLOAT y,
  108. FLOAT cumulativeTranslationX,
  109. FLOAT cumulativeTranslationY,
  110. FLOAT cumulativeScale,
  111. FLOAT cumulativeExpansion,
  112. FLOAT cumulativeRotation);
  113. // IUnknown methods
  114. STDMETHOD_(ULONG, AddRef)(void);
  115. STDMETHOD_(ULONG, Release)(void);
  116. STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppvObj);
  117. private:
  118. // Reference count of the COM object.
  119. LONG m_cRefCount;
  120. // The IConnectionPoint interface supports connection points for
  121. // connectable objects.
  122. IConnectionPoint* m_pConnection;
  123. // Cookie of the connection.
  124. DWORD m_dwCookie;
  125. //COM的IManipulationProcessor实例
  126. IManipulationProcessor* m_pIManipProc;
  127. //ManipulationStarted方法的回调函数
  128. ManipulationStartedCallBack m_mStartedCallBack = NULL;
  129. ////ManipulationDelta方法的回调函数
  130. ManipulationDeltaCallBack m_mDeltaCallBack = NULL;
  131. //ManipulationCompleted方法的回调函数
  132. ManipulationCompletedCallBack m_mCompletedCallBack = NULL;
  133. };
  134. }