private void loadDictionary() { items = new SortedSet <API.Business.DictionaryItem>(new DictionaryItemComparer()); nodes = new Dictionary <int, DicItem>(); foreach (var d in this.featureDef.DictionaryList) { items.Add(d); } foreach (var d in items) { DictionaryTreeNode node = new DictionaryTreeNode(this.featureDef, d); if (d.Parent == null) { this.Nodes.Add(node); } else if (this.nodes.ContainsKey(d.Parent.ID)) { this.nodes[d.Parent.ID].Node.Nodes.Add(node); } else { } this.nodes.Add(d.ID, new DicItem() { Node = node, Item = d }); } }
private void deleteGroupButton_Click(object sender, EventArgs e) { if (treeView.SelectedNode is FeatureTreeNode) { FeatureTreeNode node = (FeatureTreeNode)treeView.SelectedNode; if (node.FeatureDef.ID != 0) { DialogResult result = MessageBox.Show("Czy napewno chcesz usunąć grupę", "EnovaTools", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { ((Enova.Business.Old.Core.IDeleteRecord)node.FeatureDef).DeleteRecord(); } //LoadFeatures(Enova.Business.Core.ContextManager.DataContext); if (node.Parent == null) { treeView.Nodes.Remove(node); } else { node.Parent.Nodes.Remove(node); } this.treeView.SelectedNode = treeView.Nodes[0]; } } else { DialogResult result = MessageBox.Show("Chy napewno chcesz usunąć podgrupę", "EnovaTools", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { DictionaryTreeNode node = (DictionaryTreeNode)treeView.SelectedNode; TreeNode parent = node.Parent; ((Enova.Business.Old.Core.IDeleteRecord)node.Dictionary).DeleteRecord(); //LoadFeatures(Enova.Business.Core.ContextManager.DataContext); parent.Nodes.Remove(node); treeView.SelectedNode = parent; } } }
private void addGroup(bool isSubGroup, FeatureTypeNumber?type) { Enova.Business.Old.Forms.FeatureEditForm form = new Enova.Business.Old.Forms.FeatureEditForm(isSubGroup); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrEmpty(form.Value)) { EnovaContext dc = Enova.Business.Old.Core.ContextManager.DataContext; if (treeView.SelectedNode is FeatureTreeNode && ((FeatureTreeNode)treeView.SelectedNode).FeatureDef.ID == 0) { if (dc.FeatureDefs.Any(f => f.Name == form.Value)) { MessageBox.Show("Istnieje już grupa o takiej nazwie.", "EnovaTools", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FeatureTreeNode node = (FeatureTreeNode)treeView.SelectedNode; FeatureDef featureDef = new FeatureDef(TableName, form.Value, type.Value); ((Enova.Business.Old.Core.IContextSaveChanges)featureDef).SaveChanges(dc); FeatureTreeNode newNode = new FeatureTreeNode(featureDef); treeView.Nodes.Add(newNode); treeView.SelectedNode = newNode; } else { Dictionary parent = null; FeatureDef featureDef = null; TreeNode parentNode = null; if (treeView.SelectedNode is FeatureTreeNode) { featureDef = ((FeatureTreeNode)treeView.SelectedNode).FeatureDef; parentNode = treeView.SelectedNode; } else { featureDef = ((DictionaryTreeNode)treeView.SelectedNode).FeatureDef; if (featureDef.IsTree) { parent = ((DictionaryTreeNode)treeView.SelectedNode).Dictionary; parentNode = treeView.SelectedNode; } else { parentNode = treeView.SelectedNode; if (parentNode.Parent != null) { parentNode = parentNode.Parent; } } } Dictionary dictionary = new Dictionary(parent, "F." + featureDef.Dictionary, form.Value); ((Enova.Business.Old.Core.ISaveChanges)dictionary).SaveChanges(); DictionaryTreeNode newNode = new DictionaryTreeNode(dictionary, featureDef); parentNode.Nodes.Add(newNode); treeView.SelectedNode = newNode; } } }