public void OnValueChanged(int attributeID, object value) { GXDLMSAutoAnswer target = Target as GXDLMSAutoAnswer; if (attributeID == 3) { ListeningWindowLV.Items.Clear(); if (target.ListeningWindow != null) { foreach (var it in target.ListeningWindow) { ListViewItem li = ListeningWindowLV.Items.Add(it.Key.ToString()); li.SubItems.Add(GXHelpers.ConvertDLMS2String(it.Value.ToString())); } } } else if (attributeID == 5) { if (target.NumberOfCalls == 0) { NumberOfCallsTB.Value = "No limit."; } else { NumberOfCallsTB.Value = target.NumberOfCalls.ToString(); } } else if (attributeID == 6) { if (target.NumberOfRingsInListeningWindow == 0) { this.RingCountInWindowTB.Text = "No connect."; } else { this.RingCountInWindowTB.Text = target.NumberOfRingsInListeningWindow.ToString(); } if (target.NumberOfRingsOutListeningWindow == 0) { this.RingCountOutOfWindowTB.Text = "No connect."; } else { this.RingCountOutOfWindowTB.Text = target.NumberOfRingsOutListeningWindow.ToString(); } } }
void OnUpdateValue(object value) { string str; if (value != null && value.GetType().IsArray) { str = Convert.ToString(GXDLMS.Common.GXHelpers.ConvertFromDLMS(value, DataType.None, DataType.None, true)); } else { str = GXHelpers.ConvertDLMS2String(value); } if (Type == GXValueFieldType.TextBox) { textBox1.TextChanged -= new EventHandler(textBox1_TextChanged); this.textBox1.Text = str; textBox1.TextChanged += new EventHandler(textBox1_TextChanged); } else if (Type == GXValueFieldType.CompoBox) { if (comboBox1.Items.Count != 0) { if (value != null) { foreach (GXObisValueItem it in Items) { if (it.Value.Equals(Convert.ChangeType(value, it.Value.GetType()))) { int pos = comboBox1.Items.IndexOf(it.UIValue); if (pos != -1) { comboBox1.SelectedIndexChanged -= new EventHandler(comboBox1_SelectedIndexChanged); comboBox1.SelectedIndex = pos; comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); return; } } } } else { comboBox1.SelectedIndexChanged -= new EventHandler(comboBox1_SelectedIndexChanged); comboBox1.SelectedIndex = -1; comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); return; } } this.comboBox1.Text = str; } else if (Type == GXValueFieldType.ListBox) { this.listBox1.Items.Clear(); if (value is Array) { foreach (Array it in (Array)value) { List <byte> arr = new List <byte>(); foreach (object item in it) { if (item is Array) { foreach (byte b in (Array)item) { arr.Add(b); } } else { arr.Add((byte)item); } } this.listBox1.Items.Add(ASCIIEncoding.ASCII.GetString((byte[])arr.ToArray())); } } } else if (Type != GXValueFieldType.TextBox) { throw new InvalidExpressionException(); } }