Beispiel #1
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            _area.Notifications.Email.Clear();

            if (_area.Notifications.Urls != null)
            {
                _area.Notifications.Urls.Clear();

                _area.Notifications.Urls.Clear();

                foreach (ListViewItem url in urlsList.Items)
                {
                    UrlOptions option = (UrlOptions)url.Tag;
                    _area.Notifications.Urls.Add(option);
                }
            }

            if (emailsList.Items != null)
            {
                foreach (ListViewItem email in emailsList.Items)
                {
                    _area.Notifications.Email.Add(email.Text);
                }
            }

            _area.Notifications.NoMotionMQTTNotify = NoMotionMQTTCheck.Checked;
            _area.Notifications.NoMotionUrlNotify  = NoMotionUrlNotify.Text;

            _area.Notifications.UseMQTT = UseMQTTBox.Checked;

            DialogResult = DialogResult.OK;
        }
Beispiel #2
0
        private void OnActivateURL(object sender, EventArgs e)
        {
            ListViewItem item    = urlsList.Items[urlsList.SelectedIndices[0]];
            UrlOptions   options = (UrlOptions)item.Tag;

            AddEditURL(options);
        }
Beispiel #3
0
        public static AreaNotificationOption GetNotificationOption(RegistryKey key)
        {
            AreaNotificationOption notify = new AreaNotificationOption();

            notify.UseMQTT            = bool.Parse((string)key.GetValue("UseMQTT")); // save true/false as string to make it more readable
            notify.mqttCooldown       = new MQTTCoolDown((int)key.GetValue("MQTTCooldown"));
            notify.NoMotionMQTTNotify = bool.Parse((string)key.GetValue("MQTTMotionStopped"));
            notify.NoMotionUrlNotify  = (string)key.GetValue("MotionStoppedURL");

            using (RegistryKey urls = key.OpenSubKey("URLs"))
            {
                foreach (var urlID in urls.GetSubKeyNames())
                {
                    using (RegistryKey optionKey = urls.OpenSubKey(urlID))
                    {
                        UrlOptions opt = new UrlOptions((string)optionKey.GetValue("URL"), (int)optionKey.GetValue("WaitTime"), (int)optionKey.GetValue("CoolDown"), (int)optionKey.GetValue("BIFlags"));
                        opt.ID = Guid.Parse(urlID); // to keep it the same for debug otherwise not necessary
                        notify.Urls.Add(opt);
                    }
                }
            }

            using (RegistryKey emails = key.OpenSubKey("Emails"))
            {
                if (null != emails)
                {
                    foreach (var email in emails.GetSubKeyNames())
                    {
                        notify.Email.Add(email); // for email (the key name is the email name
                    }
                }
            }
            return(notify);
        }
Beispiel #4
0
        public AddUrlDialog(UrlOptions options)
        {
            InitializeComponent();
            Options = options;
            if (null == options)
            {
                Options = new UrlOptions(string.Empty, 0, 300, 0);
            }
            else
            {
                urlText.Text             = Options.Url;
                urlCoolDownNumeric.Value = Options.CoolDown.CooldownTime;
                WaitTimeNumeric.Value    = Options.WaitTime;

                if ((Options.BIFlags & (int)BIFLAGS.Flagged) > 0)
                {
                    FlagCheckBox.Checked = true;
                }

                if ((Options.BIFlags & (int)BIFLAGS.Confirmed) > 0)
                {
                    ConfirmCheckBox.Checked = true;
                }

                if ((Options.BIFlags & (int)BIFLAGS.Reset) > 0)
                {
                    ResetCheckBox.Checked = true;
                }
            }
        }
Beispiel #5
0
        public AddUrlDialog(UrlOptions options)
        {
            InitializeComponent();
            Options = options;
            if (null == options)
            {
                Options = new UrlOptions(string.Empty, 0, 300, 0);
            }

            urlText.Text             = Options.Url;
            urlCoolDownNumeric.Value = Options.CoolDown.CooldownTime;
            WaitTimeNumeric.Value    = Options.WaitTime;
        }
Beispiel #6
0
        private void AddEditURL(UrlOptions options)
        {
            bool added = false;

            if (null == options)
            {
                added = true;
            }

            using (AddUrlDialog dlg = new AddUrlDialog(options))
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    ListViewItem item;
                    int          index;

                    if (added)
                    {
                        item = new ListViewItem(new string[] { dlg.Options.Url, dlg.Options.WaitTime.ToString(), dlg.Options.CoolDown.CooldownTime.ToString() });

                        urlsList.Items.Add(item);
                        index = item.Index;
                    }
                    else
                    {
                        // editing
                        item  = urlsList.Items[urlsList.SelectedIndices[0]];
                        index = item.Index;
                        item.SubItems[0].Text = dlg.Options.Url; // update the stuff
                        item.SubItems[1].Text = dlg.Options.WaitTime.ToString();
                        item.SubItems[2].Text = dlg.Options.CoolDown.CooldownTime.ToString();
                    }

                    urlsList.Items[index].Tag      = dlg.Options;
                    urlsList.Items[index].Focused  = true;
                    urlsList.Items[index].Selected = true;
                }
            }
        }