123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #pragma once
- #include <ole2.h>
- #include <ocidl.h>
- #include <manipulations.h>
- namespace ManipulationHelper
- {
- /// <summary>
- /// _IManipulationEvents的ManipulationStarted接口回调函数类型
- /// <param name="X">x coordiante of the initial point of manipulation(1/100 of pixel)</param>
- /// <param name="Y">y coordiante of the initial point of manipulation(1/100 of pixel)</param>
- /// </summary>
- typedef void (*ManipulationStartedCallBack)(
- FLOAT x,
- FLOAT y);
- /// <summary>
- /// _IManipulationEvents的ManipulationDelta接口回调函数类型
- /// <param name="X">x coordiante of the initial point of manipulation(1/100 of pixel)</param>
- /// <param name="Y">y coordiante of the initial point of manipulation(1/100 of pixel)</param>
- /// <param name="translationDeltaX">shift of the x-coordinate (1/100 of pixel)</param>
- /// <param name="translationDeltaY">shift of the y-coordinate (1/100 of pixel)</param>
- /// <param name="scaleDelta">scale factor (zoom in/out)</param>
- /// <param name="expansionDelta">the current rate of scale change</param>
- /// <param name="rotationDelta">rotation angle in radians</param>
- /// <param name="cumulativeTranslationX">cumulative shift of x-coordinate (1/100 of pixel)</param>
- /// <param name="cumulativeTranslationY">cumulative shift of y-coordinate (1/100 of pixel)</param>
- /// <param name="cumulativeScale">cumulative scale factor (zoom in/out)</param>
- /// <param name="cumulativeExpansion">cumulative rate of scale change</param>
- /// <param name="cumulativeRotation">cumulative rotation angle in radians</param>
- /// </summary>
- typedef void (*ManipulationDeltaCallBack)(
- FLOAT x,
- FLOAT y,
- FLOAT translationDeltaX,
- FLOAT translationDeltaY,
- FLOAT scaleDelta,
- FLOAT expansionDelta,
- FLOAT rotationDelta,
- FLOAT cumulativeTranslationX,
- FLOAT cumulativeTranslationY,
- FLOAT cumulativeScale,
- FLOAT cumulativeExpansion,
- FLOAT cumulativeRotation);
- /// <summary>
- /// _IManipulationEvents的ManipulationCompleted接口回调函数类型
- /// <param name="X">x coordiante of the initial point of manipulation(1/100 of pixel)</param>
- /// <param name="Y">y coordiante of the initial point of manipulation(1/100 of pixel)</param>
- /// <param name="cumulativeTranslationX">cumulative shift of x-coordinate (1/100 of pixel)</param>
- /// <param name="cumulativeTranslationY">cumulative shift of y-coordinate (1/100 of pixel)</param>
- /// <param name="cumulativeScale">cumulative scale factor (zoom in/out)</param>
- /// <param name="cumulativeExpansion">cumulative rate of scale change</param>
- /// <param name="cumulativeRotation">cumulative rotation angle in radians</param>
- /// </summary>
- typedef void (*ManipulationCompletedCallBack)(
- FLOAT x,
- FLOAT y,
- FLOAT cumulativeTranslationX,
- FLOAT cumulativeTranslationY,
- FLOAT cumulativeScale,
- FLOAT cumulativeExpansion,
- FLOAT cumulativeRotation);
- class ManipulationEventSink : public _IManipulationEvents
- {
- public:
- ManipulationEventSink();
- virtual ~ManipulationEventSink();
- /// <summary>
- /// 连接到一个IManipulationProcessor上(参考微软例程)
- /// </summary>
- /// <param name="pManipProc">IManipulationProcessor实例</param>
- /// <returns></returns>
- bool Connect(IManipulationProcessor* pManipProc);
- bool Disconnect();
- /// <summary>
- /// 设置ManipulationStarted方法的回调函数
- /// </summary>
- /// <param name="">ManipulationStartedCallBack的函数指针</param>
- void SetManipulationStartedCallBack(ManipulationStartedCallBack);
- /// <summary>
- /// 设置ManipulationDelta方法的回调函数
- /// </summary>
- /// <param name="">ManipulationDeltaCallBack的函数指针</param>
- void SetManipulationDeltaCallBack(ManipulationDeltaCallBack);
- /// <summary>
- /// 设置ManipulationCompleted方法的回调函数
- /// </summary>
- /// <param name="">ManipulationCompletedCallBack的函数指针</param>
- void SetManipulationCompletedCallBack(ManipulationCompletedCallBack);
- // _IManipulationEvents需要实现的方法(这些方法会被回调)
- virtual HRESULT STDMETHODCALLTYPE ManipulationStarted(
- FLOAT x,
- FLOAT y);
- virtual HRESULT STDMETHODCALLTYPE ManipulationDelta(
- FLOAT x,
- FLOAT y,
- FLOAT translationDeltaX,
- FLOAT translationDeltaY,
- FLOAT scaleDelta,
- FLOAT expansionDelta,
- FLOAT rotationDelta,
- FLOAT cumulativeTranslationX,
- FLOAT cumulativeTranslationY,
- FLOAT cumulativeScale,
- FLOAT cumulativeExpansion,
- FLOAT cumulativeRotation);
- virtual HRESULT STDMETHODCALLTYPE ManipulationCompleted(
- FLOAT x,
- FLOAT y,
- FLOAT cumulativeTranslationX,
- FLOAT cumulativeTranslationY,
- FLOAT cumulativeScale,
- FLOAT cumulativeExpansion,
- FLOAT cumulativeRotation);
- // IUnknown methods
- STDMETHOD_(ULONG, AddRef)(void);
- STDMETHOD_(ULONG, Release)(void);
- STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppvObj);
- private:
- // Reference count of the COM object.
- LONG m_cRefCount;
- // The IConnectionPoint interface supports connection points for
- // connectable objects.
- IConnectionPoint* m_pConnection;
- // Cookie of the connection.
- DWORD m_dwCookie;
- //COM的IManipulationProcessor实例
- IManipulationProcessor* m_pIManipProc;
- //ManipulationStarted方法的回调函数
- ManipulationStartedCallBack m_mStartedCallBack = NULL;
- ////ManipulationDelta方法的回调函数
- ManipulationDeltaCallBack m_mDeltaCallBack = NULL;
- //ManipulationCompleted方法的回调函数
- ManipulationCompletedCallBack m_mCompletedCallBack = NULL;
- };
- }
|