/// <summary> /// Enables condition based notifications for the area or source. /// </summary> private void SetEnabledStateMI_Click(object sender, System.EventArgs e) { try { // find current selection. OpcClientSdk.Ae.TsCAeBrowseElement selection = null; if (typeof(OpcClientSdk.Ae.TsCAeBrowseElement).IsInstanceOfType(BrowseTV.SelectedNode.Tag)) { selection = (OpcClientSdk.Ae.TsCAeBrowseElement)BrowseTV.SelectedNode.Tag; } else if (!typeof(TsCAeServer).IsInstanceOfType(BrowseTV.SelectedNode.Tag)) { return; } // prompt user. bool enabled = false; bool result = new SetEnabledStateDlg().ShowDialog( m_server, selection, out enabled, ref m_recursive); if (!result) { return; } // apply changes. ArrayList elements = new ArrayList(); if (m_recursive) { FindBrowseElements(BrowseTV.SelectedNode, elements); } else { elements.Add(selection); } // seperate into areas and sources. ArrayList areas = new ArrayList(); ArrayList sources = new ArrayList(); foreach (OpcClientSdk.Ae.TsCAeBrowseElement element in elements) { if (element.NodeType == OpcClientSdk.Ae.TsCAeBrowseType.Area) { areas.Add(element.QualifiedName); } else { sources.Add(element.QualifiedName); } } // call server. if (enabled) { m_server.EnableConditionByArea((string[])areas.ToArray(typeof(string))); m_server.EnableConditionBySource((string[])sources.ToArray(typeof(string))); } else { m_server.DisableConditionByArea((string[])areas.ToArray(typeof(string))); m_server.DisableConditionBySource((string[])sources.ToArray(typeof(string))); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }