public void OnValueChanged(GXDLMSViewArguments arg)
        {
            GXDLMSIecTwistedPairSetup target = Target as GXDLMSIecTwistedPairSetup;

            if (arg.Index == 4)
            {
                PrimaryAddressesList.Items.Clear();
                if (target.PrimaryAddresses != null)
                {
                    foreach (byte it in target.PrimaryAddresses)
                    {
                        PrimaryAddressesList.Items.Add(it.ToString());
                    }
                }
            }
            else if (arg.Index == 5)
            {
                TabisList.Items.Clear();
                if (target.Tabis != null)
                {
                    foreach (byte it in target.Tabis)
                    {
                        TabisList.Items.Add(it.ToString());
                    }
                }
            }
            else
            {
                throw new IndexOutOfRangeException("index");
            }
        }
 /// <summary>
 /// Remove TAB(i).
 /// </summary>
 private void TabisRemoveBtn_Click(object sender, EventArgs e)
 {
     try
     {
         GXDLMSIecTwistedPairSetup target = Target as GXDLMSIecTwistedPairSetup;
         List <sbyte> tabis = new List <sbyte>();
         if (target.Tabis != null)
         {
             tabis.AddRange(target.Tabis);
         }
         while (TabisList.SelectedItems.Count != 0)
         {
             string item = TabisList.SelectedItems[0].Text;
             TabisList.Items.Remove(TabisList.SelectedItems[0]);
             errorProvider1.SetError(TabisList, Properties.Resources.ValueChangedTxt);
             Target.UpdateDirty(5, target.Tabis);
             tabis.Remove(sbyte.Parse(item));
         }
         target.Tabis = tabis.ToArray();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// Edit TAB(i).
 /// </summary>
 private void TabisEditBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (TabisList.SelectedItems.Count == 1)
         {
             GXDLMSIecTwistedPairSetup target = Target as GXDLMSIecTwistedPairSetup;
             List <sbyte> tabis = new List <sbyte>();
             if (target.Tabis != null)
             {
                 tabis.AddRange(target.Tabis);
             }
             ListViewItem li  = TabisList.SelectedItems[0];
             GXTextDlg    dlg = new GXTextDlg("TAB(i)", "TAB(i)", li.Text, typeof(sbyte));
             if (dlg.ShowDialog(this) == DialogResult.OK)
             {
                 string tmp = dlg.GetValue();
                 int    pos = TabisList.SelectedIndices[0];
                 li.SubItems[0].Text = tmp;
                 tabis.RemoveAt(pos);
                 tabis.Insert(pos, sbyte.Parse(tmp));
                 errorProvider1.SetError(TabisList, Properties.Resources.ValueChangedTxt);
                 Target.UpdateDirty(5, target.Tabis);
                 target.Tabis = tabis.ToArray();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// Add TAB(i).
 /// </summary>
 private void TabisAddBtn_Click(object sender, EventArgs e)
 {
     try
     {
         GXDLMSIecTwistedPairSetup target = Target as GXDLMSIecTwistedPairSetup;
         List <sbyte> tabis = new List <sbyte>();
         if (target.Tabis != null)
         {
             tabis.AddRange(target.Tabis);
         }
         GXTextDlg dlg = new GXTextDlg("TAB(i)", "TAB(i)", "", typeof(sbyte));
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             string       tmp = dlg.GetValue();
             ListViewItem li  = TabisList.Items.Add(tmp);
             tabis.Add(sbyte.Parse(tmp));
             errorProvider1.SetError(TabisList, Properties.Resources.ValueChangedTxt);
             target.Tabis = tabis.ToArray();
             Target.UpdateDirty(5, target.Tabis);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// Add primary addresses.
 /// </summary>
 private void PrimaryAddressesAddBtn_Click(object sender, EventArgs e)
 {
     try
     {
         GXDLMSIecTwistedPairSetup target = Target as GXDLMSIecTwistedPairSetup;
         List <byte> addresses            = new List <byte>();
         if (target.PrimaryAddresses != null)
         {
             addresses.AddRange(target.PrimaryAddresses);
         }
         GXTextDlg dlg = new GXTextDlg("Primary Address", "Primary Address", "", typeof(byte));
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             byte         tmp = byte.Parse(dlg.GetValue());
             ListViewItem li  = PrimaryAddressesList.Items.Add(tmp.ToString());
             addresses.Add(tmp);
             errorProvider1.SetError(PrimaryAddressesList, Properties.Resources.ValueChangedTxt);
             target.PrimaryAddresses = addresses.ToArray();
             Target.UpdateDirty(4, target.PrimaryAddresses);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #6
0
        public void OnValueChanged(int index, object value, bool user, bool connected)
        {
            GXDLMSIecTwistedPairSetup target = Target as GXDLMSIecTwistedPairSetup;

            if (index == 4)
            {
                PrimaryAddressesList.Items.Clear();
                if (target.PrimaryAddresses != null)
                {
                    foreach (byte it in target.PrimaryAddresses)
                    {
                        PrimaryAddressesList.Items.Add(it.ToString());
                    }
                }
            }
            else if (index == 5)
            {
                TabisList.Items.Clear();
                if (target.Tabis != null)
                {
                    foreach (byte it in target.Tabis)
                    {
                        TabisList.Items.Add(it.ToString());
                    }
                }
            }
            else
            {
                throw new IndexOutOfRangeException("index");
            }
        }