public void OnValueChanged(int index, object value, bool user, bool connected) { GXDLMSParameterMonitor target = Target as GXDLMSParameterMonitor; if (index == 2) { if (target.ChangedParameter != null && target.ChangedParameter.Target != null) { TargetTb.Text = target.ChangedParameter.Target.ToString(); IndexTb.Text = target.ChangedParameter.AttributeIndex.ToString(); ValueTb.Text = Convert.ToString(GXHelpers.ConvertFromDLMS(target.ChangedParameter.Value, DataType.None, DataType.None, true, false)); } else { TargetTb.Text = ""; IndexTb.Text = ""; ValueTb.Text = ""; } } else if (index == 4) { ParametersLV.Items.Clear(); if (target.Parameters != null) { foreach (GXDLMSTarget it in target.Parameters) { ListViewItem li = ParametersLV.Items.Add(it.Target.ToString()); li.SubItems.Add(it.AttributeIndex.ToString()); li.Tag = it; } } } }
void OnShowDlg(GXActionArgs arg, GXDLMSTargetObjectDlg dlg, GXDLMSTarget it) { if (InvokeRequired) { BeginInvoke(new ShowDlgEventHandler(OnShowDlg), arg, dlg, it).AsyncWaitHandle.WaitOne(); } else { bool remove = false; ListViewItem li = null; GXDLMSParameterMonitor target = Target as GXDLMSParameterMonitor; if (it == null) { remove = true; if (ParametersLV.SelectedItems.Count != 1) { arg.Handled = true; return; } else { li = ParametersLV.SelectedItems[0]; it = (GXDLMSTarget)li.Tag; dlg.Target = it.Target; dlg.Index = it.AttributeIndex; } } if (dlg.ShowDialog(this) == DialogResult.OK) { if (!remove) { it.Target = dlg.Target; it.AttributeIndex = dlg.Index; li = ParametersLV.Items.Add(it.Target.ToString()); li.SubItems.Add(it.AttributeIndex.ToString()); li.Tag = it; arg.Value = target.Insert(arg.Client, it); } else { arg.Value = target.Delete(arg.Client, it); li.Remove(); } } else { arg.Handled = true; } } }