Exemplo n.º 1
0
        private void btn_添加_Click(object sender, EventArgs e)
        {
            if (txt_名称.Text.Trim().Length == 0)
            {
                MessageBox.Show("名称不能为空!");
                return;
            }
            if (tmp.场景子名称列表.FindIndex(t1 => t1.场景子名称 == txt_名称.Text) != -1)
            {
                MessageBox.Show("名称已存在!");
                return;
            }
            SetTimeType t;

            if (radio_普通定时.Checked)
            {
                t = SetTimeType.普通定时;
            }
            else if (radio_日出时间.Checked)
            {
                t = SetTimeType.日出时间;
            }
            else
            {
                t = SetTimeType.日落时间;
            }
            var v = new 场景子模块
            {
                场景子名称     = txt_名称.Text,
                动作        = radio_open.Checked ? true : false,
                动作时间      = time_开启时间.Value,
                定时方式      = t,
                场景调试模块列表2 = new List <场景调试模块>()
            };

            tmp.场景子名称列表.Add(v);
            string s = "";

            if (radio_普通定时.Checked)
            {
                s = v.动作时间.ToString("HH:mm:ss");
            }
            else if (radio_日出时间.Checked)
            {
                s = MainForm.日出时间;
            }
            else if (radio_日落时间.Checked)
            {
                s = MainForm.日落时间;
            }
            int i = dataGridView1.Rows.Add(v.场景子名称, v.动作?"开":"关", v.定时方式, s);

            dataGridView1.Rows[i].HeaderCell.Value = "动作" + dataGridView1.Rows.Count.ToString();
            dataGridView1.Rows[i].Selected         = true;
        }
Exemplo n.º 2
0
 public static List <SwitchMsg> 获取场景模块信息(场景子模块 msg)
 {
     try
     {
         List <SwitchMsg> tmpList = new List <SwitchMsg>();
         foreach (var v in msg.场景调试模块列表2)
         {
             SwitchMsg tmp = new SwitchMsg();
             tmp.addr = v.模块编号;
             var v1 = v.场景开关信息列表.OrderBy(t => int.Parse(t.开关通道));
             foreach (var v2 in v1)
             {
                 tmp.channel[int.Parse(v2.开关通道) - 1] = v2.开关状态 == "是" ? 1 : 0;
                 tmp.value[int.Parse(v2.开关通道) - 1]   = int.Parse(v2.开关亮度);
             }
             tmpList.Add(tmp);
         }
         return(tmpList);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }