private void LoadSharedParameters() { TreeViewParameters.Nodes.Clear(); // fresh list if (RbtByGroup.Checked == true) // load by group { SortedDictionary <string, List <Definition> > parametersByBroup = Data.Helpers.GetParameterByGroup(m_app); if (string.IsNullOrEmpty(TxbFilterParam.Text)) // filter is empty { foreach (KeyValuePair <string, List <Definition> > pair in parametersByBroup) { List <Definition> defList = pair.Value; foreach (Definition def in defList) { if (!TreeViewParameters.Nodes.ContainsKey(pair.Key.ToString())) // group doesn´t exist { TreeViewParameters.Nodes.Add(pair.Key.ToString(), pair.Key.ToString()); TreeNode childNode = TreeViewParameters.Nodes[pair.Key.ToString()].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } else // group exists { TreeNode childNode = TreeViewParameters.Nodes[pair.Key.ToString()].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } } } } else // filter contains text { foreach (KeyValuePair <string, List <Definition> > pair in parametersByBroup) { foreach (Definition def in pair.Value) { if (def.Name.ToLower().Contains(TxbFilterParam.Text.ToLower())) // contains text { if (!TreeViewParameters.Nodes.ContainsKey(pair.Key)) // group doesn´t exist { TreeViewParameters.Nodes.Add(pair.Key, pair.Key); TreeNode childNode = TreeViewParameters.Nodes[pair.Key].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } else // group exists { TreeNode childNode = TreeViewParameters.Nodes[pair.Key].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } //TreeViewParameters.Sort(); } else { continue; } } } } } else // load by type { SortedDictionary <string, List <Definition> > parametersByType = Data.Helpers.GetParameterByType(m_app); foreach (KeyValuePair <string, List <Definition> > pair in parametersByType) { foreach (Definition def in pair.Value) { if (string.IsNullOrEmpty(TxbFilterParam.Text)) // filter is empty { if (!TreeViewParameters.Nodes.ContainsKey(pair.Key)) // type doesn´t exist { TreeViewParameters.Nodes.Add(pair.Key, pair.Key); TreeNode childNode = TreeViewParameters.Nodes[pair.Key].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } else // type exists { TreeNode childNode = TreeViewParameters.Nodes[pair.Key].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } //TreeViewParameters.Sort(); } else // filter contains text { if (def.Name.ToLower().Contains(TxbFilterParam.Text.ToLower())) // contains text { if (!TreeViewParameters.Nodes.ContainsKey(pair.Key)) // type doesn´t exist { TreeViewParameters.Nodes.Add(pair.Key, pair.Key); TreeNode childNode = TreeViewParameters.Nodes[pair.Key].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } else // type exists { TreeNode childNode = TreeViewParameters.Nodes[pair.Key].Nodes.Add(def.Name, def.Name); childNode.Tag = def; // set Definition as object containing data } //TreeViewParameters.Sort(); } else { continue; } } } } } // expand all when searching if (!string.IsNullOrEmpty(TxbFilterParam.Text)) { TreeViewParameters.ExpandAll(); } }
private void BtnExpandAll_Click(object sender, EventArgs e) { TreeViewParameters.ExpandAll(); }
private void BtnCollapseAll_Click(object sender, EventArgs e) { TreeViewParameters.CollapseAll(); }