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;
        }
Exemple #2
0
 public ImGroupAddr()
 {
     this.Id                  = "";
     this.IsSelected          = false;
     this.Name                = "";
     this.KnxAddress          = "";
     this.DPTName             = "";
     this.DPTNameIsDetermined = false;
     this.IsCommunication     = false;
     this.IsRead              = false;
     this.IsWrite             = false;
     this.IsTransmit          = false;
     this.IsUpgrade           = false;
     this.Priority            = KNXPriority.Low;
 }
Exemple #3
0
 public ImGroupAddr()
 {
     this.Id = "";
     this.IsSelected = false;
     this.Name = "";
     this.KnxAddress = "";
     this.DPTName = "";
     this.DPTNameIsDetermined = false;
     this.IsCommunication = false;
     this.IsRead = false;
     this.IsWrite = false;
     this.IsTransmit = false;
     this.IsUpgrade = false;
     this.Priority = KNXPriority.Low;
 }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            var selectedText = this.cmboxPriority.SelectedItem;
            if (selectedText != null)
            {
                KNXPriority dataPriority = KNXPriority.Low;
                Enum.TryParse(selectedText.ToString(), out dataPriority);
                priority = dataPriority;

                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.Ignore;
            }
        }
        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;
        }
Exemple #6
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            var selectedText = this.cmboxPriority.SelectedItem;

            if (selectedText != null)
            {
                KNXPriority dataPriority = KNXPriority.Low;
                Enum.TryParse(selectedText.ToString(), out dataPriority);
                priority = dataPriority;

                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.Ignore;
            }
        }
        private void dgvGroupAddress_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                if (this.IsSelectAll)
                {
                    this.IsSelectAll = false;

                    this.dgvGroupAddress.CurrentCell = null;

                    for (int i = 0; i < this.dgvGroupAddress.RowCount; i++)
                    {
                        this.dgvGroupAddress.Rows[i].Cells["IsSelected"].Value = false;
                    }
                }
                else
                {
                    this.IsSelectAll = true;

                    this.dgvGroupAddress.CurrentCell = null;

                    for (int i = 0; i < this.dgvGroupAddress.RowCount; i++)
                    {
                        this.dgvGroupAddress.Rows[i].Cells["IsSelected"].Value = true;
                    }
                }
            }
            else
            {
                this.dgvGroupAddress.EndEdit();

                bool anySelected            = false;
                bool communicationIsChecked = false;
                bool readIsChecked          = false;
                bool writeIsChecked         = false;
                bool transmitIsChecked      = false;
                bool upgradeIsChecked       = false;
                foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                {
                    anySelected            = (bool)row.Cells["IsSelected"].Value;
                    communicationIsChecked = (bool)row.Cells["IsCommunication"].Value;
                    readIsChecked          = (bool)row.Cells["IsRead"].Value;
                    writeIsChecked         = (bool)row.Cells["IsWrite"].Value;
                    transmitIsChecked      = (bool)row.Cells["IsTransmit"].Value;
                    upgradeIsChecked       = (bool)row.Cells["IsUpgrade"].Value;
                    if (anySelected)
                    {
                        break;
                    }
                }

                if (anySelected)
                {
                    if (1 == e.ColumnIndex) // Id
                    {
                    }
                    else if (2 == e.ColumnIndex) // Name
                    {
                    }
                    else if (3 == e.ColumnIndex) // KnxAddress
                    {
                    }
                    else if (4 == e.ColumnIndex) // KnxMainNumber
                    {
                    }
                    else if (5 == e.ColumnIndex) // KnxSubNumber
                    {
                    }
                    else if (6 == e.ColumnIndex) // Type
                    {
                    }
                    else if (7 == e.ColumnIndex) // DPTName
                    {
                    }
                    else if (8 == e.ColumnIndex) // 是否通讯
                    {
                        foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                        {
                            bool isSelected = (bool)row.Cells[0].Value;
                            if (isSelected)
                            {
                                if (communicationIsChecked)
                                {
                                    row.Cells[e.ColumnIndex].Value = false;
                                }
                                else
                                {
                                    row.Cells[e.ColumnIndex].Value = true;
                                }
                            }
                        }

                        Changed = true;
                    }
                    else if (9 == e.ColumnIndex) // 是否读
                    {
                        foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                        {
                            bool isSelected = (bool)row.Cells[0].Value;
                            if (isSelected)
                            {
                                if (readIsChecked)
                                {
                                    row.Cells[e.ColumnIndex].Value = false;
                                }
                                else
                                {
                                    row.Cells[e.ColumnIndex].Value = true;
                                }
                            }
                        }

                        Changed = true;
                    }
                    else if (10 == e.ColumnIndex) // 是否写
                    {
                        foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                        {
                            bool isSelected = (bool)row.Cells[0].Value;
                            if (isSelected)
                            {
                                if (writeIsChecked)
                                {
                                    row.Cells[e.ColumnIndex].Value = false;
                                }
                                else
                                {
                                    row.Cells[e.ColumnIndex].Value = true;
                                }
                            }
                        }

                        Changed = true;
                    }
                    else if (11 == e.ColumnIndex) // 是否传输
                    {
                        foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                        {
                            bool isSelected = (bool)row.Cells[0].Value;
                            if (isSelected)
                            {
                                if (transmitIsChecked)
                                {
                                    row.Cells[e.ColumnIndex].Value = false;
                                }
                                else
                                {
                                    row.Cells[e.ColumnIndex].Value = true;
                                }
                            }
                        }

                        Changed = true;
                    }
                    else if (12 == e.ColumnIndex) // 是否更新
                    {
                        foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                        {
                            bool isSelected = (bool)row.Cells[0].Value;
                            if (isSelected)
                            {
                                if (upgradeIsChecked)
                                {
                                    row.Cells[e.ColumnIndex].Value = false;
                                }
                                else
                                {
                                    row.Cells[e.ColumnIndex].Value = true;
                                }
                            }
                        }

                        Changed = true;
                    }
                    else if (13 == e.ColumnIndex) // 优先级
                    {
                        var frm    = new FrmSetPriority();
                        var result = frm.ShowDialog();
                        if (DialogResult.OK == result)
                        {
                            KNXPriority priority = frm.priority;
                            foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                            {
                                bool isSelected = (bool)row.Cells[0].Value;
                                if (isSelected)
                                {
                                    row.Cells[e.ColumnIndex].Value = priority;
                                }
                            }

                            Changed = true;
                        }
                    }
                    else if (14 == e.ColumnIndex) // 默认值
                    {
                        var frm    = new FrmSetDefaultValue();
                        var result = frm.ShowDialog();
                        if (DialogResult.OK == result)
                        {
                            int value = frm.value;
                            foreach (DataGridViewRow row in this.dgvGroupAddress.Rows)
                            {
                                bool isSelected = (bool)row.Cells[0].Value;
                                if (isSelected)
                                {
                                    row.Cells[e.ColumnIndex].Value = value;
                                }
                            }

                            Changed = true;
                        }
                    }
                    else if (15 == e.ColumnIndex) // Actions
                    {
                    }
                }
            }
        }