Ejemplo n.º 1
0
        public override bool DeactivateGroup(long groupID)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                IQueryable<device> devices = GetDeviceInGroup(groupID,db);

                if (devices != null)
                {
                    foreach (device d in devices)
                    {
                        switch (d.device_types.name)
                        {
                            case "SWITCH":
                                m_manager.SetNodeOff(m_homeId, Convert.ToByte(d.node_id));
                                break;
                            case "DIMMER":

                                m_manager.SetNodeLevel(m_homeId, Convert.ToByte(d.node_id), 0);
                                break;
                        }

                    }
                }
                return true;
            }
        }
Ejemplo n.º 2
0
        public static void DefineOrUpdateProperty(scene_property p)
        {
            if (p != null)
            {
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    scene_property existing_property = db.scene_property.FirstOrDefault(ep => ep.name == p.name);

                    if (existing_property == null)
                    {
                        db.scene_property.AddObject(p);
                    }
                    else
                    {
                        //Update
                        existing_property.friendly_name = p.friendly_name;
                        existing_property.description = p.description;
                        existing_property.value_data_type = p.value_data_type;
                        existing_property.defualt_value = p.defualt_value;

                        foreach (var option in db.scene_property_option.Where(o => o.scene_property_id == existing_property.id).ToArray())
                        {
                            db.DeleteObject(option);
                        }

                        foreach (scene_property_option spo in p.scene_property_option)
                            existing_property.scene_property_option.Add(new scene_property_option { option = spo.option });

                    }
                    db.SaveChanges();
                }
            }
        }
        private void AddEditEvent_Load(object sender, EventArgs e)
        {
            labelTitle.Text = (trigger_to_edit_id.HasValue) ? "Edit Trigger" :"Create Trigger";
            cmbo_scene.DisplayMember = "friendly_name";
            cmbo_devices.DisplayMember = "friendly_name";
            cmbo_devicevalues.DisplayMember = "label_name";

            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                //Load cmb box values
                cmbo_devices.DataSource = db.devices.OfType<device>().Execute(MergeOption.AppendOnly);
                cmbo_scene.DataSource = db.scenes.OrderBy(s=>s.sort_order);
                cmbo_operator.DataSource = Enum.GetValues(typeof(device_value_triggers.TRIGGER_OPERATORS));

                //prefill if editing
                if (trigger_to_edit_id.HasValue)
                {
                    device_value_triggers trigger_to_edit = db.device_value_triggers.FirstOrDefault(o => o.id == trigger_to_edit_id.Value);
                    if (trigger_to_edit != null)
                    {
                        if (trigger_to_edit.trigger_operator.HasValue)
                            cmbo_operator.Text = Enum.GetName(typeof(device_value_triggers.TRIGGER_OPERATORS), trigger_to_edit.trigger_operator.Value);
                        cmbo_devices.Text = trigger_to_edit.device_values.device.friendly_name;
                        cmbo_devicevalues.Text = trigger_to_edit.device_values.label_name;
                        cmbo_scene.Text = trigger_to_edit.scene.friendly_name;
                        txTriggertValue.Text = trigger_to_edit.trigger_value;
                        txt_name.Text = trigger_to_edit.Name;
                        checkBoxEnabled.Checked = trigger_to_edit.enabled;
                    }
                }
            }
        }
        private void AdvancedScripting_Load(object sender, EventArgs e)
        {
            labelTitle.Text = (trigger_to_edit_id.HasValue) ? "Edit Scripted Trigger" : "Create Scripted Trigger";
            cmbo_devicevalues.DisplayMember = "label_name";
            cmbo_devices.DisplayMember = "friendly_name";
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                //populate device box
                cmbo_devices.DataSource = db.devices.OfType<device>().Execute(MergeOption.AppendOnly);

                //populate trigger values
                if (trigger_to_edit_id.HasValue)
                {
                    device_value_triggers trigger_to_edit = db.device_value_triggers.FirstOrDefault(o => o.id == trigger_to_edit_id.Value);
                    if (trigger_to_edit != null)
                    {
                        cmbo_devices.SelectedItem = trigger_to_edit.device_values.device;
                        cmbo_devicevalues.SelectedItem = trigger_to_edit.device_values;
                        txt_name.Text = trigger_to_edit.Name;
                        ckEnabled.Checked = trigger_to_edit.enabled;
                        txt_script.Text = trigger_to_edit.trigger_script;
                    }
                }

            }
        }
        public static string GetDevicePropertyValue(long DeviceId, string SettingName)
        {
            using (zvsEntities2 context = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device device = context.devices.FirstOrDefault(o => o.id == DeviceId);

                if (device != null)
                {
                    device_property_values dpv = device.device_property_values.FirstOrDefault(o => o.device_propertys.name == SettingName);

                    if (dpv != null)
                    {
                        return dpv.value;
                    }
                    else
                    {
                        device_propertys dp = context.device_propertys.FirstOrDefault(o => o.name == SettingName);
                        if (dp != null)
                        {
                            return dp.default_value;
                        }
                    }
                }
                return string.Empty;
            }
        }
