Ejemplo n.º 1
0
        private void btnAutoAdd_Click(object sender, EventArgs e)
        {
            if (DgvList.RowCount >= 254)
            {
                return;
            }
            if (txtNum.Text == null || txtNum.Text == "")
            {
                return;
            }
            int Num = Convert.ToInt32(txtNum.Text);

            if (Num > 254)
            {
                Num = 254;
            }
            if (myEIB.otherInfo == null)
            {
                myEIB.otherInfo = new List <EIBConverter.OtherInfo>();
            }
            if (Num > 0)
            {
                for (int i = 0; i < Num; i++)
                {
                    EIBConverter.OtherInfo oTmp = new EIBConverter.OtherInfo();
                    oTmp.GroupAddress = "0/0/0";
                    oTmp.ControlType  = 0;
                    oTmp.strDevName   = "0/0";
                    oTmp.Param1       = 1;
                    oTmp.Param2       = 1;
                    oTmp.Param3       = 1;
                    oTmp.Param4       = 1;
                    oTmp.Type         = 0;
                    myEIB.otherInfo.Add(oTmp);
                    object[] obj = new object[] { DgvList.RowCount + 1, oTmp.GroupAddress, cbType.Items[0].ToString(), "", oTmp.strDevName.Split('/')[0].ToString(),
                                                  oTmp.strDevName.Split('/')[1].ToString(), oTmp.Param1, oTmp.Param2, oTmp.Param3, clFlag.Items[0].ToString() };
                    DgvList.Rows.Add(obj);
                }
            }
            myEIB.MyRead2UpFlags[1] = false;
        }
Ejemplo n.º 2
0
        private void DgvList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            //更新缓存 函数补全
            if (DgvList.SelectedRows == null || DgvList.SelectedRows.Count == 0)
            {
                return;
            }
            if (DgvList.RowCount > 0)
            {
                int intLastSelect = SelectRowIndex;
                for (int i = 0; i < DgvList.SelectedRows.Count; i++)
                {
                    DgvList.SelectedRows[i].Cells[e.ColumnIndex].Value = DgvList[e.ColumnIndex, e.RowIndex].Value.ToString();

                    EIBConverter.OtherInfo temp = myEIB.otherInfo[DgvList.SelectedRows[i].Index];
                    temp.ControlType = Convert.ToByte(cbType.Items.IndexOf(DgvList[2, DgvList.SelectedRows[i].Index].Value.ToString()));
                    string str1 = DgvList[6, DgvList.SelectedRows[i].Index].Value.ToString();
                    string str2 = DgvList[7, DgvList.SelectedRows[i].Index].Value.ToString();
                    string str3 = DgvList[8, DgvList.SelectedRows[i].Index].Value.ToString();
                    if (str1.Contains("("))
                    {
                        str1 = str1.Split('(')[0].ToString();
                    }
                    else
                    {
                        str1 = IsNumeric(str1).ToString();
                    }
                    if (str2.Contains("("))
                    {
                        str2 = str2.Split('(')[0].ToString();
                    }
                    else
                    {
                        str2 = IsNumeric(str2).ToString();
                    }

                    if (temp.ControlType == 0 || temp.ControlType == 2 || temp.ControlType == 3 || temp.ControlType == 9 || temp.ControlType == 10 ||
                        temp.ControlType == 11 || temp.ControlType == 13)
                    {
                        temp.Param1 = Convert.ToByte(int.Parse(str1));
                    }
                    if (temp.ControlType == 1)
                    {
                        temp.Param1 = Convert.ToByte(int.Parse(str1));
                        temp.Param2 = Convert.ToByte(int.Parse(str2));
                    }
                    if (temp.ControlType == 4 || temp.ControlType == 5)
                    {
                        temp.Param1 = Convert.ToByte(int.Parse(str1));
                        temp.Param2 = Convert.ToByte(int.Parse(str2));
                        if (!str3.Contains(":"))
                        {
                            str3 = "0:0";
                        }
                        string time = HDLPF.GetTimeFromString(str3, ':');
                        temp.Param3 = Convert.ToByte(int.Parse(time) / 256);
                        temp.Param4 = Convert.ToByte(int.Parse(time) % 256);
                    }
                    if (temp.ControlType == 6)
                    {
                        temp.Param1 = 255;
                    }
                    if (temp.ControlType == 7)
                    {
                        temp.Param1 = Convert.ToByte(int.Parse(str1));
                        temp.Param2 = Convert.ToByte(int.Parse(str2));
                        if (!str3.Contains(":"))
                        {
                            str3 = "0:0";
                        }
                        string time = HDLPF.GetTimeFromString(str3, ':');
                        temp.Param3 = Convert.ToByte(int.Parse(time) / 256);
                        temp.Param4 = Convert.ToByte(int.Parse(time) % 256);
                    }
                    if (temp.ControlType == 8)
                    {
                        temp.Param1 = 255;
                        temp.Param2 = Convert.ToByte(int.Parse(str2));
                        if (!str3.Contains(":"))
                        {
                            str3 = "0:0";
                        }
                        string time = HDLPF.GetTimeFromString(str3, ':');
                        temp.Param3 = Convert.ToByte(int.Parse(time) / 256);
                        temp.Param4 = Convert.ToByte(int.Parse(time) % 256);
                    }
                }
            }
            myEIB.MyRead2UpFlags[1] = false;
        }