private void RemoveDomain(DataDomain domain) { if (domain.Entities.Length != 0) { if (MessageBox.Show(domain.Entities.Length.ToString() + " " + (domain.Entities.Length == 1 ? "entity" : "entities") + " exists within this namespace and will removed from scope." + Environment.NewLine + "No further code will be generated for " + (domain.Entities.Length == 1 ? "this entity" : "these entities") + "." + Environment.NewLine + Environment.NewLine + "Are you sure you want to continue?", "Remove Namespace", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } // Remove the entities from the domain List <DataEntity> entities = domain.Entities.ToList(); entities.ForEach(entity => entity.CodeDomain = null); entities.ForEach(entity => entity.Save()); // Remove the entities from the domain tree foreach (TreeNode entity in this.DomainTree.SelectedNode.Nodes) { this.AddTreeNode(this.RootNode.Nodes, entity); } // Remove the domain from the database this.DomainTree.SelectedNode.Remove(); domain.Name = null; domain.Save(); // Refresh the current database this.CurrentDatabase.Refresh(); }
private void AddDomain(String name) { // Create a new domain within the database DataDomain domain = new DataDomain(this.CurrentDatabase); domain.Identifier = name; domain.Name = name; domain.Save(); // Add the tree node to the tree this.AddTreeNode(this.DomainTree.Nodes, domain); this.DomainTree.SelectedNode = this.DomainTree.Nodes[domain.Identifier]; // Refresh the current database this.CurrentDatabase.Refresh(); }