Ejemplo n.º 1
0
 public bool PushEvent(BPSEvent ev)
 {
     if (chid == 0)
     {
         throw new ObjectDisposedException("Channel");
     }
     return(BPS.bps_channel_push_event(chid, ev.DangerousGetHandle()) == BPS.BPS_SUCCESS);
 }
Ejemplo n.º 2
0
 public bool PushEvent(BPSEvent ev)
 {
     if (disposed)
     {
         throw new ObjectDisposedException("BPS");
     }
     return(bps_push_event(ev.DangerousGetHandle()) == BPS_SUCCESS);
 }
Ejemplo n.º 3
0
 public static VibrationStatus GetVibrationStatus(BPSEvent ev)
 {
     if (ev.Domain != Vibration.Domain)
     {
         throw new ArgumentException("BPSEvent is not a Vibration event");
     }
     if (ev.Code != VIBRATION_INFO)
     {
         throw new ArgumentException("BPSEvent is an unknown Vibration event");
     }
     return(new VibrationStatus(ev.DangerousGetHandle()));
 }
Ejemplo n.º 4
0
        public static ButtonEvent GetButtonEvent(BPSEvent ev)
        {
            if (ev.Domain != ButtonEvent.BPSDomain)
            {
                throw new ArgumentException("BPSEvent is not a button event");
            }
            var code = ev.Code;

            if (code != BUTTON_UP && code != BUTTON_DOWN)
            {
                throw new ArgumentException("BPSEvent is an unknown button event");
            }
            return(new ButtonEvent(ev.DangerousGetHandle(), code == BUTTON_DOWN));
        }
Ejemplo n.º 5
0
        public static ScreenEvent GetScreenEvent(BPSEvent ev)
        {
            if (ev.Domain != ScreenEvent.BPSDomain)
            {
                throw new ArgumentException("BPSEvent is not a screen event");
            }
            var code = ev.Code;

            if (code != BPS_SCREEN_EVENT && code != BPS_SCREEN_FAILURE)
            {
                throw new ArgumentException("BPSEvent is an unknown screen event");
            }
            return(new ScreenEvent(ev.DangerousGetHandle(), code == BPS_SCREEN_FAILURE));
        }
Ejemplo n.º 6
0
        public static BatteryInfo GetBatteryInfoForEvent(BPSEvent ev)
        {
            if (ev.Domain != BatteryInfo.Domain)
            {
                throw new ArgumentException("BPSEvent is not a battery info event");
            }
            var code = ev.Code;

            if (code != BATTERY_INFO)
            {
                throw new ArgumentException("BPSEvent is an unknown battery info event");
            }
            return(new BatteryInfo(ev.DangerousGetHandle(), false));
        }
Ejemplo n.º 7
0
        public static VirtualKeyboardEvent GetVirtualKeyboardEvent(BPSEvent ev)
        {
            if (ev.Domain != ScreenEvent.BPSDomain)
            {
                throw new ArgumentException("BPSEvent is not a virtual keyboard event");
            }
            var code = ev.Code;

            if (code != VIRTUALKEYBOARD_EVENT_VISIBLE &&
                code != VIRTUALKEYBOARD_EVENT_HIDDEN &&
                code != VIRTUALKEYBOARD_EVENT_INFO)
            {
                throw new ArgumentException("BPSEvent is an unknown virtual keyboard event");
            }
            return(new VirtualKeyboardEvent(ev.DangerousGetHandle(), code == VIRTUALKEYBOARD_EVENT_INFO, code == VIRTUALKEYBOARD_EVENT_VISIBLE));
        }
