private bool group_add(string _name, bool _add_to_data_bank) { TreeNode[] nodes_arr = TreeViewPatterns.Nodes.Find(_name, true); if (nodes_arr.Length > 0) { MainForm.message_box("An item with the same name (" + _name + ") is already exist!", "Group Adding Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } TreeNode node = new TreeNode(_name); node.Name = _name; node.ContextMenuStrip = ContextMenuStripGroupItem; TreeViewPatterns.BeginUpdate(); { TreeViewPatterns.Nodes.Add(node); TreeViewPatterns.SelectedNode = node; } TreeViewPatterns.EndUpdate(); if (_add_to_data_bank) { m_data.patterns_data.Add(_name, new List <pattern_data>()); } return(true); }
private void update_tree_view() { TreeViewPatterns.BeginUpdate(); { TreeViewPatterns.Nodes.Clear(); } TreeViewPatterns.EndUpdate(); int ptrns_cnt = 0; if (m_data != null) { foreach (var key in m_data.patterns_data.Keys) { group_add(key, false); (m_data.patterns_data[key] as List <pattern_data>).ForEach(delegate(pattern_data _pattern) { ++ptrns_cnt; pattern_add(key, _pattern, false); }); } } // on Linux TreeViewPatterns.SelectedNode is not reset when clearing nodes if (ptrns_cnt > 0) { reset_active_pattern(); } else { TreeViewPatterns.SelectedNode = null; } }
public bool group_delete(string _name) { if (TreeViewPatterns.Nodes.ContainsKey(_name)) { TreeNode[] nodes_arr = TreeViewPatterns.Nodes.Find(_name, true); if (nodes_arr.Length > 0) { if (nodes_arr[0].FirstNode != null) { if (MainForm.message_box("The selected group is not empty!\n\nRemove all child patterns?", "Delete Group", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { TreeViewPatterns.BeginUpdate(); { TreeViewPatterns.Nodes.RemoveByKey(_name); } TreeViewPatterns.EndUpdate(); } else { return(false); } } else { TreeViewPatterns.BeginUpdate(); { TreeViewPatterns.Nodes.RemoveByKey(_name); } TreeViewPatterns.EndUpdate(); } if (m_data.patterns_data.ContainsKey(_name)) { List <pattern_data> patterns = m_data.patterns_data[_name]; m_data.patterns_data.Remove(_name); if (patterns != null) { patterns.ForEach(delegate(pattern_data _pattern) { _pattern.reset(); }); } return(true); } } } return(false); }
public bool pattern_add(string _grp_name, pattern_data _pattern, bool _add_to_data_bank) { TreeNode[] nodes_arr = TreeViewPatterns.Nodes.Find(_pattern.name, true); if (nodes_arr.Length > 0) { MainForm.message_box("A pattern with the same name (" + _pattern.name + ") is already exist!", "Pattern Adding Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } nodes_arr = TreeViewPatterns.Nodes.Find(_grp_name, true); if (nodes_arr.Length > 0) { if (_add_to_data_bank) { List <pattern_data> patterns = m_data.patterns_data[_grp_name]; if (patterns != null) { patterns.Add(_pattern); } } TreeNode node = new TreeNode(_pattern.name); node.Name = _pattern.name; node.ContextMenuStrip = ContextMenuStripPatternItem; TreeViewPatterns.BeginUpdate(); { nodes_arr[0].Nodes.Add(node); nodes_arr[0].Expand(); TreeViewPatterns.SelectedNode = node; } TreeViewPatterns.EndUpdate(); return(true); } return(false); }
public bool pattern_delete(string _pattern_name, string _grp_name) { TreeNode[] nodes_arr = TreeViewPatterns.Nodes.Find(_pattern_name, true); if (nodes_arr.Length > 0) { List <pattern_data> patterns = m_data.patterns_data[_grp_name]; if (patterns != null) { pattern_data pattern; for (int ent_n = 0; ent_n < patterns.Count; ent_n++) { pattern = patterns[ent_n]; if (pattern.name == _pattern_name) { pattern.reset(); patterns.Remove(pattern); break; } } } TreeNode node = new TreeNode(_pattern_name); node.Name = _pattern_name; node.ContextMenuStrip = ContextMenuStripPatternItem; TreeViewPatterns.BeginUpdate(); { nodes_arr[0].Remove(); } TreeViewPatterns.EndUpdate(); return(true); } return(false); }