private void visitOneNode(LACTreeNode node, int level) { if (!node.IsPluginNode) { return; } string str = node.Text; if (node.Text.Contains("(")) { str = node.Text.Substring(0, node.Text.IndexOf('(')); } Logger.Log( "Node: " + node.Text + " Level: " + level, Logger.manageLogLevel); AddedPluginInfo pluginInfo = null; //Tried to avoid referring the tree node from the Console Root. LACTreeNode pluginnode = node.DeepCopy() as LACTreeNode; if (level > 0) { char[] spacing = new char[level * 2]; for (int i = 0; i < level * 2; i++) { spacing[i] = ' '; } pluginInfo = new AddedPluginInfo(string.Concat(new string(spacing), str), level, nodeindex, pluginnode); this.PluginComboBox.Items.Add(pluginInfo); } else { pluginInfo = new AddedPluginInfo(str, level, nodeindex, pluginnode); this.PluginComboBox.Items.Add(pluginInfo); } nodeindex++; node.Tag = pluginnode.Tag = this.PluginComboBox.Items.Count - 1; foreach (LACTreeNode n in node.Nodes) { if (n.IsPluginNode) { pluginnode.Nodes.Add(n.DeepCopy()); visitOneNode(n, level + 1); } } }
private void pluginComboBox_selectedIndexChanged(object sender, EventArgs e) { if (PluginComboBox.SelectedIndex < 0 || pluginCombobox_selectedIndex == PluginComboBox.SelectedIndex) { return; } pluginCombobox_selectedIndex = PluginComboBox.SelectedIndex; try { AddedPluginInfo obj = PluginComboBox.Items[pluginCombobox_selectedIndex] as AddedPluginInfo; LACTreeNode node = obj.node as LACTreeNode; showNode(GetIndexNode(_rootNode, (int)node.Tag)); } catch (Exception ex) { Logger.LogException("PluginStandalonePage.pluginComboBox_selectedIndexChanged", ex); } }
private void Removebtn_Click(object sender, EventArgs e) { if (ChosenPluginlistView.SelectedItems.Count == 0) { return; } try { ListViewItem removeItem = ChosenPluginlistView.SelectedItems[0]; // add to removedPlugins _removedPlugins.Add(removeItem.Tag as LACTreeNode); int idx = ChosenPluginlistView.SelectedItems[0].Index; if (idx >= 0) { List <ListViewItem> lvItemList = new List <ListViewItem>(); int index = 0; for (index = 0; index < ChosenPluginlistView.Items.Count; index++) { if (index != idx) { lvItemList.Add(ChosenPluginlistView.Items[index]); } } ListViewItem[] lvItemArr = new ListViewItem[lvItemList.Count]; lvItemList.CopyTo(lvItemArr); ChosenPluginlistView.Items.Clear(); ChosenPluginlistView.Items.AddRange(lvItemArr); Removebtn.Enabled = false; Aboutbtn.Enabled = false; } foreach (AddedPluginInfo obj in PluginComboBox.Items) { if (obj.nodeindex == (int)((LACTreeNode)removeItem.Tag).Tag) { PluginComboBox.Items.Remove(obj); AddedPluginInfo parentnodeInfo = PluginComboBox.Items[pluginCombobox_selectedIndex] as AddedPluginInfo; LACTreeNode n = parentnodeInfo.node as LACTreeNode; if (n.Nodes.Count > obj.nodeindex) { n.Nodes.RemoveAt(obj.nodeindex); } break; } } } catch (Exception ex) { Logger.LogException("PluginStandalonePage.Removebtn_Click", ex); } lblDescription.Text = string.Empty; _parentDlg.addedPlugins = _addedPlugins; _parentDlg.removedplugins = _removedPlugins; }
private void visitOneNode(LACTreeNode node, int level) { if (!node.IsPluginNode) return; string str = node.Text; if (node.Text.Contains("(")) str = node.Text.Substring(0, node.Text.IndexOf('(')); Logger.Log( "Node: " + node.Text + " Level: " + level, Logger.manageLogLevel); AddedPluginInfo pluginInfo = null; //Tried to avoid referring the tree node from the Console Root. LACTreeNode pluginnode = node.DeepCopy() as LACTreeNode; if (level > 0) { char[] spacing = new char[level * 2]; for (int i = 0; i < level * 2; i++) spacing[i] = ' '; pluginInfo = new AddedPluginInfo(string.Concat(new string(spacing), str), level, nodeindex, pluginnode); this.PluginComboBox.Items.Add(pluginInfo); } else { pluginInfo = new AddedPluginInfo(str, level, nodeindex, pluginnode); this.PluginComboBox.Items.Add(pluginInfo); } nodeindex++; node.Tag = pluginnode.Tag = this.PluginComboBox.Items.Count - 1; foreach (LACTreeNode n in node.Nodes) { if (n.IsPluginNode) { pluginnode.Nodes.Add(n.DeepCopy()); visitOneNode(n, level + 1); } } }