Ejemplo n.º 8
0
 public static bool IsActivated(BPSEvent ev)
 {
     if (ev.Domain != ScreenInputGuard.Domain)
     {
         throw new ArgumentException("BPSEvent is not a Screen Input Guard event");
     }
     if (ev.Code != SCREEN_INPUT_GUARD_EVENT_STATUS)
     {
         throw new ArgumentException("BPSEvent is an unknown Screen Input Guard event");
     }
     var result = screen_input_guard_event_get_status(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return result == SCREEN_INPUT_GUARD_STATUS_ACTIVATED;
 }
Ejemplo n.º 9
0
 private static void EventCompletion(IntPtr ptr)
 {
     if (handleToCallback.ContainsKey(ptr))
     {
         var ev       = new BPSEvent(ptr, false);
         var callback = handleToCallback[ptr];
         handleToCallback.Remove(ptr);
         try
         {
             callback(ev);
         }
         catch
         {
         }
     }
     BPSEventPayload.FreeDataPointer(bps_event_get_payload(ptr));
 }
Ejemplo n.º 10
0
        public static LEDColor GetLEDColor(BPSEvent ev)
        {
            if (ev.Domain != LED.Domain)
            {
                throw new ArgumentException("BPSEvent is not a LED event");
            }
            if (ev.Code != LED_INFO)
            {
                throw new ArgumentException("BPSEvent is an unknown LED event");
            }
            bool red, green, blue;

            if (led_event_get_rgb(ev.DangerousGetHandle(), out red, out green, out blue) != BPS.BPS_SUCCESS)
            {
                Util.ThrowExceptionForLastErrno();
            }
            return((LEDColor)(((red ? 0xFF : 0x00) << 16) | ((green ? 0xFF : 0x00) << 8) | (blue ? 0xFF : 0x00)));
        }
Ejemplo n.º 11
0
        public static bool IsActivated(BPSEvent ev)
        {
            if (ev.Domain != ScreenInputGuard.Domain)
            {
                throw new ArgumentException("BPSEvent is not a Screen Input Guard event");
            }
            if (ev.Code != SCREEN_INPUT_GUARD_EVENT_STATUS)
            {
                throw new ArgumentException("BPSEvent is an unknown Screen Input Guard event");
            }
            var result = screen_input_guard_event_get_status(ev.DangerousGetHandle());

            if (result == BPS.BPS_FAILURE)
            {
                Util.ThrowExceptionForLastErrno();
            }
            return(result == SCREEN_INPUT_GUARD_STATUS_ACTIVATED);
        }
Ejemplo n.º 12
0
 public static Size GetCardSize(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.CardResize)
     {
         throw new ArgumentException("BPSEvent is not a card resize event");
     }
     Util.GetBPSOrException();
     var evPtr = ev.DangerousGetHandle();
     var w = navigator_event_get_card_width(evPtr);
     if (w == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not get width of card", Util.GetExceptionForLastErrno());
     }
     var h = navigator_event_get_card_height(evPtr);
     if (h == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not get height of card", Util.GetExceptionForLastErrno());
     }
     return new Size(w, h);
 }
Ejemplo n.º 13
0
 public static int GetOrientationAngle(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     switch ((NavigatorEvents)ev.Code)
     {
         case NavigatorEvents.Orientation:
         case NavigatorEvents.OrientationCheck:
         case NavigatorEvents.OrientationDone:
         case NavigatorEvents.OrientationResult:
             break;
         default:
             throw new ArgumentException("BPSEvent is not a orientation-specific event");
     }
     Util.GetBPSOrException();
     return navigator_event_get_orientation_angle(ev.DangerousGetHandle());
 }
Ejemplo n.º 14
0
 public static VibrationStatus GetVibrationStatus(BPSEvent ev)
 {
     if (ev.Domain != Vibration.Domain)
     {
         throw new ArgumentException("BPSEvent is not a Vibration event");
     }
     if (ev.Code != VIBRATION_INFO)
     {
         throw new ArgumentException("BPSEvent is an unknown Vibration event");
     }
     return new VibrationStatus(ev.DangerousGetHandle());
 }
