private void LoadKABSCommand() { TreeViewItem item = new TreeViewItem(); string[] keys = new string[50]; string[] values = new string[50]; string[] sections = new string[100]; CMDTree = new ObservableCollection <CMDNode>(); IniOperations.GetAllSectionNames(out sections, "config/KABS_COMMAND.ini"); int i = 0, j = 0; for (i = 0; i < sections.Length; i++) { IniOperations.GetAllKeyValues(sections[i], out keys, out values, "config/KABS_COMMAND.ini"); CMDNode node = new CMDNode() { NodeName = sections[i], ID = 1 }; for (j = 0; j < keys.Length; j++) { node.NextNode.Add(new CMDNode { NodeName = keys[j], ID = 2 }); SP2.SendBox.AddItem(keys[j]); } CMDTree.Add(node); } treeView.ItemsSource = CMDTree; }
private void treeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { var tree = sender as TreeView; CMDNode item = tree.SelectedItem as CMDNode; if (item.ID == 2) { SP2.SendData(item.NodeName); } } catch { } }