/// <summary> /// Handles EventController sent by DirectInputManager via EventBus< /// EventController> when any controller input occurs. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEventController(object sender, BusEventArgs <EventController> e) { if (InvokeRequired && !IsDisposed) { OnEventControllerInvoker d = new OnEventControllerInvoker(OnEventController); this.Invoke(d, new object[] { sender, e }); return; } EventController controllerEvent = e.BusEvent; switch (controllerEvent.Type) { case EventController.EventType.Button: textBoxControllerLog.AppendText(" " + controllerEvent.Joystick.Information.InstanceName + " (Button " + controllerEvent.Button + " " + controllerEvent.ButtonValue + ")\r\n"); break; case EventController.EventType.POV: textBoxControllerLog.AppendText(" " + controllerEvent.Joystick.Information.InstanceName + " (POV " + controllerEvent.POVState + ")\r\n"); break; // TODO do something with axis name and value case EventController.EventType.Axis: break; } }
/// <summary> /// Handles EventController sent by DirectInputManager via EventBus< /// EventController> when any controller input occurs. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEventController(object sender, BusEventArgs <EventController> e) { if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(new OnEventControllerInvoker(OnEventController), sender, e); return; } EventController controllerEvent = e.BusEvent; switch (controllerEvent.Type) { case EventController.EventType.Button: ControllerLog.Text += " " + controllerEvent.Joystick.Information.InstanceName + " (Button " + controllerEvent.Button + " " + controllerEvent.ButtonValue + ")\r\n"; break; case EventController.EventType.POV: ControllerLog.Text += " " + controllerEvent.Joystick.Information.InstanceName + " (POV " + controllerEvent.POVState + ")\r\n"; break; // TODO do something with axis name and value case EventController.EventType.Axis: break; } ControllerLog.ScrollToEnd(); }
private static void OnEventController(object sender, BusEventArgs <EventController> e) { if (e.BusEvent.Type != EventController.EventType.Axis) { LOGGER.Info(e.BusEvent.ToString()); } }
/// <summary> /// Handles EventControllersChanged sent by DirectInputManager via /// EventBus<EventControllersChanged> when list of connected /// controller devices is updated. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e) { if (InvokeRequired && !IsDisposed) { OnEventControllersChangedInvoker d = new OnEventControllersChangedInvoker(OnEventControllersChanged); this.Invoke(d, new object[] { sender, e }); return; } UpdateConnectedDevices(e.BusEvent.ConnectedDeviceInfos); }
protected override void OnEventController(object sender, BusEventArgs <EventController> e) { EventController eventController = e.BusEvent; if (eventController.Type == EventController.EventType.POV && eventController.POVState == POVState && eventController.Joystick.Information.InstanceName.Contains(NamePart)) { Fire(); } }
private void Bus_OnReceived(object sender, BusEventArgs e) { var data = System.Text.Json.JsonSerializer.Deserialize <IEnumerable <IOTData> >(e.Message); lock (Program.lockdb) { using (var litedb = new LitedbWapper(DBFile)) { litedb.Insert <IOTData>(data); } } }
private void Bus_OnReceived(object sender, BusEventArgs e) { if (e.Topic == BusOption.CMD_INPUT) { //接收到了控制命令 DriveControl Ctrl = JsonSerializer.Deserialize <DriveControl>(e.Message); if (Ctrl.Cmd == DriveControl.CMD_SHUTDOWN) { ISRun = false; } } }
private void Handle <TEnt>(BusEventArgs <TEnt> eventToHandle, ISubscriber <TEnt> subscriber) { try { this.OnSubscriberStarted(subscriber, eventToHandle.Data); subscriber.HandleEvent(eventToHandle.Data); } catch (Exception exc) { this.OnSubcriberExecutionException(subscriber, exc); } }
/// <summary> /// Handles EventControllersChanged sent by DirectInputManager via /// EventBus<EventControllersChanged> when list of connected /// controller devices is updated. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e) { // Events from DirectInputManager aren't on the UI thread, so // updates to window elements must be marshalled via Dispatcher.Invoke() if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(new OnEventControllersChangedInvoker(OnEventControllersChanged), sender, e); return; } UpdateConnectedDevices(e.BusEvent.ConnectedDeviceInfos); }
private void Bus_OnReceived(object sender, BusEventArgs e) { switch (e.Topic) { case BusOption.CTRL_START: //启动消息 StartDrive(e.Message); break; case BusOption.CTRL_STOP: //关闭消息 StopDrive(e.Message); break; } }
private void EventMouse_Received(object sender, BusEventArgs <EventMouse> e) { EventMouse eventMouse = e.BusEvent; // Always update status bar when mouse moves DisplayMouseMove(eventMouse.X, eventMouse.Y); if (LogInput && eventMouse.MouseButton != MouseButtons.None && eventMouse.ButtonState == ButtonStates.Press) { DisplayMouseClick(eventMouse.MouseButton, eventMouse.X, eventMouse.Y); } }
private void OnEventKeyboard(object sender, BusEventArgs <EventKeyboard> e) { EventKeyboard eventKeyboard = e.BusEvent; if (eventKeyboard.ButtonState == ButtonStates.Press) { keysPressed.Add(eventKeyboard.VirtualKeyCode); } else { keysPressed.Remove(eventKeyboard.VirtualKeyCode); } UpdateKeys(); }
private void EventKeyboard_Recieved(object sender, BusEventArgs <EventKeyboard> e) { if (LogInput) { EventKeyboard eventKeyboard = e.BusEvent; if (eventKeyboard.ButtonState == ButtonStates.Press) { DisplayKeyDown(eventKeyboard.VirtualKeyCode); } else { DisplayKeyUp(eventKeyboard.VirtualKeyCode); } } }
private static void OnEventController(object sender, BusEventArgs <EventController> e) { EventController controllerEvent = e.BusEvent; // Prevents spamming every time an axis is moved by writing that // information only when buttons are pressed if (controllerEvent.Type == EventController.EventType.Axis) { LastAxisEvent = e.BusEvent; } else { Console.WriteLine(controllerEvent.ToString()); if (LastAxisEvent != null) { Console.WriteLine(LastAxisEvent.ToString()); } } }
protected override void OnEventController(object sender, BusEventArgs <EventController> e) { EventController eventController = e.BusEvent; if ( (EventController.EventType.Axis == eventController.Type) && (Axis == (ControllerAxis)eventController.JoystickUpdate.Offset) && (eventController.Joystick.Properties.InstanceName.Contains(NamePart)) ) { // LOGGER.Info(String.Format("{0} {1} {2:n0}", NamePart, axis, axisValue)); int bandCurrent = GetBand(eventController.JoystickUpdate.Value); if (bandCurrent != this.bandPrevious) { LOGGER.Info( String.Format( "{0} {1} Entered band [{2}] from band [{3}] position={4:n0}", NamePart, axis, bandCurrent, bandPrevious, eventController.JoystickUpdate.Value)); // Activate keys for exited / entered bands if (bandPrevious != -1 && Keys.None != KeyList[bandPrevious]) { SimulateKey((int)KeyList[bandPrevious], ButtonStates.Release); } else if (bandCurrent != -1 && Keys.None != KeyList[bandCurrent]) { SimulateKey((int)KeyList[bandCurrent], ButtonStates.Press); } // Fire macro for entered band Fire(bandCurrent); this.bandPrevious = bandCurrent; } } }
private void sub_EventReceived2(object sender, BusEventArgs <DefferMessage1> e) { Debug.WriteLine("Received " + sender.ToString()); (sender as ISubscriber <DefferMessage1>).HandleEvent(e.Data); }
private void Bus_EventRecievedInt(object sender, BusEventArgs <int> e) { this.intReceived = e.BusEvent; }
void context_OnNewBusConstructed(object sender, BusEventArgs e) { _currentSystem.AddBus(e.Bus); }
private void EventController_Received(object sender, BusEventArgs <EventController> e) { DisplayControllerEvent(e.BusEvent); }
private void EventUserInfo_Received(object sender, BusEventArgs <EventUserInfo> e) { AppendText(" " + e.BusEvent.Message); }
private void sub_EventHandled2(object sender, BusEventArgs <DefferMessage1> e) { Debug.WriteLine("Handled " + sender.ToString()); countEvent.Signal(); }
private static void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e) { LOGGER.Info(e.BusEvent.ToString()); }
private void OnControllerPlugEvent(object sender, BusEventArgs <EventControllersChanged> e) { connectedDeviceInfos = e.BusEvent.ConnectedDeviceInfos; UpdateListView(); }
private void Bus_OnReceived(object sender, BusEventArgs e) { var data = System.Text.Json.JsonSerializer.Deserialize <IEnumerable <IOTData> >(e.Message); litedb.Insert <IOTData>(data); }
void Instance_BusCreated(object sender, BusEventArgs e) { this.Dispatcher.Invoke(new Action(() => this.RemoveBus(e.Bus))); }
private void Bus_OnReceived(object sender, BusEventArgs e) { }
protected abstract void OnEventController(object sender, BusEventArgs <EventController> e);
private static void OnEventControllersChanged(object sender, BusEventArgs <EventControllersChanged> e) { Console.WriteLine("Controller un/plugged. New count: " + e.BusEvent.ConnectedDeviceInfos.Count); }
private void Bus_EventRecievedObject(object sender, BusEventArgs <object> e) { this.objectReceived = e.BusEvent; }