Ejemplo n.º 15
0
 public static string GetID(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     switch ((NavigatorEvents)ev.Code)
     {
         case NavigatorEvents.Orientation:
         case NavigatorEvents.OrientationCheck:
         case NavigatorEvents.OrientationResult:
         case NavigatorEvents.InvokeTargetResult:
         case NavigatorEvents.InvokeQueryResult:
         case NavigatorEvents.InvokeViewerResult:
         case NavigatorEvents.InvokeViewerRelay:
         case NavigatorEvents.InvokeViewerRelayResult:
         case NavigatorEvents.InvokeGetFiltersResult:
         case NavigatorEvents.InvokeSetFiltersResult:
         case NavigatorEvents.Pooled:
         case NavigatorEvents.InvokeTimerRegistration:
             break;
         default:
             throw new ArgumentException("BPSEvent is not a supported event");
     }
     Util.GetBPSOrException();
     return Marshal.PtrToStringAnsi(navigator_event_get_id(ev.DangerousGetHandle()));
 }
Ejemplo n.º 16
0
 public static int GetKeyboardPosition(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.KeyboardPosition)
     {
         throw new ArgumentException("BPSEvent is not a keyboard position event");
     }
     Util.GetBPSOrException();
     var result = navigator_event_get_keyboard_position(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not retrieve keyboard position.");
     }
     return result;
 }
Ejemplo n.º 17
0
 public static BatteryInfo GetBatteryInfoForEvent(BPSEvent ev)
 {
     if (ev.Domain != BatteryInfo.Domain)
     {
         throw new ArgumentException("BPSEvent is not a battery info event");
     }
     var code = ev.Code;
     if (code != BATTERY_INFO)
     {
         throw new ArgumentException("BPSEvent is an unknown battery info event");
     }
     return new BatteryInfo(ev.DangerousGetHandle(), false);
 }
Ejemplo n.º 18
0
 public static LEDColor GetLEDColor(BPSEvent ev)
 {
     if (ev.Domain != LED.Domain)
     {
         throw new ArgumentException("BPSEvent is not a LED event");
     }
     if (ev.Code != LED_INFO)
     {
         throw new ArgumentException("BPSEvent is an unknown LED event");
     }
     bool red, green, blue;
     if (led_event_get_rgb(ev.DangerousGetHandle(), out red, out green, out blue) != BPS.BPS_SUCCESS)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return (LEDColor)(((red ? 0xFF : 0x00) << 16) | ((green ? 0xFF : 0x00) << 8) | (blue ? 0xFF : 0x00));
 }
Ejemplo n.º 19
0
 public static void OrientationCheckResponse(BPSEvent ev, bool willRotate)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.OrientationCheck)
     {
         throw new ArgumentException("BPSEvent is not a orientation check event");
     }
     Util.GetBPSOrException();
     navigator_orientation_check_response(ev.DangerousGetHandle(), willRotate);
 }
Ejemplo n.º 20
0
 public static WindowState GetWindowState(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.WindowState)
     {
         throw new ArgumentException("BPSEvent is not a window state event");
     }
     Util.GetBPSOrException();
     return navigator_event_get_window_state(ev.DangerousGetHandle());
 }
Ejemplo n.º 21
0
 public static string GetSystemKeyID(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.SystemKeyPress)
     {
         throw new ArgumentException("BPSEvent is not a system key press event");
     }
     Util.GetBPSOrException();
     return Marshal.PtrToStringAnsi(navigator_event_get_syskey_id(ev.DangerousGetHandle()));
 }
Ejemplo n.º 22
0
 public static SystemKey GetSystemKey(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.SystemKeyPress)
     {
         throw new ArgumentException("BPSEvent is not a system key press event");
     }
     Util.GetBPSOrException();
     var res = navigator_event_get_syskey_key(ev.DangerousGetHandle());
     if (res == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return (SystemKey)res;
 }
Ejemplo n.º 23
0
 public static bool GetSwipeAwayStoppedPeek(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.PeekStopped)
     {
         throw new ArgumentException("BPSEvent is not a peek stopped event");
     }
     Util.GetBPSOrException();
     bool swipeAway;
     var res = navigator_event_get_peek_stopped_swipe_away(ev.DangerousGetHandle(), out swipeAway) == BPS.BPS_SUCCESS;
     if (res)
     {
         return swipeAway;
     }
     return false;
 }
