Ejemplo n.º 1
0
        private void DoUpgradeThread()
        {
            try
            {
                PerformUpgrade();
            }
            catch (Exception ex)
            {
                if (ex.Message.StartsWith("Timeout"))
                {
                    SosMessageBox.Show("Timeout", "We never found a Siren of Shame device.  Did you connect one?", "Ok");
                }
                else
                {
                    ExceptionMessageBox.Show(this, "Error Performing Upgrade", "Error Performing Upgrade", ex);
                }

                Log.Error("Error performing upgrade", ex);
                _upgrading = false;
                Invoke(() =>
                {
                    EnableAllButtons(true);
                    _status.Text       = "Click Upgrade when ready";
                    _progressBar.Value = 0;
                });
            }
        }
Ejemplo n.º 2
0
        public static DialogResult Show(string title, string body, string button1Text, DialogResult button1DialogResult, string button2Text, DialogResult button2DialogResult)
        {
            SosMessageBox msg = new SosMessageBox
            {
                Text     = title,
                _body    = { Text = body },
                _button1 = { Text = button1Text },
                _button2 = { Visible = !string.IsNullOrEmpty(button2Text), Text = button2Text }
            };

            msg._button1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            msg._button2.AutoSizeMode = AutoSizeMode.GrowAndShrink;

            msg.ShowDialog();

            if (msg._button1Clicked)
            {
                return(button1DialogResult);
            }
            if (msg._button2Clicked)
            {
                return(button2DialogResult);
            }

            return(DialogResult.Cancel);
        }
Ejemplo n.º 3
0
        private void TimerTick(object sender, EventArgs e)
        {
            TimeSpan newTimeSpan = GetCountdownValue();

            UpdateDuration(newTimeSpan);
            if (newTimeSpan.Ticks < 0 && !_timerHitZero)
            {
                _timerHitZero = true;
                if (_timeboxAudio.SelectedIndex != 0)
                {
                    var duration = GetTimespanOrDefault(_timeboxAudioDuration, 10);
                    if (SirenOfShameDevice.IsConnected)
                    {
                        SirenOfShameDevice.PlayAudioPattern((AudioPattern)_timeboxAudio.SelectedItem, duration);
                    }
                }
                if (_timeboxLights.SelectedIndex != 0)
                {
                    var duration = GetTimespanOrDefault(_timeboxLightDuration, 10);
                    if (SirenOfShameDevice.IsConnected)
                    {
                        SirenOfShameDevice.PlayLightPattern((LedPattern)_timeboxLights.SelectedItem, duration);
                    }
                }
                SosMessageBox.Show("Meeting adjourned", "This meeting is officially over.", "Ok");
            }

            int warningDuration = ((KeyValuePair <int, string>)_warningDuration.SelectedItem).Key;

            if (newTimeSpan.TotalMinutes < warningDuration && !_timerWarningHit)
            {
                _timerWarningHit = true;
                if (_warningAudio.SelectedIndex != 0)
                {
                    var duration = GetTimespanOrDefault(_warningAudioDuration, 10);
                    if (SirenOfShameDevice.IsConnected)
                    {
                        SirenOfShameDevice.PlayAudioPattern((AudioPattern)_warningAudio.SelectedItem, duration);
                    }
                }
                if (_warningLights.SelectedIndex != 0)
                {
                    var duration = GetTimespanOrDefault(_warningLightDuration, 10);
                    if (SirenOfShameDevice.IsConnected)
                    {
                        SirenOfShameDevice.PlayLightPattern((LedPattern)_warningLights.SelectedItem, duration);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void _upgrade_Click(object sender, EventArgs e)
        {
            if (SirenOfShameDevice.IsConnected)
            {
                SosMessageBox.Show("Disconnect",
                                   "Can't you follow directions or something?  Please disconnect your Siren of Shame, then click upgrade, then re-connect it when you are instructed to do so.  Geez.",
                                   "Ok, ok, got it");
                return;
            }

            EnableAllButtons(enable: false);
            _status.Text       = "Waiting for connection...";
            _progressBar.Value = 0;
            DoUpgrade();
        }
Ejemplo n.º 5
0
 public void ViewLogs()
 {
     try
     {
         Process.Start(_logFilename);
     } catch (Win32Exception)
     {
         var directoryName = Path.GetDirectoryName(_logFilename);
         if (directoryName == null)
         {
             _log.Error(_logFilename + " didn't contain a directory");
             return;
         }
         SosMessageBox.Show("Can't Open Log", "Sorry there is no app associated with .log files (you really are a developer, right?), anyway we'll just open the location of the log files for you.  The logs follow the pattern 'SirenOfShame*.log'", "Do It");
         Process.Start(directoryName);
     }
 }
Ejemplo n.º 6
0
        public static DialogResult Show(string title, string body, string button1Text, DialogResult button1DialogResult, string button2Text, DialogResult button2DialogResult)
        {
            SosMessageBox msg = new SosMessageBox
            {
                Text = title,
                _body = {Text = body},
                _button1 = {Text = button1Text},
                _button2 = {Visible = !string.IsNullOrEmpty(button2Text), Text = button2Text}
            };
            msg._button1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            msg._button2.AutoSizeMode = AutoSizeMode.GrowAndShrink;

            msg.ShowDialog();

            if (msg._button1Clicked) return button1DialogResult;
            if (msg._button2Clicked) return button2DialogResult;

            return DialogResult.Cancel;
        }
Ejemplo n.º 7
0
 private void SirenFirmwareUpgrade_Load(object sender, EventArgs e)
 {
     SosMessageBox.Show("Disconnect Device",
                        "To perform upgrade 1. Disconnect your Siren of Shame device. 2. Select file.  3. Click upgrade. 4. When the dialog says 'Please connect your Siren of Shame' then, uh yea, do it",
                        "Got it");
 }