Ejemplo n.º 6
0
        public static void DefineOrUpdateDeviceProperty(device_propertys dp)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device_propertys existing_dp = db.device_propertys.FirstOrDefault(d => d.name == dp.name);

                if (existing_dp == null)
                {
                    db.device_propertys.AddObject(dp);
                }
                else
                {
                    existing_dp.friendly_name = dp.friendly_name;
                    existing_dp.value_data_type = dp.value_data_type;
                    existing_dp.default_value = dp.default_value;

                    foreach (var option in db.device_property_options.Where(p => p.device_property_id == existing_dp.id).ToArray())
                    {
                        db.DeleteObject(option);
                    }

                    foreach (device_property_options dpo in dp.device_property_options)
                        existing_dp.device_property_options.Add(new device_property_options { name = dpo.name });

                }
                db.SaveChanges();
            }
        }
Ejemplo n.º 7
0
        public override bool ActivateGroup(long groupID)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                IQueryable<device> devices = GetDeviceInGroup(groupID,db);

                if (devices != null)
                {
                    foreach (device d in devices)
                    {
                        switch (d.device_types.name)
                        {
                            case "SWITCH":
                                m_manager.SetNodeOn(m_homeId, Convert.ToByte(d.node_id));
                                break;
                            case "DIMMER":
                                byte defaultonlevel = 99;
                                byte.TryParse(device_property_values.GetDevicePropertyValue(d.id, "DEFAULONLEVEL"), out defaultonlevel);
                                m_manager.SetNodeLevel(m_homeId, Convert.ToByte(d.node_id), defaultonlevel);
                                break;
                        }

                    }
                }
            }
            return true;
        }
        private void AddEditSceneCMD_Load(object sender, EventArgs e)
        {
            ActiveControl = comboBoxCommand;
            comboBoxCommand.Focus();
            comboBoxCommand.DisplayMember = "friendly_name";
            editing = false;

             using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
             {
                 comboBoxCommand.DataSource = db.builtin_commands.OfType<builtin_commands>().Execute(MergeOption.AppendOnly);

                 //If we are editing, populate combo box
                 if (scenecmd_id_to_edit.HasValue)
                 {
                     scene_commands scmd = db.scene_commands.FirstOrDefault(c => c.id == scenecmd_id_to_edit.Value);
                     if (scmd != null)
                     {
                         editing = true;
                         builtin_commands b_cmd = db.builtin_commands.FirstOrDefault(c => c.id == scmd.command_id);
                         if (b_cmd != null)
                             comboBoxCommand.SelectedItem = b_cmd;
                     }
                 }
                 else
                 {
                     if (!selected_scene_id.HasValue)
                     {
                         //Must pass a scene id if you do not have a scene to edit.
                         this.Close();
                     }

                 }
             }
        }
 public static void Run(builtin_command_que cmd)
 {
     using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
     {
         db.builtin_command_que.AddObject(cmd);
         db.SaveChanges();
         BuiltinCommandAddedToQue(cmd.id);
     }
 }
 public static void Run(device_type_command_que cmd)
 {
     using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
     {
         db.device_type_command_que.AddObject(cmd);
         db.SaveChanges();
         DeviceTypeCommandAddedToQue(cmd.id);
     }
 }
Ejemplo n.º 11
0
 public void UpdateControl(long device_id)
 {
     this.device_id = device_id;
     using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
     {
         device device = db.devices.FirstOrDefault(d => d.id == device_id);
         if (device != null)
             textBoxName.Text = device.friendly_name;
     }
 }
        public void UpdateControl(long device_id)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device device = db.devices.FirstOrDefault(d => d.id == device_id);

                if(device!=null)
                    dataListViewStates.DataSource = device.device_values.ToList();
            }
        }
