예제 #1
0
 private async void HandleKiirooPlatformMessage(object aObj, KiirooPlatformEventArgs aEvent)
 {
     await Dispatcher.InvokeAsync(async() =>
     {
         FleshlightLaunchFW12Cmd currentTranslatedCommand = null;
         foreach (var device in _devices)
         {
             if (device.SupportsMessage(typeof(KiirooCmd)))
             {
                 await _bpServer.SendMessage(new KiirooCmd(device.Index, aEvent.Position));
             }
             else if (device.SupportsMessage(typeof(FleshlightLaunchFW12Cmd)) ||
                      device.SupportsMessage(typeof(SingleMotorVibrateCmd)))
             {
                 if (currentTranslatedCommand == null)
                 {
                     currentTranslatedCommand = _translator.Translate(new KiirooCmd(device.Index, aEvent.Position));
                 }
                 currentTranslatedCommand.DeviceIndex = device.Index;
                 if (device.SupportsMessage(typeof(FleshlightLaunchFW12Cmd)))
                 {
                     await _bpServer.SendMessage(currentTranslatedCommand);
                 }
             }
         }
     });
 }
 private async void HandleKiirooPlatformMessage(object aObj, KiirooPlatformEventArgs aEvent)
 {
     await Dispatcher.InvokeAsync(async() =>
     {
         var currentDevices = DeviceListBox.SelectedItems.Cast <Device>().ToList();
         FleshlightLaunchFW12Cmd currentTranslatedCommand = null;
         foreach (var device in currentDevices)
         {
             if (device.Messages.Contains(typeof(KiirooCmd).Name))
             {
                 await _bpServer.SendMessage(new KiirooCmd(device.Index, aEvent.Position));
             }
             else if (device.Messages.Contains("FleshlightLaunchFW12Cmd") ||
                      device.Messages.Contains("SingleMotorVibrateCmd"))
             {
                 if (currentTranslatedCommand == null)
                 {
                     currentTranslatedCommand = _translator.Translate(new KiirooCmd(device.Index, aEvent.Position));
                 }
                 currentTranslatedCommand.DeviceIndex = device.Index;
                 if (device.Messages.Contains("FleshlightLaunchFW12Cmd"))
                 {
                     await _bpServer.SendMessage(currentTranslatedCommand);
                 }
             }
         }
     });
 }