private void btnOK_Click(object sender, EventArgs e)
        {
            Address.Name = this.txtName.Text.Trim();

            try
            {
                KNXAddressHelper.StringToAddress(this.txtWriteAddress.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, UIResMang.GetString("Message6"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtWriteAddress.Focus();
                return;
            }
            Address.KnxAddress = this.txtWriteAddress.Text.Trim();

            // 数据类型
            if (string.IsNullOrWhiteSpace(this.btnDPTName.Text))
            {
                MessageBox.Show(UIResMang.GetString("Message46"), UIResMang.GetString("Message6"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.btnDPTName.Focus();
                return;
            }
            DatapointType dpt = DPTHelper.GetTypeNode(this.btnDPTName.Text); //this.tvDPTName.SelectedNode as DatapointType;

            if (null != dpt)
            {
                Address.KnxMainNumber = dpt.KNXMainNumber;
                Address.KnxSubNumber  = dpt.KNXSubNumber;
                Address.DPTName       = dpt.Text;
                Address.Type          = dpt.Type;
            }

            // 优先级
            var selectedTextPriority = this.cmbPriority.SelectedItem;

            if (selectedTextPriority != null)
            {
                KNXPriority priority = KNXPriority.Low;
                Enum.TryParse(selectedTextPriority.ToString(), out priority);
                Address.Priority = priority;
            }

            Address.IsCommunication = this.cbxCommunication.Checked;
            Address.IsRead          = this.cbxRead.Checked;
            Address.IsWrite         = this.cbxWrite.Checked;
            Address.IsTransmit      = this.cbxTransmit.Checked;
            Address.IsUpgrade       = this.cbxUpgrade.Checked;

            this.DialogResult = DialogResult.OK;
        }
        private void backWorkerSave_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            //int len = this.dataGridView.RowCount;

            //for (int i = 0; i < len; i++)
            int len = listAddress.Count;

            for (int i = 0; i < len; i++)
            {
                float f = (float)i / (len - 1);
                worker.ReportProgress((int)(f * 100));

                //DataGridViewRow row = this.dataGridView.Rows[i];
                //bool isSelected = (bool)row.Cells["IsSelected"].Value;
                //if (isSelected)
                //{
                //    EdGroupAddress addr = new EdGroupAddress();
                //    addr.Id = row.Cells["Id"].Value as string;
                //    addr.Name = row.Cells["Name"].Value as string;
                //    addr.KnxAddress = row.Cells["KnxAddress"].Value as string;
                //    addr.DPTName = row.Cells["DPTName"].Value as string;
                //    DatapointType dpt = DPTHelper.GetTypeNode(addr.DPTName);
                //    if (null != dpt)
                //    {
                //        addr.KnxMainNumber = dpt.KNXMainNumber;
                //        addr.KnxSubNumber = dpt.KNXSubNumber;
                //        addr.Type = dpt.Type;
                //    }
                //    addr.IsCommunication = (bool)row.Cells["IsCommunication"].Value;
                //    addr.IsRead = (bool)row.Cells["IsRead"].Value;
                //    addr.IsWrite = (bool)row.Cells["IsWrite"].Value;
                //    addr.IsTransmit = (bool)row.Cells["IsTransmit"].Value;
                //    addr.IsUpgrade = (bool)row.Cells["IsUpgrade"].Value;
                //    addr.Priority = (KNXPriority)row.Cells["Priority"].Value;
                //    addr.Actions = DPTHelper.GetActionNodes(addr.DPTName);

                //    MyCache.GroupAddressTable.Add(addr);
                //}

                ImGroupAddr imAddr = listAddress[i];
                if (imAddr.IsSelected)
                {
                    MgGroupAddress addr = new MgGroupAddress();
                    addr.Id         = imAddr.Id;
                    addr.Name       = imAddr.Name;
                    addr.KnxAddress = imAddr.KnxAddress;
                    addr.DPTName    = imAddr.DPTName;
                    DatapointType dpt = DPTHelper.GetTypeNode(imAddr.DPTName);
                    if (null != dpt)
                    {
                        addr.KnxMainNumber = dpt.KNXMainNumber;
                        addr.KnxSubNumber  = dpt.KNXSubNumber;
                        addr.Type          = dpt.Type;
                    }
                    addr.IsCommunication = imAddr.IsCommunication;
                    addr.IsRead          = imAddr.IsRead;
                    addr.IsWrite         = imAddr.IsWrite;
                    addr.IsTransmit      = imAddr.IsTransmit;
                    addr.IsUpgrade       = imAddr.IsUpgrade;
                    addr.Priority        = imAddr.Priority;
                    //addr.Actions = DPTHelper.GetActionNodes(addr.DPTName);
                    addr.Actions = new GroupAddressActions(DPTHelper.GetActionNodes(addr.DPTName));

                    //MyCache.GroupAddressTable.Add(addr);
                    var formName = typeof(FrmGroupAddressMgt).Name;
                    if (Application.OpenForms[formName] != null)
                    {
                        var frm = Application.OpenForms[formName] as FrmGroupAddressMgt;
                        if (frm != null)
                        {
                            frm.AddMgAddress(addr);
                        }
                    }
                }
            }
        }