Ejemplo n.º 13
0
        private void GroupEditor_Load(object sender, EventArgs e)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                comboBoxGroups.DataSource = db.groups.OfType<group>().Execute(MergeOption.AppendOnly);
            }
            comboBoxGroups.DisplayMember = "name";

            //Select the first group if there is one
            if (comboBoxGroups.Items.Count > 0) { comboBoxGroups.SelectedIndex = 0; }
        }
Ejemplo n.º 14
0
        public static IQueryable<device> GetAllDevices(zvsEntities2 db, bool forList)
        {
            var query = from o in db.devices
                            where o.device_types.plugin.name != "BUILTIN"
                            select o;

                if (forList)
                    return query.Where(o => o.device_types.show_in_list == true).AsQueryable();
                else
                    return query.AsQueryable();
        }
Ejemplo n.º 15
0
        public void UpdateControl(long device_id)
        {
            listBoxGroups.Items.Clear();

            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device device = db.devices.FirstOrDefault(d => d.id == device_id);
                if (device != null)
                    foreach (group_devices gd in device.group_devices)
                        listBoxGroups.Items.Add(gd.group.name);
            }
        }
Ejemplo n.º 16
0
 public void Run()
 {
     using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
     {
         scene scene = db.scenes.FirstOrDefault(s => s.id == this.Scene_id);
         if (scene != null)
         {
             string result = scene.RunScene(db);
             Logger.WriteToLog(Urgency.INFO, string.Format("Scheduled task '{0}' {1}", this.friendly_name, result), _FriendlyName);
         }
         else
             Logger.WriteToLog(Urgency.WARNING, "Scheduled task '" + this.friendly_name + "' Failed to find scene ID '" + this.Scene_id + "'.", _FriendlyName);
     }
 }
Ejemplo n.º 17
0
        void btn_Click_Property_Set(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            scene_property property = (scene_property)btn.Tag;

            string arg = String.Empty;

            switch ((Data_Types)property.value_data_type)
            {
                case Data_Types.NONE:
                    break;
                case Data_Types.DECIMAL:
                case Data_Types.INTEGER:
                case Data_Types.SHORT:
                case Data_Types.BYTE:
                    //NumericUpDown have built in self validation
                    if (pnlSceneProperties.Controls.ContainsKey(property.id + "-proparg"))
                        arg = ((NumericUpDown)pnlSceneProperties.Controls[property.id + "-proparg"]).Value.ToString();
                    break;
                case Data_Types.BOOL:
                    if (pnlSceneProperties.Controls.ContainsKey(property.id + "-proparg"))
                        arg = ((CheckBox)pnlSceneProperties.Controls[property.id + "-proparg"]).Checked.ToString();
                    break;
                case Data_Types.STRING:
                    if (pnlSceneProperties.Controls.ContainsKey(property.id + "-proparg"))
                        arg = ((TextBox)pnlSceneProperties.Controls[property.id + "-proparg"]).Text;
                    break;
                case Data_Types.LIST:
                    if (pnlSceneProperties.Controls.ContainsKey(property.id + "-proparg"))
                        arg = ((ComboBox)pnlSceneProperties.Controls[property.id + "-proparg"]).Text;
                    break;
            }

            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                scene scene = db.scenes.FirstOrDefault(s => s.id == Scene_ID);
                if (scene != null)
                {
                    if (scene.scene_property_value.Any(sp => sp.scene_property_id == property.id))
                        scene.scene_property_value.FirstOrDefault(sp => sp.scene_property_id == property.id).value = arg;
                    else
                        scene.scene_property_value.Add(new scene_property_value { value = arg, scene_property_id = property.id });

                    db.SaveChanges();
                }
            }
            zvsEntityControl.CallSceneModified(this, Scene_ID);
        }
Ejemplo n.º 18
0
        public static string GetProgramOption(string optionName)
        {
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                program_options option = db.program_options.FirstOrDefault(o => o.name == optionName);

                if (option != null)
                    return option.value;
                else
                {
                    //DEFAULTS
                    if (optionName.Equals("TempAbbreviation"))
                        return "F";

                    return null;
                }
            }
        }
