////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Throws an exception if callback_I is null.
 /// </summary>
 /// <param name="callback_I">callback function used by MTAPI to send touch data</param>
 protected void ThrowIfInvalidCallback(ref WacomMTCallback callback_I)
 {
     if (callback_I == null)
     {
         throw new Exception("Oops - null callback");
     }
 }
        ////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Registers an MTAPI raw data client over the entire tablet surface
        /// (no hitrect or HWND required).
        /// </summary>
        /// <param name="deviceID_I">touch device identifier</param>
        /// <param name="callback_I">callback function used by MTAPI to send touch data</param>
        /// <param name="userData_I">custom user data</param>
        public void RegisterClient(Int32 deviceID_I,
                                   ref WacomMTCallback callback_I, IntPtr userData_I)
        {
            try
            {
                InitWacomMTClientParams(deviceID_I, ref callback_I, userData_I);

                WacomMTError res = CWacomMTInterface.WacomMTRegisterRawReadCallback(
                    mDeviceID, mClientMode, mTouchCallback, mUserData);

                if (WacomMTError.WMTErrorSuccess != res)
                {
                    String errMsg = "Oops - failed WacomMTRegisterRawReadCallback with error: " + res.ToString();
                    throw new Exception(errMsg);
                }

#if TRACE_CLIENT
                DumpClient("RegisterClient");
#endif //TRACE_CLIENT
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 ////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Initalize MTAPI client parameters
 /// </summary>
 /// <param name="deviceID_I">touch device identifier</param>
 /// <param name="callback_I">callback function used by MTAPI to send touch data</param>
 /// <param name="userData_I">custom user data</param>
 protected void InitWacomMTClientParams(Int32 deviceID_I, ref WacomMTCallback callback_I, IntPtr userData_I)
 {
     ThrowIfInvalidDeviceID(deviceID_I);
     mDeviceID = deviceID_I;
     ThrowIfInvalidCallback(ref callback_I);
     mTouchCallback = callback_I;
     mUserData      = userData_I;
 }
        ////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Sets/verifies MTAPI hitrect client params.
        /// </summary>
        /// <param name="deviceID_I">touch device identifier</param>
        /// <param name="hitrect_I">rectangle tracked by MTAPI for touch contacts</param>
        /// <param name="callback_I">callback function used by MTAPI to send touch data</param>
        /// <param name="userData_I">custom user data</param>s
        protected void InitWacomMTHitRectClientParams(Int32 deviceID_I,
                                                      WacomMTHitRect hitrect_I, ref WacomMTCallback callback_I, IntPtr userData_I)
        {
            InitWacomMTClientParams(deviceID_I, ref callback_I, userData_I);

            ThrowIfInvalidHitRect(ref hitrect_I);
            mHitRect = hitrect_I;
        }
Example #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            WacomMTError status = WacomMTError.WMTErrorSuccess;

            IntPtr userDataBuf = IntPtr.Zero;

            try
            {
                mWacomMTConfig.Init();

                //Delegate called when events come to tablet
                mUpdateRealTimeLabel  = new UpdateDelegate(this.DoUpdateGraphicsControl);
                mUpdateRealTimeLabel += this.DoSendMidiMessage;

                // crée un nouveau callback attach et abonne a ce callback
                mAttachCallback = new WacomMTAttachCallback(this.DoAttachWindowClientCallback);
                status          = CWacomMTInterface.WacomMTRegisterAttachCallback(this.mAttachCallback, IntPtr.Zero);

                if (status != WacomMTError.WMTErrorSuccess)
                {
                    throw new Exception("Failed to register for device attaches - err: " + status.ToString());
                }

                // crée un nouveau callback detack et abonne a ce callback
                mDetachCallback = new WacomMTDetachCallback(this.DoDetachWindowClientCallback);
                status          = CWacomMTInterface.WacomMTRegisterDetachCallback(this.mDetachCallback, IntPtr.Zero);

                if (status != WacomMTError.WMTErrorSuccess)
                {
                    throw new Exception("Failed to register for device detaches - err: " + status.ToString());
                }

                //crée un nouveau callback de type Finger Read et abonne a celui-ci
                WacomMTHitRect HR = new WacomMTHitRect(0, 0, 0, 0);
                mTouchDataCallback = new WacomMTCallback(this.DoFingerDataUpdateCallback);
                status             = CWacomMTInterface.WacomMTRegisterFingerReadCallback(0, ref HR, _processingMode,
                                                                                         mTouchDataCallback, IntPtr.Zero);

                UpdateLabelText();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.ToString());
            }
        }
        // -------------------------------------------------------------------------
        // HitRect methods
        // -------------------------------------------------------------------------

        ////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Registers an MTAPI windowed client using a hitrect.
        /// </summary>
        /// <param name="deviceID_I">touch device identifier</param>
        /// <param name="hitrect_I">rectangle tracked by MTAPI for touch contacts</param>
        /// <param name="callback_I">callback function used by MTAPI to send touch data</param>
        /// <param name="userData_I">custom user data</param>
        public void RegisterHitRectClient(Int32 deviceID_I, WacomMTHitRect hitrect_I,
                                          ref WacomMTCallback callback_I, IntPtr userData_I)
        {
            try
            {
                InitWacomMTHitRectClientParams(deviceID_I, hitrect_I, ref callback_I, userData_I);

                WacomMTError res = DoRegisterHitRectCallback();

                if (WacomMTError.WMTErrorSuccess != res)
                {
                    String errMsg = "Oops - failed DoRegisterHitRectCallback with error: " + res.ToString();
                    throw new Exception(errMsg);
                }

#if TRACE_CLIENT
                DumpClient("RegisterHitRectClient");
#endif //TRACE_CLIENT
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            WacomMTError status = WacomMTError.WMTErrorSuccess;

            IntPtr userDataBuf = IntPtr.Zero;
            try
            {
                mWacomMTConfig.Init();

                //Delegate called when events come to tablet
                mUpdateRealTimeLabel = new UpdateDelegate(this.DoUpdateGraphicsControl);
                mUpdateRealTimeLabel += this.DoSendMidiMessage;

                // crée un nouveau callback attach et abonne a ce callback
                mAttachCallback = new WacomMTAttachCallback(this.DoAttachWindowClientCallback);
                status = CWacomMTInterface.WacomMTRegisterAttachCallback(this.mAttachCallback, IntPtr.Zero);

                if (status != WacomMTError.WMTErrorSuccess)
                {
                    throw new Exception("Failed to register for device attaches - err: " + status.ToString());
                }

                // crée un nouveau callback detack et abonne a ce callback
                mDetachCallback = new WacomMTDetachCallback(this.DoDetachWindowClientCallback);
                status = CWacomMTInterface.WacomMTRegisterDetachCallback(this.mDetachCallback, IntPtr.Zero);

                if (status != WacomMTError.WMTErrorSuccess)
                {
                    throw new Exception("Failed to register for device detaches - err: " + status.ToString());
                }

                //crée un nouveau callback de type Finger Read et abonne a celui-ci
                WacomMTHitRect HR = new WacomMTHitRect(0, 0, 0, 0);
                mTouchDataCallback = new WacomMTCallback(this.DoFingerDataUpdateCallback);
                status = CWacomMTInterface.WacomMTRegisterFingerReadCallback(0, ref HR, _processingMode,
                    mTouchDataCallback, IntPtr.Zero);

                UpdateLabelText();

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.ToString());
            }

        }
 ////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Clears MTAPI client parameters
 /// </summary>
 protected void ClearWacomMTClientParams()
 {
     mDeviceID      = -1;
     mTouchCallback = null;
     mUserData      = IntPtr.Zero;
 }