private void OnSelectWMIClass(object sender, EventArgs e) { try { ArrayList strs = new ArrayList(50); //First, enumerate existing classes to initialize dialog Node[] children = GetNodeSite().GetChildNodes(); for (int i = 0; i < children.Length; i++) { if (children[i] is WMIClassNode) { strs.Add(((WMIClassNode)children[i]).pathNoServer); } } //get current server name ServerNode server = (ServerNode)GetNodeSite().GetParentNode(); String serverName = server.GetUNCName(); if (selectClassDlg == null) { selectClassDlg = new SelectWMIClassTreeDialog( serverName, this.ConnectAs, this.Password, ClassFilters.ConcreteData, //SchemaFilters.NoEvent|SchemaFilters.NoAbstract| SchemaFilters.NoSystem |SchemaFilters.NoAssoc, strs); } else { //updated selected classes list in the dialog: //to account for the case wheen some class node //was deleted UpdateSelectClassDialog(); ((SelectWMIClassTreeDialog)selectClassDlg).CleanUpPreviousSelections(); } DialogResult ret = ((SelectWMIClassTreeDialog)selectClassDlg).ShowDialog(); if (ret != DialogResult.OK) { return; } //inspect strs and add or delete child nodes as necessary UpdateChildren(((SelectWMIClassTreeDialog)selectClassDlg).SelectedClasses); } catch (Exception exc) { MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace)); } }
private void OnAddEventFilter(object sender, EventArgs e) { try { //get current server name ServerNode server = (ServerNode)GetNodeSite().GetParentNode(); String serverName = server.GetUNCName(); if (eventQueryDlg == null) { eventQueryDlg = new EventQueryDialog(serverName, this.connectAs, this.password); } DialogResult res = eventQueryDlg.ShowDialog(); if (res == DialogResult.Cancel) { return; } //Forming a unique query node label: //get all child names into a SortedList Node[] children = GetNodeSite().GetChildNodes(); SortedList childNames = new SortedList(children.Length); foreach (Node childNode in children) { childNames.Add(childNode.Label.ToLower(), null); } string newLabel = WMISys.GetString("WMISE_QueryNameBase", eventQueryDlg.SelectedClassName); string labelSeed = newLabel; //keep adding digits at the end to find a unique label UInt16 i = 1; while (childNames.Contains(newLabel.ToLower())) { newLabel = labelSeed + " " + i.ToString(); i++; } //add the node EventQueryNode newChild = new EventQueryNode(newLabel, serverName, eventQueryDlg.SelectedNS, eventQueryDlg.QueryString, connectAs, password); GetNodeSite().AddChild(newChild); } catch (Exception exc) { MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace)); } }