예제 #1
0
 /// <summary>
 ///Edit action script and threshold.
 /// </summary>
 private void ActionEditBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (ActionsLV.SelectedItems.Count == 1)
         {
             ListViewItem               li     = ActionsLV.SelectedItems[0];
             int                        index  = ActionsLV.Items.IndexOf(li);
             GXDLMSRegisterMonitor      target = Target as GXDLMSRegisterMonitor;
             GXRegisterMonitorTargetDlg dlg    = new GXRegisterMonitorTargetDlg(target, index, false);
             if (dlg.ShowDialog(this) == DialogResult.OK)
             {
                 errorProvider1.SetError(ActionsLV, Properties.Resources.ValueChangedTxt);
                 Target.UpdateDirty(2, target.Thresholds);
                 Target.UpdateDirty(4, target.Actions);
                 GXDLMSActionSet it = target.Actions[index];
                 li.SubItems[0].Text = Convert.ToString(target.Thresholds[index]);
                 li.SubItems[1].Text = it.ActionUp.LogicalName;
                 li.SubItems[2].Text = it.ActionUp.ScriptSelector.ToString();
                 li.SubItems[3].Text = it.ActionDown.LogicalName;
                 li.SubItems[4].Text = it.ActionDown.ScriptSelector.ToString();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
 /// <summary>
 ///Add new action script and threshold.
 /// </summary>
 private void ActionAddBtn_Click(object sender, EventArgs e)
 {
     try
     {
         GXDLMSRegisterMonitor      target = Target as GXDLMSRegisterMonitor;
         GXRegisterMonitorTargetDlg dlg    = new GXRegisterMonitorTargetDlg(target, target.Thresholds.Length, false);
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             errorProvider1.SetError(ActionsLV, Properties.Resources.ValueChangedTxt);
             Target.UpdateDirty(2, target.Thresholds);
             Target.UpdateDirty(4, target.Actions);
             GXDLMSActionSet it = target.Actions[target.Actions.Length - 1];
             ListViewItem    li = ActionsLV.Items.Add(Convert.ToString(target.Thresholds[target.Thresholds.Length - 1]));
             li.SubItems.AddRange(new string[] { it.ActionUp.LogicalName, it.ActionUp.ScriptSelector.ToString(),
                                                 it.ActionDown.LogicalName, it.ActionDown.ScriptSelector.ToString() });
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }