Ejemplo n.º 1
0
        private async Task HandleMessage(DeviceMapping deviceMapping,
                                         ParsedData parsedData)
        {
            if (deviceMapping.Processor != null)
            {
                bool continueProcessing = await deviceMapping.Processor.Process(parsedData);

                if (!continueProcessing)
                {
                    _logger.LogWarning($"Filtered by processor");
                }
            }

            await Task.WhenAll(deviceMapping.Destinations.Select(async(s) =>
            {
                try
                {
                    await s.SendAsync(parsedData);
                }
                catch (Exception x)
                {
                    _logger.LogError(x, $"Destination {s.Name} failed");
                    throw;
                }
            }));
        }
Ejemplo n.º 2
0
        private void buttonPressed(object sender, EventArgs e)
        {
            if (remainingBtnSpots.Count == 0)
            {
                return;
            }

            pbar.Value += 1;

            var spot = remainingBtnSpots[0];

            remainingBtnSpots.RemoveAt(0);

            if (sender != null)
            {
                var ba = sender as ButtonActions;
                int id = (int)ba.Identifier;

                var dm = new DeviceMapping();
                dm.Source      = "button:" + (id - 1);
                dm.Gesture     = "Link";
                dm.Destination = spot.Button.ToString();
                mappings.Add(dm);
                progress.Text += string.Format("- Mapped button {0} to {1}", id - 1, Util.GetButtonDisplayName(spot.Button)) + "\n";
            }
            else
            {
                progress.Text += string.Format("- Not mapping button {0}", Util.GetButtonDisplayName(spot.Button)) + "\n";
            }

            if (spot.Button == VirtualController.Button.Tr)
            {
                front.Show();
                top.Hide();
            }

            if (remainingBtnSpots.Count == 0)
            {
                front.Hide();
                top.Show();
                var aspot = remainingAxisSpots[0];
                indicator.Location = new Point(front.Left + aspot.X - 8, front.Top + aspot.Y - 10);
                return;
            }
            else
            {
                int xadd = 0, yadd = 0;

                if (front.Visible)
                {
                    xadd = -3;
                    yadd = -3;
                }

                spot = remainingBtnSpots[0];
                indicator.Location = new Point(front.Left + spot.X + xadd, front.Top + spot.Y + yadd);
            }
        }
Ejemplo n.º 3
0
        private void axisPressed(object sender, EventArgs e)
        {
            if (remainingBtnSpots.Count > 0)
            {
                return;
            }
            if (remainingAxisSpots.Count == 0)
            {
                return;
            }

            pbar.Value += 1;

            var spot = remainingAxisSpots[0];

            remainingAxisSpots.RemoveAt(0);

            if (sender != null)
            {
                var aa = sender as AxisActions;
                int id = (int)aa.Identifier;

                var dm = new DeviceMapping();
                dm.Source      = "axis:" + (id - 1);
                dm.Destination = spot.Axis.ToString();
                dm.Gesture     = "";
                mappings.Add(dm);
                progress.Text += string.Format("- Mapped axis #{0} to {1}", id - 1, Util.GetAxisDisplayName(spot.Axis)) + "\n";
            }
            else
            {
                progress.Text += string.Format("- Not mapping axis {0}", Util.GetAxisDisplayName(spot.Axis)) + "\n";
            }

            if (spot.Axis == VirtualController.Axis.Trigger)
            {
                front.Show();
                top.Hide();
            }

            if (remainingAxisSpots.Count == 0)
            {
                page3.BringToFront();
                startBtn.Enabled    = true;
                noHaveBtn.Enabled   = false;
                finishedLbl.Text    = finishedLbl.Text.Replace("%", Controller.Device.ProductName);
                sendPermission.Text = sendPermission.Text.Replace("%", Controller.Device.ProductName);
                pbar.Hide();
            }
            else
            {
                spot = remainingAxisSpots[0];
                indicator.Location = new Point(front.Left + spot.X - 3, front.Top + spot.Y - 3);
            }
        }
Ejemplo n.º 4
0
 public DeviceMappingItem(DeviceMapping dm)
 {
     Mapping = dm;
 }