private void ConditionListView_SelectedIndexChanged(object sender, EventArgs e) { /* * if (ConditionListView.SelectedIndices.Count > 1) * { * EdtSelectedConditions.Text = "[" + ConditionListView.SelectedItems[0].Text + "] " + ConditionListView.SelectedItems[0].SubItems[1].Text + " & " + "[" + ConditionListView.SelectedItems[1].Text + "] " + ConditionListView.SelectedItems[1].SubItems[1].Text; * } * else if (ConditionListView.SelectedIndices.Count > 0) * { * EdtSelectedConditions.Text = "[" + ConditionListView.SelectedItems[0].Text + "] " + ConditionListView.SelectedItems[0].SubItems[1].Text; * } */ if (ConditionListView.SelectedItems.Count > 0) { try { LblCondIdx.Text = ConditionListView.SelectedItems[0].Text; LblCondNo.Text = ConditionListView.SelectedItems[0].SubItems[4].Text; if (Convert.ToByte(LblCondNo.Text) > (byte)LOGIC_CONDITION_TYPE.L_EVENT_MAX) { LblCondNo.Text = LOGIC_CONDITION_TYPE.L_EVENT_INVALID.ToString(); } //CmbConditionList.SelectedIndex = CmbConditionList.FindStringExact(LOGIC_CONDITION_NAMES[Convert.ToInt32(ConditionListView.SelectedItems[0].SubItems[4].Text.ToString())]); UpDownCondParam1.Value = Convert.ToUInt32(ConditionListView.SelectedItems[0].SubItems[2].Text); UpDownCondParam2.Value = Convert.ToUInt32(ConditionListView.SelectedItems[0].SubItems[3].Text); CmbConditionList.SelectedIndex = CmbConditionList.FindStringExact(LOGIC_CONDITION_NAMES[Convert.ToInt32(ConditionListView.SelectedItems[0].SubItems[4].Text.ToString())]); UpdateConditionEditor(); } catch (Exception) { UpDownCondParam1.Value = 0; UpDownCondParam2.Value = 0; UpdateConditionEditor(); } } }
private void UpdateConditionEditor() { LblCondNo.Text = CmbConditionList.SelectedIndex.ToString(); switch ((LOGIC_CONDITION_TYPE)CmbConditionList.SelectedIndex) { case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_RAISING: case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_FALLING: case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_LOW: case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_HIGH: tabConditions.SelectedTab = GpioTab; try { CondGpioMask.Value = (int)UpDownCondParam2.Value; CondGpioPort.SelectedIndex = (int)UpDownCondParam1.Value; } catch (Exception) { } tabConditions.Show(); CmbConditionList.Focus(); break; case LOGIC_CONDITION_TYPE.L_EVENT_DATE_AFTER: case LOGIC_CONDITION_TYPE.L_EVENT_DATE_BEFORE: tabConditions.SelectedTab = DateTab; try { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); CondDate.Value = epoch.AddSeconds((int)UpDownCondParam1.Value); } catch (Exception) { CondDate.Value = DateTime.Now; } tabConditions.Show(); CmbConditionList.Focus(); break; case LOGIC_CONDITION_TYPE.L_EVENT_TIME_AFTER: case LOGIC_CONDITION_TYPE.L_EVENT_TIME_BEFORE: tabConditions.SelectedTab = TabTime; CondTime.Value = DecodeTime((UInt32)UpDownCondParam1.Value); tabConditions.Show(); CmbConditionList.Focus(); break; case LOGIC_CONDITION_TYPE.L_EVENT_ADC_ABOVE: case LOGIC_CONDITION_TYPE.L_EVENT_ADC_BELOW: tabConditions.SelectedTab = AdcTab; tabConditions.Show(); CmbConditionList.Focus(); try { CondAdcPort.SelectedIndex = (int)UpDownCondParam1.Value; } catch (Exception) { CondAdcPort.SelectedIndex = 0; } CondAdcMask.Value = (int)UpDownCondParam2.Value; break; case LOGIC_CONDITION_TYPE.L_EVENT_REG_ABOVE: case LOGIC_CONDITION_TYPE.L_EVENT_REG_EQUAL: case LOGIC_CONDITION_TYPE.L_EVENT_REG_BELOW: tabConditions.SelectedTab = TabRegister; tabConditions.Show(); CmbConditionList.Focus(); try { CondRegNo.Value = (int)UpDownCondParam1.Value; } catch (Exception) { CondRegNo.Value = 0; } CondRegVal.Value = (int)UpDownCondParam2.Value; break; default: tabConditions.SelectedTab = TabNoParams; //tabConditions.Hide(); break; } }