private void contribTree_AfterSelect(object sender, TreeViewEventArgs e) { if (contribTree.SelectedNode == null) { contribTree.SelectedNode = lastValidNode; } int idxnew; if (contribTree.SelectedNode.Tag == null) { idxnew = contribTree.SelectedNode.Nodes[0].Index; } else { lastValidNode = contribTree.SelectedNode; idxnew = lastValidNode.Index; } if (currentContrib == lastValidNode.Tag) { return; } currentContrib = (RoadContribution)lastValidNode.Tag; description.Text = currentContrib.oneLineDescription; level.Text = ToStyleDescription(currentContrib.style); toolTip.SetToolTip(this.description, this.description.Text); currentContrib.PreviewPatternIdx = currentPattern; this.Text = type.name; updatePreview(); }
private void makeContribTree() { RoadContribution[] contribs = Core.plugins.roads; if (contribs.Length > 0) { currentContrib = contribs[0]; for (int idx = 0; idx < contribs.Length; idx++) { RoadContribution rc = contribs[idx]; //string[] path = rc.name.Split(new char[]{'(',')','i','j','/','\\'}); string[] path = rc.name.Split(new char[] { '(', ')', '/', '\\' }); TreeNodeCollection parent = contribTree.Nodes; TreeNode node = null; int m = path.Length - 1; for (int i = 0; i <= m; i++) { string label = path[i].Trim(); if (label.Length == 0) { continue; } bool find = false; foreach (TreeNode n in parent) { if (n.Text.Equals(label)) { find = true; node = n; break; } } if (!find) { node = new TreeNode(label); parent.Add(node); } if (node.Tag == null || m == i) { node.Tag = rc; } parent = node.Nodes; } lastValidNode = node; } } }