private void modelTree_DoubleClick(object sender, System.EventArgs e) { TreeNode selectedNode = this.modelTree.SelectedNode; if (selectedNode.Parent == null && selectedNode.Tag is DataModel) { modelProperties(this, e); } else { if (selectedNode.Parent.Tag is ModelFolder) { if (selectedNode.Tag is ModelClass) { ModelClass editClass = (ModelClass)selectedNode.Tag; // Bring the edit window to focus if there is already one attached to the field if (editClass.Editor != null) { ((ClassEditor)editClass.Editor).Focus(); return; } ClassEditor classEditor = new ClassEditor(editClass); classEditor.MdiParent = this.MdiParent; classEditor.Show(); } else if (selectedNode.Tag is ModelEnum) { ModelEnum editEnum = (ModelEnum)selectedNode.Tag; if (editEnum.Editor != null) { ((EnumEditor)editEnum.Editor).Focus(); return; } EnumEditor enumEditor = new EnumEditor(editEnum); enumEditor.MdiParent = this.MdiParent; enumEditor.Show(); } } } }
private void addEnum(object sender, System.EventArgs e) { TreeNode selectedNode; ModelFolder folder; selectedNode = modelTree.SelectedNode; // Find Current Folder while (selectedNode.Parent != null & !(selectedNode.Tag is ModelFolder)) { selectedNode = selectedNode.Parent; } if (selectedNode.Tag is ModelFolder) { folder = (ModelFolder)selectedNode.Tag; } else { return; } // Instantiate new class object ModelEnum newEnum = new ModelEnum(); newEnum.Name = "NewEnum"; newEnum.ParentModel = this.model; newEnum.Namespace = this.model.DefaultNamespace; folder.Items.Add(newEnum); // Add class object to DataTypeManager DataTypeManager.EnumTypes.Add(new EnumType(newEnum, null)); // Instantiate new class object editor EnumEditor newEnumEditor = new EnumEditor(newEnum); newEnumEditor.MdiParent = this.MdiParent; newEnumEditor.Show(); refreshTree(); }