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(); }
private void close() { if (model != null) { foreach (ModelFolder folder in model.Folders) { foreach (object item in folder.Items) { if (item is ModelClass) { ModelClass c = (ModelClass)item; if (c.Editor != null) { ClassEditor editor = (ClassEditor)c.Editor; editor.Close(); } } else if (item is EnumEditor) { ModelEnum e = (ModelEnum)item; if (e.Editor != null) { EnumEditor editor = (EnumEditor)e.Editor; editor.Close(); } } } } // // Clear DataTypes! // DataTypeManager.Clear(); mExplorer.Clear(); } }