protected virtual void OnMotion(MotionEventArgs args)
 {
     if (Motion != null)
     {
         Motion(this, args);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Called in WndPrc to process the Window Messages
        /// </summary>
        /// <param name="msg">Message Number</param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        public void ProcessWindowMessage(int msg, IntPtr wParam, IntPtr lParam)
        {
            if (this.IsDisposed) //We don't throw an Exception in the Message Loop, just return
            {
                return;
            }

            SiApp.SiGetEventData evd = default(SiApp.SiGetEventData);
            SiApp.SiGetEventWinInit(ref evd, msg, wParam, lParam);
            SiApp.SiSpwEvent_SpwData edata = default(SiApp.SiSpwEvent_SpwData);
            var t = SiApp.SiGetEvent(_deviceHandle, SiApp.SI_AVERAGE_EVENTS, ref evd, ref edata);

            if (t == SiApp.SpwRetVal.SI_IS_EVENT)
            {
                switch (edata.type)
                {
                case SiApp.SiEventType.SI_ZERO_EVENT:
                    lock (eventBuffer)
                    {
                        eventBuffer[SiApp.SiEventType.SI_ZERO_EVENT] = EventArgs.Empty;
                        Monitor.Pulse(eventBuffer);
                    }
                    break;

                case SiApp.SiEventType.SI_MOTION_EVENT:
                    lock (eventBuffer)
                    {
                        eventBuffer[SiApp.SiEventType.SI_MOTION_EVENT] = MotionEventArgs.FromEventArray(edata.spwData.mData);
                        Monitor.Pulse(eventBuffer);
                    }
                    break;
                }
            }
        }