Ejemplo n.º 24
0
 public static Size GetOrientationSize(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.OrientationSize)
     {
         throw new ArgumentException("BPSEvent is not a orientation size event");
     }
     Util.GetBPSOrException();
     var evPtr = ev.DangerousGetHandle();
     return new Size(navigator_event_get_orientation_size_width(evPtr), navigator_event_get_orientation_size_height(evPtr));
 }
Ejemplo n.º 25
0
 public static OrientationMode GetOrientationMode(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     switch ((NavigatorEvents)ev.Code)
     {
         case NavigatorEvents.Orientation:
         case NavigatorEvents.OrientationCheck:
             break;
         default:
             throw new ArgumentException("BPSEvent is not a orientation or orientation check event");
     }
     Util.GetBPSOrException();
     return navigator_event_get_orientation_mode(ev.DangerousGetHandle());
 }
Ejemplo n.º 26
0
 public static string GetData(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.Invoke)
     {
         throw new ArgumentException("BPSEvent is not a invoke event");
     }
     Util.GetBPSOrException();
     // Invoke events are caused by navigator_invoke calls, which has been deprecated and isn't included in this library. Even so, data should be the remainder of the URL used for invocation. AKA, a string.
     return Marshal.PtrToStringAnsi(navigator_event_get_data(ev.DangerousGetHandle()));
 }
Ejemplo n.º 27
0
 public static string GetError(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     switch ((NavigatorEvents)ev.Code)
     {
         case NavigatorEvents.OrientationResult:
         case NavigatorEvents.InvokeTargetResult:
         case NavigatorEvents.InvokeQueryResult:
         case NavigatorEvents.InvokeViewerResult:
         case NavigatorEvents.InvokeViewerRelayResult:
         case NavigatorEvents.InvokeGetFiltersResult:
         case NavigatorEvents.InvokeSetFiltersResult:
         case NavigatorEvents.InvokeTimerRegistration:
             break;
         default:
             // It can be assumed that this function will be called for more then just supported events. So pretend that there is no error with them.
             //throw new ArgumentException("BPSEvent is not a supported event");
             return null;
     }
     Util.GetBPSOrException();
     return Marshal.PtrToStringAnsi(navigator_event_get_err(ev.DangerousGetHandle()));
 }
Ejemplo n.º 28
0
 public static void OrientationDone(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.Orientation)
     {
         throw new ArgumentException("BPSEvent is not a orientation event");
     }
     Util.GetBPSOrException();
     navigator_done_orientation(ev.DangerousGetHandle());
 }
Ejemplo n.º 29
0
 public static AppState GetAppState(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.AppState)
     {
         throw new ArgumentException("BPSEvent is not a app state event");
     }
     Util.GetBPSOrException();
     var res = navigator_event_get_app_state(ev.DangerousGetHandle());
     if (res == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not get app state");
     }
     return (AppState)res;
 }
Ejemplo n.º 30
0
 public static KeyboardState GetKeyboardState(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.OrientationSize)
     {
         throw new ArgumentException("BPSEvent is not a keyboard state event");
     }
     Util.GetBPSOrException();
     var result = navigator_event_get_keyboard_state(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not retrieve keyboard state.");
     }
     return (KeyboardState)result;
 }
Ejemplo n.º 31
0
 public static T GetCodeAs <T>(this BPSEvent ev)
 {
     return((T)Enum.ToObject(typeof(T), ev.Code));
 }
Ejemplo n.º 32
0
 public bool PushEvent(BPSEvent ev)
 {
     if (chid == 0)
     {
         throw new ObjectDisposedException("Channel");
     }
     return BPS.bps_channel_push_event(chid, ev.DangerousGetHandle()) == BPS.BPS_SUCCESS;
 }
Ejemplo n.º 33
0
 internal BPSEvent(BPSEvent baseEvent)
 {
     handle = baseEvent.handle;
     token = baseEvent.token;
     IsDisposable = baseEvent.IsDisposable;
 }
