public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { // BUG: the value of context.Instance should always be the entity itself, since the // domain property is defined on the Entity class. However, currently it is shape, if // you select it on the design surface. Code below works around this. PresentationElement pe = context.Instance as PresentationElement; if (pe != null) { //entity = pe.ModelElement as Entity; connection = pe.ModelElement as SchemaModelItemHasSchemaModelItem; if (connection != null) { selected = true; return(true); } else { selected = false; } return(false); } else { connection = context.Instance as SchemaModelItemHasSchemaModelItem; if (connection != null) { selected = true; return(true); } else { selected = false; } return(false); } //return connection != null ? true : false; }
/// <summary> /// Called when a SchemaModelItemHasSchemaModelItem relationship is created. /// </summary> /// <param name="e">Argument to event</param> public override void ElementAdded(ElementAddedEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } SchemaModelItemHasSchemaModelItem relationship = e.ModelElement as SchemaModelItemHasSchemaModelItem; if (relationship != null) { // M1: Get the diagram's (single) root class // M3: Expand to support arbirary roots with the help of the containment tree IList roots = relationship.Store.ElementDirectory.GetElements(SchemaModel.MetaClassGuid); if (roots.Count == 1) { SchemaModel root = roots[0] as SchemaModel; if (root != null) { Microsoft.VisualStudio.Modeling.Diagrams.Diagram.FixUpDiagram(root, relationship); } } } }