Ejemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.btnDPTName.Text))
            {
                MessageBox.Show(ResourceMng.GetString("Message46"), ResourceMng.GetString("Message6"), MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            Address.Name       = this.txtName.Text.Trim();
            Address.KnxAddress = this.txtWriteAddress.Text.Trim();

            // 数据类型
            DatapointType dpt = DatapointType.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;
            }

            // 默认值
            Address.DefaultValue = this.txtDefaultValue.Text.Trim();

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

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

            //Address.WireNumber = this.txtWireNumber.Text.Trim();
            Address.ReadTimeSpan    = Convert.ToInt32(txtReadTimespan.Text);
            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;
            //Address.Tip = this.textBoxTip.Text;

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

            int len = this.dataGridView.RowCount;

            //float i = 0;
            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 = DatapointType.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         = DatapointType.GetActionNodes(addr.DPTName);

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