public bool PushEvent(BPSEvent ev) { if (chid == 0) { throw new ObjectDisposedException("Channel"); } return(BPS.bps_channel_push_event(chid, ev.DangerousGetHandle()) == BPS.BPS_SUCCESS); }
public bool PushEvent(BPSEvent ev) { if (disposed) { throw new ObjectDisposedException("BPS"); } return(bps_push_event(ev.DangerousGetHandle()) == BPS_SUCCESS); }
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())); }
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)); }
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)); }
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)); }
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)); }
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; }
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)); }
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))); }
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); }
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); }
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()); }
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()); }
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())); }
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; }
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); }
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)); }
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); }
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()); }
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())); }
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; }
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; }
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)); }
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()); }
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())); }
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())); }
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()); }
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; }
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; }
public static T GetCodeAs <T>(this BPSEvent ev) { return((T)Enum.ToObject(typeof(T), ev.Code)); }
public bool PushEvent(BPSEvent ev) { if (chid == 0) { throw new ObjectDisposedException("Channel"); } return BPS.bps_channel_push_event(chid, ev.DangerousGetHandle()) == BPS.BPS_SUCCESS; }
internal BPSEvent(BPSEvent baseEvent) { handle = baseEvent.handle; token = baseEvent.token; IsDisposable = baseEvent.IsDisposable; }
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; }
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())); }
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; }
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; }
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())); }
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; }
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())); }