public frmQueueSetting(object[] obj) : this() { if (obj != null && obj.Length >= 5) { sendObj = new QueueSendObject(); sendObj.Index = Convert.ToInt32(obj[0]); sendObj.Title = Convert.ToString(obj[1]); sendObj.Enable = Convert.ToBoolean(obj[2]); sendObj.Mode = Convert.ToString(obj[3]); sendObj.Content = Convert.ToString(obj[4]); CSendParam sp = getSendParamByMode(sendObj.Mode, sendObj.Content); chkSendHex.Checked = sp.Format == SendParamFormat.Hex ? true : false; cbSendMode.SelectedIndex = (int)sp.Mode; numSendListDelayTime.Value = sp.DelayTime; txtTitle.Text = sendObj.Title; if (sp.Format == SendParamFormat.Hex) { txtSend.Text = sp.HexString; } else { txtSend.Text = sp.ASCIIString; } } }
private void btnAddSendList_Click(object sender, EventArgs e) { //if (panelSendParam.Visible == false) //{ // panelSendParam.Visible = true; // btnAddSendList.Image = Properties.Resources.round_minus; // //btnAddSendList.Enabled = false; // btnDeleteSendList.Enabled = false; // btnSetupSendList.Enabled = false; // btnSetdownSendList.Enabled = false; // OpenParamSet(sender, e); //} //else //{ // panelSendParam.Visible = false; // btnAddSendList.Image = Properties.Resources.round_plus; // //btnAddSendList.Enabled = false; // btnDeleteSendList.Enabled = true; // btnSetupSendList.Enabled = true; // btnSetdownSendList.Enabled = true; // CloseParamSet(sender, e); //} bool topMost = this.ParentForm.TopMost; this.ParentForm.TopMost = false; frmQueueSetting frm = new frmQueueSetting(); if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { QueueSendObject obj = frm.SendObject; object[] array = new object[5]; array[0] = dgvSendList.Rows.Count; array[1] = obj.Title; array[2] = obj.Enable; array[3] = obj.Mode; array[4] = obj.Content; dgvSendList.Rows.Add(array); } this.ParentForm.TopMost = topMost; }
private void btnSaveSendParam_Click(object sender, EventArgs e) { if (txtSend.Text == string.Empty) { MessageBox.Show("发送数据不能为空", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { SendParamFormat format = SendParamFormat.ASCII; if (chkSendHex.Checked) { format = SendParamFormat.Hex; } CSendParam param = new CSendParam(format, (SendParamMode)cbSendMode.SelectedIndex, Convert.ToInt32(numSendListDelayTime.Value), txtSend.Text); if (sendObj == null) { sendObj = new QueueSendObject(); sendObj.Index = -1; sendObj.Enable = true; } if (chkTitleAuto.Checked) { sendObj.Title = txtSend.Text; } else { sendObj.Title = txtTitle.Text; } sendObj.Mode = param.ParameterString; sendObj.Content = param.Data; this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (System.Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dgvSendList_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } if (e.RowIndex >= dgvSendList.RowCount || e.ColumnIndex == 1 || e.ColumnIndex == 2) // 发送列和使能列不允许双击操作 { return; } DataGridViewRow row = dgvSendList.Rows[e.RowIndex]; object[] items = new object[row.Cells.Count]; for (int i = 0; i < items.Length; i++) { items[i] = row.Cells[i].Value; } bool topMost = this.ParentForm.TopMost; this.ParentForm.TopMost = false; frmQueueSetting frm = new frmQueueSetting(items); if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { QueueSendObject obj = frm.SendObject; row.Cells[1].Value = obj.Title; row.Cells[2].Value = obj.Enable; row.Cells[3].Value = obj.Mode; row.Cells[4].Value = obj.Content; } this.ParentForm.TopMost = topMost; }