Ejemplo n.º 34
0
 public static byte[] GetExtendedData(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     var evPtr = ev.DangerousGetHandle();
     var data = navigator_event_get_extended_data(evPtr);
     var exp = Util.GetExceptionForLastErrno();
     if (exp != null)
     {
         throw new InvalidOperationException("Could not get extended data from event", exp);
     }
     if (data == IntPtr.Zero)
     {
         return null;
     }
     var dataLen = navigator_event_get_extended_data_length(evPtr);
     var result = new byte[dataLen];
     Marshal.Copy(data, result, 0, (int)dataLen);
     return result;
 }
Ejemplo n.º 35
0
 public static string GetGroupID(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     switch ((NavigatorEvents)ev.Code)
     {
         case NavigatorEvents.WindowState:
         case NavigatorEvents.WindowActive:
         case NavigatorEvents.WindowInactive:
             break;
         default:
             throw new ArgumentException("BPSEvent is not a window state, window active, or window inactive event");
     }
     Util.GetBPSOrException();
     return Marshal.PtrToStringAnsi(navigator_event_get_groupid(ev.DangerousGetHandle()));
 }
Ejemplo n.º 36
0
 public static PeekType GetCardPeekType(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.CardPeekStarted)
     {
         throw new ArgumentException("BPSEvent is not a card peek started event");
     }
     Util.GetBPSOrException();
     var res = navigator_event_get_card_peek_type(ev.DangerousGetHandle());
     if (res == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not get card peek type.", Util.GetExceptionForLastErrno());
     }
     return (PeekType)res;
 }
Ejemplo n.º 37
0
 internal BPSEvent(BPSEvent baseEvent)
 {
     handle       = baseEvent.handle;
     token        = baseEvent.token;
     IsDisposable = baseEvent.IsDisposable;
 }
Ejemplo n.º 38
0
 public static int GetLowMemorySeverity(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.LowMemory)
     {
         throw new ArgumentException("BPSEvent is not a low memory event");
     }
     Util.GetBPSOrException();
     var result = navigator_event_get_severity(ev.DangerousGetHandle());
     if (result == BPS.BPS_FAILURE)
     {
         throw new InvalidOperationException("Could not retrieve severity from low memory event.");
     }
     return result;
 }
Ejemplo n.º 39
0
 public static string GetCardClosedReason(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     switch ((NavigatorEvents)ev.Code)
     {
         case NavigatorEvents.ChildCardClosed:
         case NavigatorEvents.CardClosed:
             break;
         default:
             throw new ArgumentException("BPSEvent is not a ChildCardClosed or CardClosed event");
     }
     Util.GetBPSOrException();
     return Marshal.PtrToStringAnsi(navigator_event_get_card_closed_reason(ev.DangerousGetHandle()));
 }
Ejemplo n.º 40
0
 public static OrientationMode GetCardOrientation(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.CardResize)
     {
         throw new ArgumentException("BPSEvent is not a card resize event");
     }
     Util.GetBPSOrException();
     var res = navigator_event_get_card_orientation(ev.DangerousGetHandle());
     if (res == BPS.BPS_FAILURE)
     {
         Util.ThrowExceptionForLastErrno();
     }
     return (OrientationMode)res;
 }
Ejemplo n.º 41
0
 public static string GetCardClosedDataType(BPSEvent ev)
 {
     if (ev.Domain != Domain)
     {
         throw new ArgumentException("BPSEvent is not a navigator event");
     }
     if ((NavigatorEvents)ev.Code != NavigatorEvents.ChildCardClosed)
     {
         throw new ArgumentException("BPSEvent is not a child card closed event");
     }
     Util.GetBPSOrException();
     return Marshal.PtrToStringAnsi(navigator_event_get_card_closed_data_type(ev.DangerousGetHandle()));
 }
Ejemplo n.º 42
0
 private static void EventCompletion(IntPtr ptr)
 {
     if (handleToCallback.ContainsKey(ptr))
     {
         var ev = new BPSEvent(ptr, false);
         var callback = handleToCallback[ptr];
         handleToCallback.Remove(ptr);
         try
         {
             callback(ev);
         }
         catch
         {
         }
     }
     BPSEventPayload.FreeDataPointer(bps_event_get_payload(ptr));
 }