Ejemplo n.º 19
0
 private void buttonOn_Click(object sender, EventArgs e)
 {
     if (comboBoxGroups.SelectedIndex > -1)
     {
         group g = (group)comboBoxGroups.SelectedItem;
         if (g != null)
         {
             using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
             {
                 builtin_commands group_on_cmd = db.builtin_commands.FirstOrDefault(c => c.name == "GROUP_ON");
                 if (group_on_cmd != null)
                     group_on_cmd.Run(g.id.ToString());
             }
         }
     }
     else
         MessageBox.Show("No Group Selected!", zvsEntityControl.zvsNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 }
Ejemplo n.º 20
0
        private void btnAddOne_Click(object sender, EventArgs e)
        {
            group selected_group = (group)cboGroups.SelectedItem;

            if (selected_group != null)
            {
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    foreach (device d in lstNotAdded.SelectedObjects)
                    {
                        db.group_devices.AddObject(new group_devices { device_id = d.id, group_id = selected_group.id });
                    }
                    db.SaveChanges();
                }
                zvsEntityControl.CallDeviceModified(this, "group");
                RebindGroup();
            }
        }
Ejemplo n.º 21
0
 public static void InstallBuiltInCommand(builtin_commands c)
 {
     using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
     {
         builtin_commands existing_c = db.builtin_commands.FirstOrDefault(cmd => cmd.name == c.name);
         if (existing_c == null)
         {
             db.builtin_commands.AddObject(c);
         }
         else
         {
             existing_c.friendly_name = c.friendly_name;
             existing_c.custom_data1 = c.custom_data1;
             existing_c.custom_data2 = c.custom_data2;
             existing_c.show_on_dynamic_obj_list = c.show_on_dynamic_obj_list;
             existing_c.arg_data_type = c.arg_data_type;
         }
         db.SaveChanges();
     }
 }
Ejemplo n.º 22
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Object Name
            if (String.IsNullOrEmpty(textBoxName.Text))
                MessageBox.Show("Invalid Object Name", zvsEntityControl.zvsNameAndVersion);
            else
            {
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    device d = db.devices.FirstOrDefault(o => o.id == device_id);
                    if (d != null)
                    {
                        d.friendly_name = textBoxName.Text;
                        db.SaveChanges();

                        //Call event
                        zvsEntityControl.CallDeviceModified(this, "friendly_name");
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public static void DefineOrUpdateProgramOption(program_options opt)
        {
            if (opt != null)
            {
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    program_options existing_option = db.program_options.FirstOrDefault(o => o.name == opt.name);

                    if (existing_option == null)
                    {
                        db.program_options.AddObject(opt);
                    }
                    else
                    {
                        //Update
                        existing_option.name = opt.name;
                        existing_option.value = opt.value;
                    }
                    db.SaveChanges();
                }
            }
        }
        public static string GetPropertyValue(zvsEntities2 db, long sceneID, string property_value_name)
        {
            //Find the property
            scene_property property = db.scene_property.FirstOrDefault(p => p.name == property_value_name);

            if (property == null)
                return string.Empty;
            else
            {
                scene_property_value spv = db.scene_property_value.FirstOrDefault(p => p.scene_property_id == property.id && p.scene_id == sceneID);

                //Check to see if the property has been set yet, otherwise return the defualt vaule for this property.
                if (spv == null)
                {
                    return property.defualt_value;
                }
                else
                {
                    return spv.value;
                }
            }
        }
Ejemplo n.º 25
0
        protected Plugin(string Plugin_Name, string Plugin_Friendly_Name, string Plugin_Description)
        {
            _name = Plugin_Name;
            Friendly_Name = Plugin_Friendly_Name;
            Description = Plugin_Description;

            using (var context = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                plugin pl = context.plugins.FirstOrDefault(p => p.name == this._name);

                if (pl != null)
                {
                    pl.friendly_name = Friendly_Name;
                    pl.description = Description;
                }
                else
                {
                    pl = new plugin { name = _name, friendly_name = Friendly_Name, description = Description };
                    context.plugins.AddObject(pl);
                }
                context.SaveChanges();
            }
        }
Ejemplo n.º 26
0
        public string RunScene(zvsEntities2 db = null)
        {
            if (this.is_running || ExecuteScene.IsBusy)
                return "Failed to start scene '" + this.friendly_name + "' because it is already running!";
            else
            {
                bool DisposeDB = false;
                if (db == null)
                {
                    DisposeDB = true;
                    db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString);
                }

                scene s = db.scenes.FirstOrDefault(sc => sc.id == this.id);
                if (s != null)
                {
                    if (s.scene_commands.Count < 1)
                        return "Failed to start scene '" + this.friendly_name + "' because it has no commands!";

                    ExecuteScene.DoWork += new DoWorkEventHandler(ExecuteScene_DoWork);
                    ExecuteScene.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ExecuteScene_RunWorkerCompleted);

                    s.is_running = true;
                    db.SaveChanges();
                }

                if(DisposeDB)
                    db.Dispose();

                ExecuteScene.RunWorkerAsync(this.id);

                string result = "Scene '" + this.friendly_name + "' started.";
                zvsEntityControl.SceneRunStarted(this, result);
                return result;
            }
        }
