Esempio n. 1
0
 private void SubscribeEvents()
 {
     _sosOnlineService.StatusChanged  += OnStatusChanged;
     _sosOnlineService.SetAudio       += OnSetAudio;
     _sosOnlineService.SetLights      += OnSetLights;
     _sosOnlineService.ModalDialog    += OnModalDialog;
     _sosOnlineService.SetTrayIcon    += RulesEngineSetTrayIcon;
     _sosOnlineService.TrayNotify     += RulesEngineTrayNotify;
     _sirenOfShameDevice.Connected    += SirenOfShameDeviceConnected;
     _sirenOfShameDevice.Disconnected += SirenOfShameDeviceDisconnected;
     _sirenOfShameDevice.TryConnect();
 }
        private void _ledPlay_Click(object sender, EventArgs e)
        {
            var lvi = _ledPatterns.SelectedItems.Cast <ListViewItem>().FirstOrDefault();

            if (lvi != null)
            {
                var setting = (LedPatternSetting)lvi.Tag;
                if (_sirenOfShameDevice.TryConnect())
                {
                    var rows = _ledFileService.GetRows(File.ReadAllText(setting.FileName)).ToList();
                    for (int i = 0; i < 5; i++)
                    {
                        foreach (var row in rows)
                        {
                            _sirenOfShameDevice.ManualControl(new ManualControlData
                            {
                                Siren = false,
                                Led0  = row[0],
                                Led1  = row[1],
                                Led2  = row[2],
                                Led3  = row[3],
                                Led4  = row[4]
                            });
                            Thread.Sleep(100);
                        }
                    }

                    _sirenOfShameDevice.ManualControl(new ManualControlData
                    {
                        Siren = false,
                        Led0  = 0,
                        Led1  = 0,
                        Led2  = 0,
                        Led3  = 0,
                        Led4  = 0
                    });
                }
            }
        }
 private void _tryConnect_Click(object sender, EventArgs e)
 {
     _sirenOfShameDevice.TryConnect();
 }