Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public AreaOfInterest

        (
            Guid id,
            string name,
            AOIType areaType,
            Rectangle areaRect,
            int originalXResolution,
            int originalYResolution,
            MovementType movementType,
            AreaNotificationOption notifications,
            List <ObjectCharacteristics> searchCritera
        )

        {
            ID                  = id;
            AOIName             = name;
            AOIType             = areaType;
            AreaRect            = areaRect;
            OriginalXResolution = originalXResolution;
            OriginalYResolution = originalYResolution;
            MovementType        = movementType;
            Notifications       = notifications;
            SearchCriteria      = searchCritera;
        }
Ejemplo n.º 3
0
 public AreaNotificationOption(AreaNotificationOption src)
 {
     Urls               = new List <UrlOptions>(src.Urls);
     Email              = new List <string>(src.Email);
     UseMQTT            = src.UseMQTT;
     NoMotionMQTTNotify = src.NoMotionMQTTNotify;
     mqttCooldown       = new MQTTCoolDown(src.mqttCooldown.CooldownTime);
 }
Ejemplo n.º 4
0
 // Copy constructor for an area.
 public AreaOfInterest(AreaOfInterest src)
 {
     ID                  = src.ID; //
     AOIName             = src.AOIName;
     AOIType             = src.AOIType;
     AreaRect            = src.AreaRect;
     OriginalXResolution = src.OriginalXResolution;
     OriginalYResolution = src.OriginalYResolution;
     MovementType        = src.MovementType;
     Notifications       = new AreaNotificationOption(src.Notifications);
     SearchCriteria      = new List <ObjectCharacteristics>(src.SearchCriteria);
 }
Ejemplo n.º 5
0
        public static void SaveNotificationOption(RegistryKey key, AreaNotificationOption options)
        {
            if (key != null && options != null)
            {
                key.SetValue("UseMQTT", options.UseMQTT.ToString(), RegistryValueKind.String);
                key.SetValue("MQTTCooldown", options.mqttCooldown.CooldownTime, RegistryValueKind.DWord);
                key.SetValue("MQTTMotionStopped", options.NoMotionMQTTNotify.ToString(), RegistryValueKind.String);

                if (!string.IsNullOrEmpty(options.NoMotionUrlNotify))
                {
                    key.SetValue("MotionStoppedURL", options.NoMotionUrlNotify, RegistryValueKind.String);
                }

                key.DeleteSubKeyTree("URLs", false); // we are recreating it.

                using (RegistryKey urls = key.CreateSubKey("URLs", true))
                {
                    foreach (var notifyOption in options.Urls)
                    {
                        if (!string.IsNullOrEmpty(notifyOption.Url))
                        {
                            using (RegistryKey urlKey = urls.CreateSubKey(notifyOption.ID.ToString(), true))
                            {
                                urlKey.SetValue("URL", notifyOption.Url, RegistryValueKind.String);
                                urlKey.SetValue("CoolDown", notifyOption.CoolDown.CooldownTime, RegistryValueKind.DWord);
                                urlKey.SetValue("WaitTime", notifyOption.WaitTime, RegistryValueKind.DWord);
                                urlKey.SetValue("BIFlags", notifyOption.BIFlags, RegistryValueKind.DWord);
                            }
                        }
                    }
                }

                using (RegistryKey emails = key.CreateSubKey("Emails", true))
                {
                    foreach (var email in options.Email)
                    {
                        emails.CreateSubKey(email, true);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        }                     // a unique id for the area

        public AreaOfInterest()
        {
            ID             = Guid.NewGuid();
            SearchCriteria = new List <ObjectCharacteristics>();
            Notifications  = new AreaNotificationOption();
        }