Ejemplo n.º 27
0
        private void btnDeleteGroup_Click(object sender, EventArgs e)
        {
            if (cboGroups.SelectedIndex > -1)
            {
                group g = (group)cboGroups.SelectedItem;
                if (g != null)
                {
                    if (
                        MessageBox.Show("Are you sure you want to delete the " + g.name + " group?",
                                        "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                        DialogResult.Yes)
                    {
                        using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                        {
                            db.groups.DeleteObject(g);
                            db.SaveChanges();

                            zvsEntityControl.CallDeviceModified(this, "group");
                        }
                        cboGroups.SelectedIndex = cboGroups.Items.Count - 1;
                    }
                }
            }
        }
Ejemplo n.º 28
0
        void device_values_DeviceValueDataChangedEvent(object sender, device_values.ValueDataChangedEventArgs args)
        {
            if (IsReady)
            {
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    device_values dv = db.device_values.FirstOrDefault(v => v.id == args.device_value_id);
                    if (dv != null)
                    {

                        string[] deviceTypeValuespairs = GetSettingValue("NOTIFICATIONS").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string deviceTypeValuespair in deviceTypeValuespairs)
                        {
                            string thisEvent = dv.device.device_types.name + ":" + dv.label_name;

                            if (thisEvent.Equals(deviceTypeValuespair.Trim()))
                            {
                                Notification notification = new Notification("zVirtualScenes", NOTIFY_DEVICE_VALUE_CHANGE, "0", dv.device.friendly_name + " " + dv.label_name, "Changed to " + dv.value + " from " + args.previousValue + ".");
                                GrowlConnector.Notify(notification);
                            }
                        }
                    }
                }
            }
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txt_name.Text))
            {
                MessageBox.Show("Please enter a name for this trigger.", zvsEntityControl.zvsNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                ActiveControl = txt_name;
                return;
            }

            if (string.IsNullOrEmpty(txTriggertValue.Text))
            {
                MessageBox.Show("Please enter a trigger value for this trigger.", zvsEntityControl.zvsNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                ActiveControl = txt_name;
                return;
            }

            device_values selected_device_value = (device_values)cmbo_devicevalues.SelectedItem;
            if (selected_device_value == null)
            {
                MessageBox.Show("Please select a device value for this trigger.", zvsEntityControl.zvsNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                ActiveControl = cmbo_devicevalues;
                return;
            }

            scene selected_scene = (scene)cmbo_scene.SelectedItem;
            if (selected_scene == null)
            {
                MessageBox.Show("Please select a scene for this trigger.", zvsEntityControl.zvsNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                ActiveControl = cmbo_scene;
                return;
            }

            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device_value_triggers trigger_to_edit;
                if (trigger_to_edit_id.HasValue)
                {
                    trigger_to_edit = db.device_value_triggers.FirstOrDefault(o => o.id == trigger_to_edit_id.Value);
                }
                else
                {
                    trigger_to_edit = new device_value_triggers();
                }

                trigger_to_edit.device_value_id = selected_device_value.id;
                trigger_to_edit.enabled = true;
                trigger_to_edit.trigger_value = txTriggertValue.Text;
                trigger_to_edit.trigger_operator = (int)cmbo_operator.SelectedItem;
                trigger_to_edit.scene_id = selected_scene.id;
                trigger_to_edit.Name = txt_name.Text;
                trigger_to_edit.enabled = checkBoxEnabled.Checked;
                trigger_to_edit.trigger_type = (int)device_value_triggers.TRIGGER_TYPE.Basic;

                //if we are not editing add new trigger to trigger list
                if (!trigger_to_edit_id.HasValue)
                    db.device_value_triggers.AddObject(trigger_to_edit);

                db.SaveChanges();
            }
            zvsEntityControl.CallTriggerModified(this, "modified");
            this.Close();
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            long device_id = ((device)cmbo_devices.SelectedItem).id;
            using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
            {
                device device = db.devices.FirstOrDefault(d => d.id == device_id);
                //populate device values
                if (device != null)
                    cmbo_devicevalues.DataSource = device.device_values;

            }
        }