/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { if (!typeCollection.TargetNamespace.EndsWith("obj")) { continue; } Namespace = typeCollection.TargetNamespace; TypeCollection = typeCollection; Schema.Initialize(typeCollection); foreach (DomNodeType nodeType in typeCollection.GetNodeTypes()) { nodeType.SetIdAttribute("name"); } // Register base interfaces Schema.vertexArray_array.Type.Define(new ExtensionInfo <DataSet>()); Schema.vertexArray_primitives.Type.Define(new ExtensionInfo <PrimitiveSet>()); Schema.meshType.Type.Define(new ExtensionInfo <Mesh>()); Schema.nodeType.Type.Define(new ExtensionInfo <DomResource>()); Schema.nodeType.Type.Define(new ExtensionInfo <Node>()); Schema.shaderType.Type.Define(new ExtensionInfo <Shader>()); break; } }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // There's no document type, so we will use the timeline type. Schema.timelineType.Type.Define(new ExtensionInfo <TimelineDocument>()); Schema.timelineType.Type.Define(new ExtensionInfo <TimelineContext>()); Schema.timelineType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); // register extensions Schema.timelineType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); Schema.timelineType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.timelineType.Type.Define(new ExtensionInfo <TimelineValidator>()); // register the timeline model interfaces Schema.timelineType.Type.Define(new ExtensionInfo <Timeline>()); Schema.groupType.Type.Define(new ExtensionInfo <Group>()); Schema.trackType.Type.Define(new ExtensionInfo <Track>()); Schema.intervalType.Type.Define(new ExtensionInfo <Interval>()); Schema.eventType.Type.Define(new ExtensionInfo <BaseEvent>()); Schema.keyType.Type.Define(new ExtensionInfo <Key>()); Schema.markerType.Type.Define(new ExtensionInfo <Marker>()); Schema.timelineRefType.Type.Define(new ExtensionInfo <TimelineReference>()); // the timeline schema defines only one type collection break; } }
public CustomDomXmlWriter(Uri documentRoot, XmlSchemaTypeCollection typeCollection) : base(typeCollection) { _documentRoot = documentRoot; PreserveSimpleElements = true; PersistDefaultAttributes = true; }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { winGuiCommonDataType.Type = typeCollection.GetNodeType("winGuiCommonDataType"); winGuiCommonDataType.eventChild = winGuiCommonDataType.Type.GetChildInfo("event"); eventType.Type = typeCollection.GetNodeType("eventType"); eventType.nameAttribute = eventType.Type.GetAttributeInfo("name"); eventType.timeAttribute = eventType.Type.GetAttributeInfo("time"); eventType.durationAttribute = eventType.Type.GetAttributeInfo("duration"); eventType.resourceChild = eventType.Type.GetChildInfo("resource"); resourceType.Type = typeCollection.GetNodeType("resourceType"); resourceType.nameAttribute = resourceType.Type.GetAttributeInfo("name"); resourceType.sizeAttribute = resourceType.Type.GetAttributeInfo("size"); resourceType.compressedAttribute = resourceType.Type.GetAttributeInfo("compressed"); animationResourceType.Type = typeCollection.GetNodeType("animationResourceType"); animationResourceType.nameAttribute = animationResourceType.Type.GetAttributeInfo("name"); animationResourceType.sizeAttribute = animationResourceType.Type.GetAttributeInfo("size"); animationResourceType.compressedAttribute = animationResourceType.Type.GetAttributeInfo("compressed"); animationResourceType.tracksAttribute = animationResourceType.Type.GetAttributeInfo("tracks"); animationResourceType.durationAttribute = animationResourceType.Type.GetAttributeInfo("duration"); geometryResourceType.Type = typeCollection.GetNodeType("geometryResourceType"); geometryResourceType.nameAttribute = geometryResourceType.Type.GetAttributeInfo("name"); geometryResourceType.sizeAttribute = geometryResourceType.Type.GetAttributeInfo("size"); geometryResourceType.compressedAttribute = geometryResourceType.Type.GetAttributeInfo("compressed"); geometryResourceType.bonesAttribute = geometryResourceType.Type.GetAttributeInfo("bones"); geometryResourceType.verticesAttribute = geometryResourceType.Type.GetAttributeInfo("vertices"); geometryResourceType.primitiveTypeAttribute = geometryResourceType.Type.GetAttributeInfo("primitiveType"); winGuiCommonDataRootElement = typeCollection.GetRootElement("winGuiCommonData"); }
public TimelineXmlWriter(XmlSchemaTypeCollection typeCollection) : base(typeCollection) { // By default, attributes are not persisted if they have their default values. // Set PersistDefaultAttributes to true to persist these attributes. This might // be useful if another app will consume the XML file without a schema file. //PersistDefaultAttributes = true; }
protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions Schema.storyType.Type.Define(new ExtensionInfo <Story>()); Schema.storyType.Type.Define(new ExtensionInfo <StoryDocument>()); Schema.storyType.Type.Define(new ExtensionInfo <StoryContext>()); Schema.storyType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.storyType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); Schema.storyType.Type.Define(new ExtensionInfo <DomNodeQueryable>()); Schema.settingsType.Type.Define(new ExtensionInfo <Settings>()); Schema.settingsType.Type.Define(new ExtensionInfo <CharacterSettingsContext>()); Schema.characterType.Type.Define(new ExtensionInfo <Character>()); // Enable metadata driven property editing for events and resources var creator = new AdapterCreator <CustomTypeDescriptorNodeAdapter>(); Schema.characterType.Type.AddAdapterCreator(creator); Schema.characterType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.characterType.nameAttribute, null, "Name".Localize(), false), new AttributePropertyDescriptor( "Alternative Names".Localize(), Schema.characterType.altNamesAttribute, null, "List of Alternative Names".Localize(), false, new StringArrayEditor()), new AttributePropertyDescriptor( "Age".Localize(), Schema.characterType.ageAttribute, null, "Age".Localize(), false), })); } }
protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_typeCollection = typeCollection; SkinSchema.Initialize(typeCollection); SkinSchema.skinType.Type.Define(new ExtensionInfo <SkinDocument>()); SkinSchema.skinType.Type.Define(new ExtensionInfo <SkinEditingContext>()); SkinSchema.skinType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); SkinSchema.styleType.Type.Define(new ExtensionInfo <SkinStyleProperties>()); break; } }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { timelineType.Type = typeCollection.GetNodeType("timelineType"); timelineType.groupChild = timelineType.Type.GetChildInfo("group"); timelineType.markerChild = timelineType.Type.GetChildInfo("marker"); timelineType.timelineRefChild = timelineType.Type.GetChildInfo("timelineRef"); groupType.Type = typeCollection.GetNodeType("groupType"); groupType.nameAttribute = groupType.Type.GetAttributeInfo("name"); groupType.expandedAttribute = groupType.Type.GetAttributeInfo("expanded"); groupType.trackChild = groupType.Type.GetChildInfo("track"); trackType.Type = typeCollection.GetNodeType("trackType"); trackType.nameAttribute = trackType.Type.GetAttributeInfo("name"); trackType.intervalChild = trackType.Type.GetChildInfo("interval"); trackType.keyChild = trackType.Type.GetChildInfo("key"); intervalType.Type = typeCollection.GetNodeType("intervalType"); intervalType.startAttribute = intervalType.Type.GetAttributeInfo("start"); intervalType.descriptionAttribute = intervalType.Type.GetAttributeInfo("description"); intervalType.nameAttribute = intervalType.Type.GetAttributeInfo("name"); intervalType.lengthAttribute = intervalType.Type.GetAttributeInfo("length"); intervalType.colorAttribute = intervalType.Type.GetAttributeInfo("color"); eventType.Type = typeCollection.GetNodeType("eventType"); eventType.startAttribute = eventType.Type.GetAttributeInfo("start"); eventType.descriptionAttribute = eventType.Type.GetAttributeInfo("description"); keyType.Type = typeCollection.GetNodeType("keyType"); keyType.startAttribute = keyType.Type.GetAttributeInfo("start"); keyType.descriptionAttribute = keyType.Type.GetAttributeInfo("description"); keyType.specialEventAttribute = keyType.Type.GetAttributeInfo("specialEvent"); markerType.Type = typeCollection.GetNodeType("markerType"); markerType.startAttribute = markerType.Type.GetAttributeInfo("start"); markerType.descriptionAttribute = markerType.Type.GetAttributeInfo("description"); markerType.nameAttribute = markerType.Type.GetAttributeInfo("name"); markerType.colorAttribute = markerType.Type.GetAttributeInfo("color"); timelineRefType.Type = typeCollection.GetNodeType("timelineRefType"); timelineRefType.nameAttribute = timelineRefType.Type.GetAttributeInfo("name"); timelineRefType.startAttribute = timelineRefType.Type.GetAttributeInfo("start"); timelineRefType.descriptionAttribute = timelineRefType.Type.GetAttributeInfo("description"); timelineRefType.colorAttribute = timelineRefType.Type.GetAttributeInfo("color"); timelineRefType.refAttribute = timelineRefType.Type.GetAttributeInfo("ref"); timelineRootElement = typeCollection.GetRootElement("timeline"); }
protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { NameSpace = typeCollection.TargetNamespace; TypeCollection = typeCollection; DotaObjectsSchema.Initialize(TypeCollection); // register UI adapters as extensions on the DOM data // Register adapters for the Documents //Register the adapters for the Project object model DotaObjectsSchema.ProjectType.Type.Define(new ExtensionInfo <Project.AddonProject>()); DotaObjectsSchema.FileType.Type.Define(new ExtensionInfo <Project.ProjectFile>()); DotaObjectsSchema.FolderType.Type.Define(new ExtensionInfo <Project.ProjectFolder>()); DotaObjectsSchema.TextFileType.Type.Define(new ExtensionInfo <Project.TextFile>()); DotaObjectsSchema.KVDocumentType.Type.Define(new ExtensionInfo <Project.KVFile>()); DotaObjectsSchema.LuaDocumentType.Type.Define(new ExtensionInfo <Project.LuaFile>()); DotaObjectsSchema.VMTType.Type.Define(new ExtensionInfo <Project.VMTFile>()); // register adapters to define the Dota object model DotaObjectsSchema.DotaDataObjectType.Type.Define(new ExtensionInfo <DotaDataObject>()); DotaObjectsSchema.DotaBaseUnitType.Type.Define(new ExtensionInfo <DotaBaseUnit>()); DotaObjectsSchema.DotaUnitType.Type.Define(new ExtensionInfo <DotaUnit>()); DotaObjectsSchema.DotaHeroType.Type.Define(new ExtensionInfo <DotaHero>()); //Register the EditingContext DotaObjectsSchema.ProjectType.Type.Define(new ExtensionInfo <DotaEditingContext>()); DotaObjectsSchema.FileType.Type.Define(new ExtensionInfo <DotaEditingContext>()); DotaObjectsSchema.FolderType.Type.Define(new ExtensionInfo <DotaEditingContext>()); DotaObjectsSchema.TextFileType.Type.Define(new ExtensionInfo <DotaEditingContext>()); DotaObjectsSchema.KVDocumentType.Type.Define(new ExtensionInfo <DotaEditingContext>()); DotaObjectsSchema.LuaDocumentType.Type.Define(new ExtensionInfo <DotaEditingContext>()); DotaObjectsSchema.VMTType.Type.Define(new ExtensionInfo <DotaEditingContext>()); OverrideProperty(typeof(KeyValue), "Key"); OverrideProperty(typeof(KeyValue), "Children", new PropertyEditorAttribute(typeof(NestedCollectionEditor))); //OverrideProperty(typeof(KeyValue), "Children"); break; //Only one namespace } }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters on the DOM types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; bitBoxSchema.Initialize(typeCollection); bitBoxSchema.graphType.Type.Define(new ExtensionInfo <SceneEditingContext>()); bitBoxSchema.graphType.Type.Define(new ExtensionInfo <NodeEditingContext>()); bitBoxSchema.graphType.Type.Define(new ExtensionInfo <SceneDocument>()); //bitBoxSchema.graphType.Type.Define(new ExtensionInfo<UniqueIdValidator>()); // register extensions //bitBoxSchema.graphType.Type.Define(new ExtensionInfo<Game>()); //bitBoxSchema.graphType.Type.Define(new ExtensionInfo<ReferenceValidator>()); //bitBoxSchema.graphType.Type.Define(new ExtensionInfo<UniqueIdValidator>()); // //bitBoxSchema.nodeType.Type.Define(new ExtensionInfo<GameObject>()); //bitBoxSchema.MeshNode.Type.Define(new ExtensionInfo<Dwarf>()); //bitBoxSchema.MeshNode.Type.Define(new ExtensionInfo<MeshNode>()); var creator = new AdapterCreator <CustomTypeDescriptorNodeAdapter>(); foreach (DomNodeType type in GetNodeTypes(bitBoxSchema.nodeType.Type)) { type.AddAdapterCreator(creator); string defaultNodeName = type.Name.Split(':').Last().Replace("Node", ""); type.SetTag(new NodeTypePaletteItem(type, defaultNodeName, defaultNodeName.Localize(), null)); PropertyDescriptorCollection propDescs = new PropertyDescriptorCollection(null); foreach (AttributeInfo attr in type.Attributes) { IPropertyEditor editor = PropertyEditorFactory.createEditorForAttribute(attr); AttributePropertyDescriptor attributePropDesc = new AttributePropertyDescriptor(attr.Name.Localize(), attr, "Attributes".Localize(), null, false, editor); propDescs.Add(attributePropDesc); } type.SetTag(propDescs); } break; } }
/// <summary>Constructor that initialize the schema</summary> /// [ImportingConstructor] public VisualScriptTypeManager() { var nameSpaces = new XmlQualifiedName[] { new XmlQualifiedName(NameSpaceName, "http://www.blue3k.com/") }; m_typeCollection = new XmlSchemaTypeCollection( nameSpaces, NameSpaceName, new DomNodeTypeCollection(NameSpaceName) ); m_version = new Version("1.0");// string.IsNullOrEmpty(version) ? new Version("1.0") : new Version(version); m_ChildInfoOfTheRoot = new ChildInfo("VScript", visualScriptDocumentType.Type); Initialize(); }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters on the DOM types. /// Sets up information for types in palette. Constructs PropertyDescriptors for types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // Enable metadata driven property editing for events and resources var creator = new AdapterCreator <CustomTypeDescriptorNodeAdapter>(); Schema.eventType.Type.AddAdapterCreator(creator); Schema.resourceType.Type.AddAdapterCreator(creator); break; // schema only defines one type collection } }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { fsmType.Type = typeCollection.GetNodeType("fsmType"); fsmType.stateChild = fsmType.Type.GetChildInfo("state"); fsmType.transitionChild = fsmType.Type.GetChildInfo("transition"); fsmType.annotationChild = fsmType.Type.GetChildInfo("annotation"); fsmType.prototypeFolderChild = fsmType.Type.GetChildInfo("prototypeFolder"); stateType.Type = typeCollection.GetNodeType("stateType"); stateType.entryActionAttribute = stateType.Type.GetAttributeInfo("entryAction"); stateType.actionAttribute = stateType.Type.GetAttributeInfo("action"); stateType.exitActionAttribute = stateType.Type.GetAttributeInfo("exitAction"); stateType.nameAttribute = stateType.Type.GetAttributeInfo("name"); stateType.labelAttribute = stateType.Type.GetAttributeInfo("label"); stateType.xAttribute = stateType.Type.GetAttributeInfo("x"); stateType.yAttribute = stateType.Type.GetAttributeInfo("y"); stateType.sizeAttribute = stateType.Type.GetAttributeInfo("size"); stateType.hiddenAttribute = stateType.Type.GetAttributeInfo("hidden"); stateType.startAttribute = stateType.Type.GetAttributeInfo("start"); transitionType.Type = typeCollection.GetNodeType("transitionType"); transitionType.triggerAttribute = transitionType.Type.GetAttributeInfo("trigger"); transitionType.actionAttribute = transitionType.Type.GetAttributeInfo("action"); transitionType.labelAttribute = transitionType.Type.GetAttributeInfo("label"); transitionType.sourceAttribute = transitionType.Type.GetAttributeInfo("source"); transitionType.destinationAttribute = transitionType.Type.GetAttributeInfo("destination"); annotationType.Type = typeCollection.GetNodeType("annotationType"); annotationType.textAttribute = annotationType.Type.GetAttributeInfo("text"); annotationType.xAttribute = annotationType.Type.GetAttributeInfo("x"); annotationType.yAttribute = annotationType.Type.GetAttributeInfo("y"); prototypeFolderType.Type = typeCollection.GetNodeType("prototypeFolderType"); prototypeFolderType.nameAttribute = prototypeFolderType.Type.GetAttributeInfo("name"); prototypeFolderType.prototypeFolderChild = prototypeFolderType.Type.GetChildInfo("prototypeFolder"); prototypeFolderType.prototypeChild = prototypeFolderType.Type.GetChildInfo("prototype"); prototypeType.Type = typeCollection.GetNodeType("prototypeType"); prototypeType.nameAttribute = prototypeType.Type.GetAttributeInfo("name"); prototypeType.stateChild = prototypeType.Type.GetChildInfo("state"); prototypeType.transitionChild = prototypeType.Type.GetChildInfo("transition"); fsmRootElement = typeCollection.GetRootElement("fsm"); }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { meshType.Type = typeCollection.GetNodeType("meshType"); meshType.boundingBoxAttribute = meshType.Type.GetAttributeInfo("boundingBox"); meshType.nameAttribute = meshType.Type.GetAttributeInfo("name"); meshType.vertexArrayChild = meshType.Type.GetChildInfo("vertexArray"); meshType_vertexArray.Type = typeCollection.GetNodeType("meshType_vertexArray"); meshType_vertexArray.primitivesChild = meshType_vertexArray.Type.GetChildInfo("primitives"); meshType_vertexArray.arrayChild = meshType_vertexArray.Type.GetChildInfo("array"); vertexArray_primitives.Type = typeCollection.GetNodeType("vertexArray_primitives"); vertexArray_primitives.indicesAttribute = vertexArray_primitives.Type.GetAttributeInfo("indices"); vertexArray_primitives.sizesAttribute = vertexArray_primitives.Type.GetAttributeInfo("sizes"); vertexArray_primitives.nameAttribute = vertexArray_primitives.Type.GetAttributeInfo("name"); vertexArray_primitives.typeAttribute = vertexArray_primitives.Type.GetAttributeInfo("type"); vertexArray_primitives.bindingChild = vertexArray_primitives.Type.GetChildInfo("binding"); vertexArray_primitives.shaderChild = vertexArray_primitives.Type.GetChildInfo("shader"); primitives_binding.Type = typeCollection.GetNodeType("primitives_binding"); primitives_binding.sourceAttribute = primitives_binding.Type.GetAttributeInfo("source"); shaderType.Type = typeCollection.GetNodeType("shaderType"); shaderType.nameAttribute = shaderType.Type.GetAttributeInfo("name"); shaderType.ambientAttribute = shaderType.Type.GetAttributeInfo("ambient"); shaderType.diffuseAttribute = shaderType.Type.GetAttributeInfo("diffuse"); shaderType.shininessAttribute = shaderType.Type.GetAttributeInfo("shininess"); shaderType.specularAttribute = shaderType.Type.GetAttributeInfo("specular"); shaderType.textureAttribute = shaderType.Type.GetAttributeInfo("texture"); vertexArray_array.Type = typeCollection.GetNodeType("vertexArray_array"); vertexArray_array.Attribute = vertexArray_array.Type.GetAttributeInfo(""); vertexArray_array.countAttribute = vertexArray_array.Type.GetAttributeInfo("count"); vertexArray_array.nameAttribute = vertexArray_array.Type.GetAttributeInfo("name"); vertexArray_array.strideAttribute = vertexArray_array.Type.GetAttributeInfo("stride"); nodeType.Type = typeCollection.GetNodeType("nodeType"); nodeType.boundingBoxAttribute = nodeType.Type.GetAttributeInfo("boundingBox"); nodeType.transformAttribute = nodeType.Type.GetAttributeInfo("transform"); nodeType.nameAttribute = nodeType.Type.GetAttributeInfo("name"); nodeType.meshChild = nodeType.Type.GetChildInfo("mesh"); nodeType.shaderChild = nodeType.Type.GetChildInfo("shader"); }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters on the DOM types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; GameSchema.Initialize(typeCollection); // register extensions GameSchema.gameType.Type.Define(new ExtensionInfo <Game>()); GameSchema.gameType.Type.Define(new ExtensionInfo <ReferenceValidator>()); GameSchema.gameType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); GameSchema.gameObjectType.Type.Define(new ExtensionInfo <GameObject>()); GameSchema.dwarfType.Type.Define(new ExtensionInfo <Dwarf>()); GameSchema.ogreType.Type.Define(new ExtensionInfo <Ogre>()); break; } }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { gameType.Type = typeCollection.GetNodeType("gameType"); gameType.nameAttribute = gameType.Type.GetAttributeInfo("name"); gameType.gameObjectChild = gameType.Type.GetChildInfo("gameObject"); gameObjectType.Type = typeCollection.GetNodeType("gameObjectType"); gameObjectType.nameAttribute = gameObjectType.Type.GetAttributeInfo("name"); ogreType.Type = typeCollection.GetNodeType("ogreType"); ogreType.nameAttribute = ogreType.Type.GetAttributeInfo("name"); ogreType.sizeAttribute = ogreType.Type.GetAttributeInfo("size"); ogreType.strengthAttribute = ogreType.Type.GetAttributeInfo("strength"); dwarfType.Type = typeCollection.GetNodeType("dwarfType"); dwarfType.nameAttribute = dwarfType.Type.GetAttributeInfo("name"); dwarfType.ageAttribute = dwarfType.Type.GetAttributeInfo("age"); dwarfType.experienceAttribute = dwarfType.Type.GetAttributeInfo("experience"); treeType.Type = typeCollection.GetNodeType("treeType"); treeType.nameAttribute = treeType.Type.GetAttributeInfo("name"); gameRootElement = typeCollection.GetRootElement("game"); }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters on the DOM types. /// Sets up information for types in palette. Constructs PropertyDescriptors for types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions Schema.eventSequenceType.Type.Define(new ExtensionInfo <EventSequenceDocument>()); Schema.eventSequenceType.Type.Define(new ExtensionInfo <EventSequenceContext>()); Schema.eventSequenceType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); Schema.eventSequenceType.Type.Define(new ExtensionInfo <EventSequence>()); Schema.eventSequenceType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.eventSequenceType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); Schema.eventSequenceType.Type.Define(new ExtensionInfo <DomNodeQueryable>()); Schema.eventType.Type.Define(new ExtensionInfo <Event>()); Schema.eventType.Type.Define(new ExtensionInfo <ResourceListContext>()); Schema.resourceType.Type.Define(new ExtensionInfo <Resource>()); // Enable metadata driven property editing for events and resources var creator = new AdapterCreator <CustomTypeDescriptorNodeAdapter>(); Schema.eventType.Type.AddAdapterCreator(creator); Schema.resourceType.Type.AddAdapterCreator(creator); // annotate types with display information for palette Schema.eventType.Type.SetTag( new NodeTypePaletteItem( Schema.eventType.Type, "Event".Localize(), "Event in a sequence".Localize(), "Events".Localize(), Resources.EventImage)); string resourcesCategory = "Resources".Localize(); Schema.animationResourceType.Type.SetTag( new NodeTypePaletteItem( Schema.animationResourceType.Type, "Animation".Localize(), "Animation resource".Localize(), resourcesCategory, Resources.AnimationImage)); Schema.geometryResourceType.Type.SetTag( new NodeTypePaletteItem( Schema.geometryResourceType.Type, "Geometry".Localize(), "Geometry resource".Localize(), resourcesCategory, Resources.GeometryImage)); // register property descriptors on state, transition, folder types Schema.eventType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.eventType.nameAttribute, null, "Event name".Localize(), false), new AttributePropertyDescriptor( "Time".Localize(), Schema.eventType.timeAttribute, null, "Event starting time".Localize(), false), new AttributePropertyDescriptor( "Duration".Localize(), Schema.eventType.durationAttribute, null, "Event duration".Localize(), false), })); Schema.animationResourceType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.animationResourceType.nameAttribute, null, "Animation name".Localize(), false), new AttributePropertyDescriptor( "Size".Localize(), Schema.animationResourceType.sizeAttribute, null, "Size of animation, in bytes".Localize(), true), new AttributePropertyDescriptor( "# Tracks".Localize(), Schema.animationResourceType.tracksAttribute, null, "Number of tracks in animation".Localize(), true), new AttributePropertyDescriptor( "Duration".Localize(), Schema.animationResourceType.durationAttribute, null, "Duration of animation, in milliseconds".Localize(), true), new AttributePropertyDescriptor( "Compressed".Localize(), Schema.animationResourceType.compressedAttribute, null, "Whether or not animation is compressed".Localize(), false, null), })); var primitiveKinds = new string[] { "Lines", "Line_Strips", "Polygons", "Polylist", "Triangles", "Triangle_Strips", "Bezier_Curves", "Bezier_Surfaces", "Subdivision_Surfaces" }; // TODO: Seems like default values for enums should be set automatically by XmlSchemaTypeLoader. Schema.geometryResourceType.primitiveTypeAttribute.DefaultValue = primitiveKinds[0]; Schema.geometryResourceType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.geometryResourceType.nameAttribute, null, "Geometry name".Localize(), false), new AttributePropertyDescriptor( "Size".Localize(), Schema.geometryResourceType.sizeAttribute, null, "Size of geometry, in bytes".Localize(), true), new AttributePropertyDescriptor( "# Bones".Localize(), Schema.geometryResourceType.bonesAttribute, null, "Number of bones in geometry".Localize(), true), new AttributePropertyDescriptor( "# Vertices".Localize(), Schema.geometryResourceType.verticesAttribute, null, "Number of vertices in geometry".Localize(), true), new AttributePropertyDescriptor( "Primitive Kind".Localize(), Schema.geometryResourceType.primitiveTypeAttribute, null, "Kind of primitives in geometry".Localize(), false, StandardValuesEditor.Instance, null, new Attribute[] { new StandardValuesAttribute(primitiveKinds) }) })); break; // schema only defines one type collection } }
/// <summary> /// Initialize /// </summary> /// <param name="typeCollection"></param> public static void Initialize(XmlSchemaTypeCollection typeCollection) { SledProjectFilesType.Type = typeCollection.GetNodeType("SledProjectFilesType"); SledProjectFilesType.nameAttribute = SledProjectFilesType.Type.GetAttributeInfo("name"); SledProjectFilesType.expandedAttribute = SledProjectFilesType.Type.GetAttributeInfo("expanded"); SledProjectFilesType.assetdirectoryAttribute = SledProjectFilesType.Type.GetAttributeInfo("assetdirectory"); SledProjectFilesType.guidAttribute = SledProjectFilesType.Type.GetAttributeInfo("guid"); SledProjectFilesType.FilesChild = SledProjectFilesType.Type.GetChildInfo("Files"); SledProjectFilesType.FoldersChild = SledProjectFilesType.Type.GetChildInfo("Folders"); SledProjectFilesType.LanguagesChild = SledProjectFilesType.Type.GetChildInfo("Languages"); SledProjectFilesType.WatchesChild = SledProjectFilesType.Type.GetChildInfo("Watches"); SledProjectFilesType.RootsChild = SledProjectFilesType.Type.GetChildInfo("Roots"); SledProjectFilesType.UserSettingsChild = SledProjectFilesType.Type.GetChildInfo("UserSettings"); SledProjectFilesEmptyType.Type = typeCollection.GetNodeType("SledProjectFilesEmptyType"); SledProjectFilesEmptyType.nameAttribute = SledProjectFilesEmptyType.Type.GetAttributeInfo("name"); SledProjectFilesFolderType.Type = typeCollection.GetNodeType("SledProjectFilesFolderType"); SledProjectFilesFolderType.nameAttribute = SledProjectFilesFolderType.Type.GetAttributeInfo("name"); SledProjectFilesFolderType.expandedAttribute = SledProjectFilesFolderType.Type.GetAttributeInfo("expanded"); SledProjectFilesFolderType.FilesChild = SledProjectFilesFolderType.Type.GetChildInfo("Files"); SledProjectFilesFolderType.FoldersChild = SledProjectFilesFolderType.Type.GetChildInfo("Folders"); SledProjectFilesBaseType.Type = typeCollection.GetNodeType("SledProjectFilesBaseType"); SledProjectFilesBaseType.nameAttribute = SledProjectFilesBaseType.Type.GetAttributeInfo("name"); SledProjectFilesBaseType.expandedAttribute = SledProjectFilesBaseType.Type.GetAttributeInfo("expanded"); SledProjectFilesFileType.Type = typeCollection.GetNodeType("SledProjectFilesFileType"); SledProjectFilesFileType.nameAttribute = SledProjectFilesFileType.Type.GetAttributeInfo("name"); SledProjectFilesFileType.expandedAttribute = SledProjectFilesFileType.Type.GetAttributeInfo("expanded"); SledProjectFilesFileType.pathAttribute = SledProjectFilesFileType.Type.GetAttributeInfo("path"); SledProjectFilesFileType.guidAttribute = SledProjectFilesFileType.Type.GetAttributeInfo("guid"); SledProjectFilesFileType.BreakpointsChild = SledProjectFilesFileType.Type.GetChildInfo("Breakpoints"); SledProjectFilesFileType.FunctionsChild = SledProjectFilesFileType.Type.GetChildInfo("Functions"); SledProjectFilesFileType.AttributesChild = SledProjectFilesFileType.Type.GetChildInfo("Attributes"); SledProjectFilesBreakpointType.Type = typeCollection.GetNodeType("SledProjectFilesBreakpointType"); SledProjectFilesBreakpointType.lineAttribute = SledProjectFilesBreakpointType.Type.GetAttributeInfo("line"); SledProjectFilesBreakpointType.enabledAttribute = SledProjectFilesBreakpointType.Type.GetAttributeInfo("enabled"); SledProjectFilesBreakpointType.conditionAttribute = SledProjectFilesBreakpointType.Type.GetAttributeInfo("condition"); SledProjectFilesBreakpointType.conditionenabledAttribute = SledProjectFilesBreakpointType.Type.GetAttributeInfo("conditionenabled"); SledProjectFilesBreakpointType.conditionresultAttribute = SledProjectFilesBreakpointType.Type.GetAttributeInfo("conditionresult"); SledProjectFilesBreakpointType.usefunctionenvironmentAttribute = SledProjectFilesBreakpointType.Type.GetAttributeInfo("usefunctionenvironment"); SledFunctionBaseType.Type = typeCollection.GetNodeType("SledFunctionBaseType"); SledFunctionBaseType.nameAttribute = SledFunctionBaseType.Type.GetAttributeInfo("name"); SledFunctionBaseType.line_definedAttribute = SledFunctionBaseType.Type.GetAttributeInfo("line_defined"); SledAttributeBaseType.Type = typeCollection.GetNodeType("SledAttributeBaseType"); SledAttributeBaseType.nameAttribute = SledAttributeBaseType.Type.GetAttributeInfo("name"); SledProjectFilesLanguageType.Type = typeCollection.GetNodeType("SledProjectFilesLanguageType"); SledProjectFilesLanguageType.languageAttribute = SledProjectFilesLanguageType.Type.GetAttributeInfo("language"); SledProjectFilesLanguageType.versionAttribute = SledProjectFilesLanguageType.Type.GetAttributeInfo("version"); SledProjectFilesWatchType.Type = typeCollection.GetNodeType("SledProjectFilesWatchType"); SledProjectFilesWatchType.nameAttribute = SledProjectFilesWatchType.Type.GetAttributeInfo("name"); SledProjectFilesWatchType.expandedAttribute = SledProjectFilesWatchType.Type.GetAttributeInfo("expanded"); SledProjectFilesWatchType.language_pluginAttribute = SledProjectFilesWatchType.Type.GetAttributeInfo("language_plugin"); SledProjectFilesRootType.Type = typeCollection.GetNodeType("SledProjectFilesRootType"); SledProjectFilesRootType.directoryAttribute = SledProjectFilesRootType.Type.GetAttributeInfo("directory"); SledProjectFilesUserSettingsType.Type = typeCollection.GetNodeType("SledProjectFilesUserSettingsType"); SledProjectFilesUserSettingsType.nameAttribute = SledProjectFilesUserSettingsType.Type.GetAttributeInfo("name"); SledProjectFilesUserSettingsType.expandedAttribute = SledProjectFilesUserSettingsType.Type.GetAttributeInfo("expanded"); SledSyntaxErrorListType.Type = typeCollection.GetNodeType("SledSyntaxErrorListType"); SledSyntaxErrorListType.nameAttribute = SledSyntaxErrorListType.Type.GetAttributeInfo("name"); SledSyntaxErrorListType.ErrorsChild = SledSyntaxErrorListType.Type.GetChildInfo("Errors"); SledSyntaxErrorType.Type = typeCollection.GetNodeType("SledSyntaxErrorType"); SledSyntaxErrorType.lineAttribute = SledSyntaxErrorType.Type.GetAttributeInfo("line"); SledSyntaxErrorType.errorAttribute = SledSyntaxErrorType.Type.GetAttributeInfo("error"); SledFindResultsListType.Type = typeCollection.GetNodeType("SledFindResultsListType"); SledFindResultsListType.nameAttribute = SledFindResultsListType.Type.GetAttributeInfo("name"); SledFindResultsListType.FindResultsChild = SledFindResultsListType.Type.GetChildInfo("FindResults"); SledFindResultsType.Type = typeCollection.GetNodeType("SledFindResultsType"); SledFindResultsType.nameAttribute = SledFindResultsType.Type.GetAttributeInfo("name"); SledFindResultsType.fileAttribute = SledFindResultsType.Type.GetAttributeInfo("file"); SledFindResultsType.lineAttribute = SledFindResultsType.Type.GetAttributeInfo("line"); SledFindResultsType.start_offsetAttribute = SledFindResultsType.Type.GetAttributeInfo("start_offset"); SledFindResultsType.end_offsetAttribute = SledFindResultsType.Type.GetAttributeInfo("end_offset"); SledFindResultsType.line_textAttribute = SledFindResultsType.Type.GetAttributeInfo("line_text"); SledProfileInfoType.Type = typeCollection.GetNodeType("SledProfileInfoType"); SledProfileInfoType.functionAttribute = SledProfileInfoType.Type.GetAttributeInfo("function"); SledProfileInfoType.time_totalAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_total"); SledProfileInfoType.time_avgAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_avg"); SledProfileInfoType.time_minAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_min"); SledProfileInfoType.time_maxAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_max"); SledProfileInfoType.time_total_innerAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_total_inner"); SledProfileInfoType.time_avg_innerAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_avg_inner"); SledProfileInfoType.time_min_innerAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_min_inner"); SledProfileInfoType.time_max_innerAttribute = SledProfileInfoType.Type.GetAttributeInfo("time_max_inner"); SledProfileInfoType.num_callsAttribute = SledProfileInfoType.Type.GetAttributeInfo("num_calls"); SledProfileInfoType.lineAttribute = SledProfileInfoType.Type.GetAttributeInfo("line"); SledProfileInfoType.fileAttribute = SledProfileInfoType.Type.GetAttributeInfo("file"); SledProfileInfoType.num_funcs_calledAttribute = SledProfileInfoType.Type.GetAttributeInfo("num_funcs_called"); SledProfileInfoType.ProfileInfoChild = SledProfileInfoType.Type.GetChildInfo("ProfileInfo"); SledProfileInfoListType.Type = typeCollection.GetNodeType("SledProfileInfoListType"); SledProfileInfoListType.nameAttribute = SledProfileInfoListType.Type.GetAttributeInfo("name"); SledProfileInfoListType.ProfileInfoChild = SledProfileInfoListType.Type.GetChildInfo("ProfileInfo"); SledMemoryTraceType.Type = typeCollection.GetNodeType("SledMemoryTraceType"); SledMemoryTraceType.orderAttribute = SledMemoryTraceType.Type.GetAttributeInfo("order"); SledMemoryTraceType.whatAttribute = SledMemoryTraceType.Type.GetAttributeInfo("what"); SledMemoryTraceType.oldaddressAttribute = SledMemoryTraceType.Type.GetAttributeInfo("oldaddress"); SledMemoryTraceType.newaddressAttribute = SledMemoryTraceType.Type.GetAttributeInfo("newaddress"); SledMemoryTraceType.oldsizeAttribute = SledMemoryTraceType.Type.GetAttributeInfo("oldsize"); SledMemoryTraceType.newsizeAttribute = SledMemoryTraceType.Type.GetAttributeInfo("newsize"); SledMemoryTraceListType.Type = typeCollection.GetNodeType("SledMemoryTraceListType"); SledMemoryTraceListType.nameAttribute = SledMemoryTraceListType.Type.GetAttributeInfo("name"); SledMemoryTraceListType.MemoryTraceChild = SledMemoryTraceListType.Type.GetChildInfo("MemoryTrace"); SledCallStackType.Type = typeCollection.GetNodeType("SledCallStackType"); SledCallStackType.functionAttribute = SledCallStackType.Type.GetAttributeInfo("function"); SledCallStackType.fileAttribute = SledCallStackType.Type.GetAttributeInfo("file"); SledCallStackType.currentlineAttribute = SledCallStackType.Type.GetAttributeInfo("currentline"); SledCallStackType.linedefinedAttribute = SledCallStackType.Type.GetAttributeInfo("linedefined"); SledCallStackType.lineendAttribute = SledCallStackType.Type.GetAttributeInfo("lineend"); SledCallStackType.levelAttribute = SledCallStackType.Type.GetAttributeInfo("level"); SledCallStackListType.Type = typeCollection.GetNodeType("SledCallStackListType"); SledCallStackListType.nameAttribute = SledCallStackListType.Type.GetAttributeInfo("name"); SledCallStackListType.CallStackChild = SledCallStackListType.Type.GetChildInfo("CallStack"); SledVarLocationType.Type = typeCollection.GetNodeType("SledVarLocationType"); SledVarLocationType.fileAttribute = SledVarLocationType.Type.GetAttributeInfo("file"); SledVarLocationType.lineAttribute = SledVarLocationType.Type.GetAttributeInfo("line"); SledVarLocationType.occurenceAttribute = SledVarLocationType.Type.GetAttributeInfo("occurence"); SledVarBaseWatchListType.Type = typeCollection.GetNodeType("SledVarBaseWatchListType"); SledVarBaseWatchListType.nameAttribute = SledVarBaseWatchListType.Type.GetAttributeInfo("name"); SledVarBaseType.Type = typeCollection.GetNodeType("SledVarBaseType"); SledVarBaseType.nameAttribute = SledVarBaseType.Type.GetAttributeInfo("name"); SledVarBaseType.unique_nameAttribute = SledVarBaseType.Type.GetAttributeInfo("unique_name"); SledVarBaseType.LocationsChild = SledVarBaseType.Type.GetChildInfo("Locations"); SledProjectFilesRootElement = typeCollection.GetRootElement("SledProjectFiles"); SledProjectFilesEmptyRootElement = typeCollection.GetRootElement("SledProjectEmpty"); SledSyntaxErrorsRootElement = typeCollection.GetRootElement("SledSyntaxErrors"); SledFindResults1RootElement = typeCollection.GetRootElement("SledFindResults1"); SledFindResults2RootElement = typeCollection.GetRootElement("SledFindResults2"); }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { Initialize((ns, name) => typeCollection.GetNodeType(ns, name), (ns, name) => typeCollection.GetRootElement(ns, name)); }
public CircuitWriter(XmlSchemaTypeCollection typeCollection) : base(typeCollection) { PreserveSimpleElements = true; }
/// <summary> /// Generates the Schema CSharp class</summary> /// <param name="typeLoader">Type loader with loaded type and annotation information</param> /// <param name="schemaNamespace">Target namespace of the schema</param> /// <param name="codeNamespace">Namespace of the class ot be generated</param> /// <param name="className">Name of the class to be generated</param> /// <param name="args">Commandline arguments</param> /// <returns>CSharp Schema class as string</returns> public static string Generate(SchemaLoader typeLoader, string schemaNamespace, string codeNamespace, string className, string[] args) { bool generateAdapters = false; bool annotatedOnly = false; bool generateEnums = false; for (int i = 4; i < args.Length; i++) { string arg = args[i]; if (arg == "-a" || arg == "-adapters") { generateAdapters = true; } else if (arg == "-annotatedOnly") { annotatedOnly = true; } else if (arg == "-enums") { generateEnums = true; } } XmlSchemaTypeCollection typeCollection = GetTypeCollection(typeLoader, schemaNamespace); string targetNamespace = typeCollection.TargetNamespace; XmlQualifiedName[] namespaces = typeCollection.Namespaces; List <DomNodeType> nodeTypes = new List <DomNodeType>(typeCollection.GetNodeTypes()); // Append additional DomNodeTypes from other namespaces, for example if the xs:import was used. // Don't include the built-in "anyType". // The reason to append is that if there is a conflict with the imported types, priority should // be given to the types defined in the importing schema file. foreach (XmlQualifiedName knownNamespace in namespaces) { if (knownNamespace.Namespace != targetNamespace && knownNamespace.Namespace != "http://www.w3.org/2001/XMLSchema") { nodeTypes.AddRange(typeCollection.GetNodeTypes(knownNamespace.Namespace)); } } List <ChildInfo> rootElements = new List <ChildInfo>(typeCollection.GetRootElements()); StringBuilder sb = new StringBuilder(); GenerateFileProlog(codeNamespace, args, sb); WriteLine(sb, " public static class {0}", className); WriteLine(sb, " {{"); WriteLine(sb, " public const string NS = \"{0}\";", targetNamespace); WriteLine(sb, ""); WriteLine(sb, " public static void Initialize(XmlSchemaTypeCollection typeCollection)"); WriteLine(sb, " {{"); WriteLine(sb, " Initialize((ns,name)=>typeCollection.GetNodeType(ns,name),"); WriteLine(sb, " (ns,name)=>typeCollection.GetRootElement(ns,name));"); WriteLine(sb, " }}"); WriteLine(sb, ""); WriteLine(sb, " public static void Initialize(IDictionary<string, XmlSchemaTypeCollection> typeCollections)"); WriteLine(sb, " {{"); WriteLine(sb, " Initialize((ns,name)=>typeCollections[ns].GetNodeType(name),"); WriteLine(sb, " (ns,name)=>typeCollections[ns].GetRootElement(name));"); WriteLine(sb, " }}"); WriteLine(sb, ""); WriteLine(sb, " private static void Initialize(Func<string, string, DomNodeType> getNodeType, Func<string, string, ChildInfo> getRootElement)"); WriteLine(sb, " {{"); StringBuilder fieldSb = new StringBuilder(); Dictionary <string, string> domNodeTypeToClassName = new Dictionary <string, string>(nodeTypes.Count); Dictionary <string, string> classNameToDomNodeType = new Dictionary <string, string>(nodeTypes.Count); foreach (DomNodeType nodeType in nodeTypes) { NodeAnnotationInfo annotationInfo = new NodeAnnotationInfo(); typeLoader.DomGenAnnotations.TryGetValue(nodeType.Name, out annotationInfo); // Determine if the type should be included or skipped // If the -annotatedOnly argument is set: types will be included // ONLY IF <sce.domgen include="true"> is defined for this type, all other types will be skipped // If -annotatedOnly is NOT set: types will be included by default // UNLESS <sce.domgen include="false" is explicitly set for this type bool include = !annotatedOnly || annotationInfo.DomgenInclude; if (!include) { continue; // skip this type if it's not to be included } string ns = codeNamespace; if (ns == null) { ns = targetNamespace; } string typeName = GetClassName(namespaces, nodeType, domNodeTypeToClassName, classNameToDomNodeType); GenerateInitializers(nodeType, typeName, sb); WriteLine(sb, ""); WriteLine(fieldSb, ""); GenerateFields(nodeType, typeName, fieldSb); } if (generateEnums) { GenerateEnums(fieldSb, typeLoader, namespaces, domNodeTypeToClassName, classNameToDomNodeType); } foreach (ChildInfo rootElement in rootElements) { string fieldName = rootElement.Name + "RootElement"; WriteLine(fieldSb, ""); WriteLine(fieldSb, " public static ChildInfo {0};", fieldName); WriteLine(sb, " {0} = getRootElement(NS, \"{1}\");", fieldName, rootElement.Name); } WriteLine(sb, " }}"); sb.Append(fieldSb.ToString()); WriteLine(sb, " }}"); if (generateAdapters) { WriteLine(sb, ""); foreach (DomNodeType nodeType in nodeTypes) { string modifiers = (nodeType.IsAbstract) ? "abstract " : ""; string adapterClassName = GetClassName(nodeType, domNodeTypeToClassName); string adapterBaseClassName = "DomNodeAdapter"; if (nodeType.BaseType != DomNodeType.BaseOfAllTypes) { adapterBaseClassName = GetClassName(nodeType.BaseType, domNodeTypeToClassName); } WriteLine(sb, " public {0}partial class {1} : {2}", modifiers, adapterClassName, adapterBaseClassName); WriteLine(sb, " {{"); foreach (AttributeInfo attrInfo in nodeType.Attributes) { if (attrInfo.DefiningType != nodeType) { continue; } string typeName = attrInfo.Type.Type.ToString(); typeName = s_attributeTypes[typeName]; string attrName = attrInfo.Name; string propertyName = attrName; if (s_cSharpKeywords.Contains(propertyName)) { propertyName = "@" + propertyName; } WriteLine(sb, " public {0} {1}", typeName, propertyName); WriteLine(sb, " {{"); string attrInfoName = className + "." + adapterClassName + "." + attrName + "Attribute"; WriteLine(sb, " get {{ return GetAttribute<{0}>({1}); }}", typeName, attrInfoName); WriteLine(sb, " set {{ SetAttribute({0}, value); }}", attrInfoName); WriteLine(sb, " }}"); } foreach (ChildInfo childInfo in nodeType.Children) { if (childInfo.DefiningType != nodeType) { continue; } string childName = childInfo.Name; string propertyName = childName; string typeName = GetClassName(childInfo.Type, domNodeTypeToClassName); string childInfoName = className + "." + adapterClassName + "." + childName + "Child"; if (childInfo.IsList) { WriteLine(sb, " public IList<{0}> {1}", typeName, propertyName); WriteLine(sb, " {{"); WriteLine(sb, " get {{ return GetChildList<{0}>({1}); }}", typeName, childInfoName); WriteLine(sb, " }}"); } else { WriteLine(sb, " public {0} {1}", typeName, propertyName); WriteLine(sb, " {{"); WriteLine(sb, " get {{ return GetChild<{0}>({1}); }}", typeName, childInfoName); WriteLine(sb, " set {{ SetChild({0}, value); }}", childInfoName); WriteLine(sb, " }}"); } } WriteLine(sb, " }}"); WriteLine(sb, ""); } } GenerateFileEpilog(sb); return(sb.ToString()); }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters for types. Adds palette and PropertyDescriptor information to DomNoteType objects.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions // on the document type, register editing context, layout context, validator, unique id, // and reference integrity tracking Schema.statechartDocumentType.Type.Define(new ExtensionInfo <Document>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <ViewingContext>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <PrintableDocument>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <EditingContext>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <BoundsValidator>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <StatechartValidator>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <PrototypingContext>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.statechartDocumentType.Type.Define(new ExtensionInfo <LockingValidator>()); // register the statechart model interfaces Schema.prototypeFolderType.Type.Define(new ExtensionInfo <PrototypeFolder>()); Schema.prototypeType.Type.Define(new ExtensionInfo <Prototype>()); Schema.annotationType.Type.Define(new ExtensionInfo <Annotation>()); Schema.statechartType.Type.Define(new ExtensionInfo <Statechart>()); Schema.stateType.Type.Define(new ExtensionInfo <State>()); Schema.conditionalStateType.Type.Define(new ExtensionInfo <ConditionalState>()); Schema.finalStateType.Type.Define(new ExtensionInfo <FinalState>()); Schema.historyStateType.Type.Define(new ExtensionInfo <HistoryState>()); Schema.reactionType.Type.Define(new ExtensionInfo <Reaction>()); Schema.startStateType.Type.Define(new ExtensionInfo <StartState>()); Schema.transitionType.Type.Define(new ExtensionInfo <Transition>()); // types are initialized, annotate them with palette information Schema.annotationType.Type.SetTag( new NodeTypePaletteItem( Schema.annotationType.Type, Localizer.Localize("Comment"), Localizer.Localize("Comment on a statechart"), Resources.AnnotationImage)); Schema.reactionType.Type.SetTag( new NodeTypePaletteItem( Schema.reactionType.Type, Localizer.Localize("Reaction"), Localizer.Localize("Reaction"), Resources.ReactionImage)); Schema.stateType.Type.SetTag( new NodeTypePaletteItem( Schema.stateType.Type, Localizer.Localize("State"), Localizer.Localize("State in a statechart"), Resources.StateImage)); Schema.startStateType.Type.SetTag( new NodeTypePaletteItem( Schema.startStateType.Type, Localizer.Localize("Start State"), Localizer.Localize("Initial state in a statechart"), Resources.StartImage)); Schema.conditionalStateType.Type.SetTag( new NodeTypePaletteItem( Schema.conditionalStateType.Type, Localizer.Localize("Conditional State"), Localizer.Localize("State with a condition to reduce the number of transitions"), Resources.ConditionalImage)); Schema.historyStateType.Type.SetTag( new NodeTypePaletteItem( Schema.historyStateType.Type, Localizer.Localize("History State"), Localizer.Localize("State that restores history"), Resources.HistoryImage)); Schema.finalStateType.Type.SetTag( new NodeTypePaletteItem( Schema.finalStateType.Type, Localizer.Localize("Final State"), Localizer.Localize("Final state in a statechart"), Resources.FinalImage)); Schema.reactionType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( Localizer.Localize("Event"), Schema.reactionType.eventAttribute, null, Localizer.Localize("Event that triggers reaction"), false), new AttributePropertyDescriptor( Localizer.Localize("Guard"), Schema.reactionType.guardAttribute, null, Localizer.Localize("Guard condition required for reaction"), false), new AttributePropertyDescriptor( Localizer.Localize("Action"), Schema.reactionType.actionAttribute, null, Localizer.Localize("Action taken"), false), })); Schema.stateType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( Localizer.Localize("Label"), Schema.stateType.labelAttribute, // 'nameAttribute' is unique id, label is user visible name null, Localizer.Localize("State label"), false), new AttributePropertyDescriptor( Localizer.Localize("Entry Action"), Schema.stateType.entryActionAttribute, null, Localizer.Localize("Action taken when state is entered"), false), new AttributePropertyDescriptor( Localizer.Localize("Exit Action"), Schema.stateType.exitActionAttribute, null, Localizer.Localize("Action taken when state is exited"), false), new AttributePropertyDescriptor( Localizer.Localize("Width"), Schema.stateType.widthAttribute, null, Localizer.Localize("Width of state"), false), new AttributePropertyDescriptor( Localizer.Localize("Height"), Schema.stateType.heightAttribute, null, Localizer.Localize("Height of state"), false), })); Schema.historyStateType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( Localizer.Localize("History Type"), Schema.historyStateType.typeAttribute, null, Localizer.Localize("Whether history is shallow or deep"), false, new EnumUITypeEditor( new string[] { Localizer.Localize("Shallow", "Shallow history in a statechart"), Localizer.Localize("Deep", "Deep history in a statechart") })) })); // the statechart schema defines only one type collection break; } }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Create property descriptors for types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions Schema.gameType.Type.Define(new ExtensionInfo <GameEditingContext>()); Schema.gameType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); // Add required property descriptors to GameObject and OrcType so it can be edited // with two column PropertyGrid. // Note: this is programmatic approach: Decorate DomNode types with // property descriptors. // Alternatively schema annotations can used. // However, programmatic approach is recommend because of type safety. // Descriptors for armorType. string general = "General".Localize(); var armorDescriptors = new PropertyDescriptorCollection(null); armorDescriptors.Add(new AttributePropertyDescriptor( "Name".Localize(), Schema.armorType.nameAttribute, general, "Armor name".Localize(), false )); armorDescriptors.Add(new AttributePropertyDescriptor( "Defense".Localize(), Schema.armorType.defenseAttribute, general, "Armor defense".Localize(), false, new NumericEditor(typeof(int)) )); armorDescriptors.Add(new AttributePropertyDescriptor( "Price".Localize(), Schema.armorType.priceAttribute, general, "Armor price in gold".Localize(), false, new NumericEditor(typeof(int)) )); Schema.armorType.Type.SetTag(armorDescriptors); // club type property descriptors. var clubDescriptors = new PropertyDescriptorCollection(null); clubDescriptors.Add(new AttributePropertyDescriptor( "Spike".Localize(), Schema.clubType.spikesAttribute, general, "Club Has Spikes".Localize(), false, new BoolEditor() )); clubDescriptors.Add(new AttributePropertyDescriptor( "Damage".Localize(), Schema.clubType.DamageAttribute, general, "Amount of damage per strike".Localize(), false, new NumericEditor(typeof(int)) )); clubDescriptors.Add(new AttributePropertyDescriptor( "Weight".Localize(), Schema.clubType.wieghtAttribute, general, "Weight of the club".Localize(), false, new NumericEditor(typeof(float)) )); Schema.clubType.Type.SetTag(clubDescriptors); var gobDescriptors = new PropertyDescriptorCollection(null); gobDescriptors.Add( new AttributePropertyDescriptor( "Name".Localize(), Schema.gameObjectType.nameAttribute, null, "Object name".Localize(), false )); // bool editor: shows checkBox instead of textual (true,false). gobDescriptors.Add( new AttributePropertyDescriptor( "Visible".Localize(), Schema.gameObjectType.visibleAttribute, null, "Show/Hide object in editor".Localize(), false, new BoolEditor() )); // NumericTupleEditor can be used for vector values. string xformCategory = "Transformation".Localize(); var transEditor = new NumericTupleEditor(typeof(float), new string[] { "Tx", "Ty", "Tz" }); gobDescriptors.Add( new AttributePropertyDescriptor( "Translate".Localize(), Schema.gameObjectType.translateAttribute, xformCategory, "Object's position".Localize(), false, transEditor )); var scaleEditor = new NumericTupleEditor(typeof(float), new string[] { "Sx", "Sy", "Sz" }); gobDescriptors.Add( new AttributePropertyDescriptor( "Scale".Localize(), Schema.gameObjectType.scaleAttribute, xformCategory, "Object's scale".Localize(), false, scaleEditor )); var rotationEditor = new NumericTupleEditor(typeof(float), new string[] { "Rx", "Ry", "Rz" }); rotationEditor.ScaleFactor = 360.0f / (2.0f * (float)Math.PI); // Radians to Degrees gobDescriptors.Add( new AttributePropertyDescriptor( "Rotation".Localize(), Schema.gameObjectType.rotateAttribute, xformCategory, "Object's orientation".Localize(), false, rotationEditor )); Schema.gameObjectType.Type.SetTag(gobDescriptors); // Defines property descriptors for orcType. var orcDescriptors = new PropertyDescriptorCollection(null); string chCategory = "Character attributes".Localize(); // Bounded int editor: used for editing bounded int properties. orcDescriptors.Add( new AttributePropertyDescriptor( "Skill".Localize(), Schema.orcType.skillAttribute, chCategory, "Skill".Localize(), false, new BoundedIntEditor(1, 120) )); // Bounded float editor: similar to bounded int editor // but it operates on float instead. orcDescriptors.Add( new AttributePropertyDescriptor( "Weight".Localize(), Schema.orcType.weightAttribute, chCategory, "Weight".Localize(), false, new BoundedFloatEditor(80, 400) )); // Enum can be stored as string or as int. // OrcLevel is stored as int // OrcEmotion is stored as string. // please see the schema. // Create image for showing character level. var levVals = Enum.GetValues(typeof(OrcLevel)); Image[] levImages = new Image[levVals.Length]; foreach (var en in levVals) { levImages[(int)en] = new Bitmap(this.GetType(), "Resources." + en + ".png"); } // show usage for enum stored as int. // Shows how to edit enum that is stored as string. var lvEnumEditor = new LongEnumEditor(typeof(OrcLevel), levImages); var lvTypeConverter = new IntEnumTypeConverter(typeof(OrcLevel)); orcDescriptors.Add( new AttributePropertyDescriptor( "Level".Localize(), Schema.orcType.levelAttribute, chCategory, "Character level".Localize(), false, lvEnumEditor, lvTypeConverter )); // create images used for showing emotion // for enum OrcEmotion var emoVals = Enum.GetValues(typeof(OrcEmotion)); Image[] emoImages = new Image[emoVals.Length]; foreach (var en in emoVals) { emoImages[(int)en] = new Bitmap(this.GetType(), "Resources." + en + ".png"); } // Shows how to edit enum that is stored as string. var emotionEditor = new LongEnumEditor(typeof(OrcEmotion), emoImages); orcDescriptors.Add( new AttributePropertyDescriptor( "Emotion".Localize(), Schema.orcType.emotionAttribute, chCategory, "Emotion".Localize(), false, emotionEditor )); // FlagsUITypeEditor store flags as int. // doesn't implement IPropertyEditor FlagsUITypeEditor goalsEditor = new FlagsUITypeEditor(Enum.GetNames(typeof(OrcGoals))); FlagsTypeConverter goalsConverter = new FlagsTypeConverter(Enum.GetNames(typeof(OrcGoals))); orcDescriptors.Add( new AttributePropertyDescriptor( "Goals".Localize(), Schema.orcType.goalsAttribute, chCategory, "Goals".Localize(), false, goalsEditor, goalsConverter )); orcDescriptors.Add( new AttributePropertyDescriptor( "Health".Localize(), Schema.orcType.healthAttribute, chCategory, "Orc's health".Localize(), false, new NumericEditor(typeof(int)) )); //EmbeddedCollectionEditor edit children (edit, add, remove, move). // note: EmbeddedCollectionEditor needs some work (efficiency and implementation issues). var collectionEditor = new EmbeddedCollectionEditor(); // the following lambda's handles (add, remove, move ) items. collectionEditor.GetItemInsertersFunc = (context) => { var insertors = new EmbeddedCollectionEditor.ItemInserter[1]; var list = context.GetValue() as IList <DomNode>; if (list != null) { var childDescriptor = context.Descriptor as ChildPropertyDescriptor; if (childDescriptor != null) { insertors[0] = new EmbeddedCollectionEditor.ItemInserter(childDescriptor.ChildInfo.Type.Name, delegate { DomNode node = new DomNode(childDescriptor.ChildInfo.Type); if (node.Type.IdAttribute != null) { node.SetAttribute(node.Type.IdAttribute, node.Type.Name); } list.Add(node); return(node); }); return(insertors); } } return(EmptyArray <EmbeddedCollectionEditor.ItemInserter> .Instance); }; collectionEditor.RemoveItemFunc = (context, item) => { var list = context.GetValue() as IList <DomNode>; if (list != null) { list.Remove(item.Cast <DomNode>()); } }; collectionEditor.MoveItemFunc = (context, item, delta) => { var list = context.GetValue() as IList <DomNode>; if (list != null) { DomNode node = item.Cast <DomNode>(); int index = list.IndexOf(node); int insertIndex = index + delta; if (insertIndex < 0 || insertIndex >= list.Count) { return; } list.RemoveAt(index); list.Insert(insertIndex, node); } }; string weaponCategory = "Weapons and Defense".Localize(); orcDescriptors.Add( new ChildPropertyDescriptor( "Armor".Localize(), Schema.orcType.armorChild, weaponCategory, "Armors".Localize(), false, collectionEditor )); orcDescriptors.Add( new ChildPropertyDescriptor( "Club".Localize(), Schema.orcType.clubChild, weaponCategory, "Club".Localize(), false, collectionEditor )); orcDescriptors.Add( new ChildPropertyDescriptor( "Orcs".Localize(), Schema.orcType.orcChild, "Children".Localize(), "Orc children".Localize(), false, collectionEditor )); string renderingCategory = "Rendering".Localize(); // color picker. // note: ColorPickerEditor doesn't implement IPropertyEditor orcDescriptors.Add( new AttributePropertyDescriptor( "Skin".Localize(), Schema.orcType.skinColorAttribute, renderingCategory, "Skin color".Localize(), false, new ColorPickerEditor(), new IntColorConverter() )); // file picker. orcDescriptors.Add( new AttributePropertyDescriptor( "Texture file".Localize(), Schema.orcType.textureFileAttribute, renderingCategory, "Texture file".Localize(), false, new FileUriEditor("Texture file (*.dds)|*.dds") )); // Edit matrix. //NumericMatrixEditor orcDescriptors.Add( new AttributePropertyDescriptor( "Texture Transform".Localize(), Schema.orcType.textureTransformAttribute, renderingCategory, "Texture Transform".Localize(), false, new NumericMatrixEditor() )); // Edit array. // ArrayEditor, need some work, it has some efficiency and implementation issues. orcDescriptors.Add( new AttributePropertyDescriptor( "Texture Array".Localize(), Schema.orcType.textureArrayAttribute, renderingCategory, "Texture Array".Localize(), false, new ArrayEditor() )); // readonly property, // show datetime as readonly. orcDescriptors.Add( new AttributePropertyDescriptor( "Revision data".Localize(), Schema.orcType.TextureRevDateAttribute, renderingCategory, "Texture revision data and time".Localize(), true )); // folder picker. // FolderUriEditor and FolderBrowserDialogUITypeEditor orcDescriptors.Add( new AttributePropertyDescriptor( "Resource Folder".Localize(), Schema.orcType.resourceFolderAttribute, renderingCategory, "Resource folder".Localize(), false, new FolderUriEditor() )); Schema.orcType.Type.SetTag(orcDescriptors); // only one namespace break; } }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Create property descriptors for types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions // extend FSM root node with FSM, document, editing context, and printing support Schema.fsmType.Type.Define(new ExtensionInfo <Fsm>()); Schema.fsmType.Type.Define(new ExtensionInfo <EditingContext>()); Schema.fsmType.Type.Define(new ExtensionInfo <ViewingContext>()); Schema.fsmType.Type.Define(new ExtensionInfo <TransitionRouter>()); Schema.fsmType.Type.Define(new ExtensionInfo <Document>()); Schema.fsmType.Type.Define(new ExtensionInfo <PrintableDocument>()); // extend with adapter to synch multiple histories in document with document "Dirty" flag Schema.fsmType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); // extend with adapter for prototyping Schema.fsmType.Type.Define(new ExtensionInfo <PrototypingContext>()); // extend with adapters to validate references and unique ids Schema.fsmType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.fsmType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); // define FSM object model Schema.prototypeFolderType.Type.Define(new ExtensionInfo <PrototypeFolder>()); Schema.prototypeType.Type.Define(new ExtensionInfo <Prototype>()); Schema.stateType.Type.Define(new ExtensionInfo <State>()); Schema.transitionType.Type.Define(new ExtensionInfo <Transition>()); Schema.annotationType.Type.Define(new ExtensionInfo <Annotation>()); // annotate state and annotation types with display information for palette Schema.stateType.labelAttribute.DefaultValue = "State".Localize(); Schema.stateType.Type.SetTag( new NodeTypePaletteItem( Schema.stateType.Type, (string)Schema.stateType.labelAttribute.DefaultValue, "State in a finite state machine".Localize(), Resources.StateImage)); Schema.annotationType.Type.SetTag( new NodeTypePaletteItem( Schema.annotationType.Type, "Comment".Localize(), "Comment on state machine".Localize(), Resources.AnnotationImage)); // register property descriptors on state, transition, folder types Schema.stateType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.stateType.labelAttribute, // 'nameAttribute' is unique id, label is user visible name null, "State name".Localize(), false), new AttributePropertyDescriptor( "Size".Localize(), Schema.stateType.sizeAttribute, null, "State size".Localize(), false), new AttributePropertyDescriptor( "Hidden".Localize(), Schema.stateType.hiddenAttribute, null, "Whether or not state is hidden".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "Start".Localize(), Schema.stateType.startAttribute, null, "Whether or not state is the start state".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "Entry Action".Localize(), Schema.stateType.entryActionAttribute, null, "Action performed when entering state".Localize(), false), new AttributePropertyDescriptor( "Action".Localize(), Schema.stateType.actionAttribute, null, "Action performed while in state".Localize(), false), new AttributePropertyDescriptor( "Exit Action".Localize(), Schema.stateType.exitActionAttribute, null, "Action performed when exiting state".Localize(), false), })); Schema.transitionType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Label".Localize(), Schema.transitionType.labelAttribute, null, "Label displayed on transition".Localize(), false), new AttributePropertyDescriptor( "Trigger".Localize(), Schema.transitionType.triggerAttribute, null, "Event which triggers transition".Localize(), false), new AttributePropertyDescriptor( "Action".Localize(), Schema.transitionType.actionAttribute, null, "Action performed when making transition".Localize(), false), })); Schema.prototypeFolderType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.prototypeFolderType.nameAttribute, null, "Prototype folder name".Localize(), false) })); Schema.annotationType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Text".Localize(), Schema.annotationType.textAttribute, null, "Comment text".Localize(), false) })); // the fsm schema defines only one type collection break; } }
/// <summary> /// Constructor /// </summary> /// <param name="typeCollection">Schema type collection</param> public SledSpfWriter(XmlSchemaTypeCollection typeCollection) { m_typeCollection = typeCollection; }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Create property descriptors for types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions // extend FSM root node with FSM, document, editing context, and printing support Schema.fsmType.Type.Define(new ExtensionInfo <Fsm>()); Schema.fsmType.Type.Define(new ExtensionInfo <EditingContext>()); Schema.fsmType.Type.Define(new ExtensionInfo <ViewingContext>()); Schema.fsmType.Type.Define(new ExtensionInfo <TransitionRouter>()); Schema.fsmType.Type.Define(new ExtensionInfo <Document>()); Schema.fsmType.Type.Define(new ExtensionInfo <PrintableDocument>()); // extend with adapter to synch multiple histories in document with document "Dirty" flag Schema.fsmType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); // extend with adapter for prototyping Schema.fsmType.Type.Define(new ExtensionInfo <PrototypingContext>()); // extend with adapters to validate references and unique ids Schema.fsmType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.fsmType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); // define FSM object model Schema.prototypeFolderType.Type.Define(new ExtensionInfo <PrototypeFolder>()); Schema.prototypeType.Type.Define(new ExtensionInfo <Prototype>()); Schema.stateType.Type.Define(new ExtensionInfo <State>()); Schema.transitionType.Type.Define(new ExtensionInfo <Transition>()); Schema.annotationType.Type.Define(new ExtensionInfo <Annotation>()); // annotate state and annotation types with display information for palette Schema.stateType.labelAttribute.DefaultValue = "State".Localize(); Schema.stateType.Type.SetTag( new NodeTypePaletteItem( Schema.stateType.Type, (string)Schema.stateType.labelAttribute.DefaultValue, "State in a finite state machine".Localize(), Resources.StateImage)); Schema.annotationType.Type.SetTag( new NodeTypePaletteItem( Schema.annotationType.Type, "Comment".Localize(), "Comment on state machine".Localize(), Resources.AnnotationImage)); // register property descriptors on state, transition, folder types // TransitionType have a collection of child triggers. // use EmbeddedCollectionEditor to edit children (edit, add, remove, move). // Note: EmbeddedCollectionEditor needs some work (efficiency and implementation issues). var collectionEditor = new EmbeddedCollectionEditor(); // the following lambda's handles (add, remove, move ) items. collectionEditor.GetItemInsertersFunc = (context) => { var insertors = new EmbeddedCollectionEditor.ItemInserter[1]; var list = context.GetValue() as IList <DomNode>; if (list != null) { var childDescriptor = context.Descriptor as ChildPropertyDescriptor; if (childDescriptor != null) { insertors[0] = new EmbeddedCollectionEditor.ItemInserter(childDescriptor.ChildInfo.Type.Name, delegate { DomNode node = new DomNode(childDescriptor.ChildInfo.Type); if (node.Type.IdAttribute != null) { node.SetAttribute(node.Type.IdAttribute, node.Type.Name); } list.Add(node); return(node); }); return(insertors); } } return(EmptyArray <EmbeddedCollectionEditor.ItemInserter> .Instance); }; collectionEditor.RemoveItemFunc = (context, item) => { var list = context.GetValue() as IList <DomNode>; if (list != null) { list.Remove(item.Cast <DomNode>()); } }; collectionEditor.MoveItemFunc = (context, item, delta) => { var list = context.GetValue() as IList <DomNode>; if (list != null) { DomNode node = item.Cast <DomNode>(); int index = list.IndexOf(node); int insertIndex = index + delta; if (insertIndex < 0 || insertIndex >= list.Count) { return; } list.RemoveAt(index); list.Insert(insertIndex, node); } }; Schema.stateType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.stateType.labelAttribute, // 'nameAttribute' is unique id, label is user visible name null, "State name".Localize(), false), new AttributePropertyDescriptor( "Size".Localize(), Schema.stateType.sizeAttribute, null, "State size".Localize(), false), new AttributePropertyDescriptor( "Hidden".Localize(), Schema.stateType.hiddenAttribute, null, "Whether or not state is hidden".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "Start".Localize(), Schema.stateType.startAttribute, null, "Whether or not state is the start state".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "Entry Action".Localize(), Schema.stateType.entryActionAttribute, null, "Action performed when entering state".Localize(), false), new AttributePropertyDescriptor( "Action".Localize(), Schema.stateType.actionAttribute, null, "Action performed while in state".Localize(), false), new AttributePropertyDescriptor( "Exit Action".Localize(), Schema.stateType.exitActionAttribute, null, "Action performed when exiting state".Localize(), false), })); Schema.triggerType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Label".Localize(), Schema.triggerType.labelAttribute, null, "Label displayed on trigger".Localize(), false), new AttributePropertyDescriptor( "ID".Localize(), Schema.triggerType.idAttribute, null, "Trigger ID".Localize(), false), new AttributePropertyDescriptor( "Action".Localize(), Schema.triggerType.actionAttribute, null, "Action on trigger".Localize(), false) })); Schema.transitionType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Label".Localize(), Schema.transitionType.labelAttribute, null, "Label displayed on transition".Localize(), false), new AttributePropertyDescriptor( "Action".Localize(), Schema.transitionType.actionAttribute, null, "Action performed when making transition".Localize(), false), new ChildPropertyDescriptor( "Triggers".Localize(), Schema.transitionType.triggerChild, null, "List of triggers".Localize(), false, collectionEditor) })); Schema.prototypeFolderType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.prototypeFolderType.nameAttribute, null, "Prototype folder name".Localize(), false) })); Schema.annotationType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Text".Localize(), Schema.annotationType.textAttribute, null, "Comment text".Localize(), false) })); // the fsm schema defines only one type collection break; } }
public static void Initialize(XmlSchemaTypeCollection typeCollection) { statechartDocumentType.Type = typeCollection.GetNodeType("statechartDocumentType"); statechartDocumentType.stateChild = statechartDocumentType.Type.GetChildInfo("state"); statechartDocumentType.transitionChild = statechartDocumentType.Type.GetChildInfo("transition"); statechartDocumentType.annotationChild = statechartDocumentType.Type.GetChildInfo("annotation"); statechartDocumentType.prototypeFolderChild = statechartDocumentType.Type.GetChildInfo("prototypeFolder"); statechartType.Type = typeCollection.GetNodeType("statechartType"); statechartType.stateChild = statechartType.Type.GetChildInfo("state"); stateBaseType.Type = typeCollection.GetNodeType("stateBaseType"); stateBaseType.nameAttribute = stateBaseType.Type.GetAttributeInfo("name"); stateBaseType.xAttribute = stateBaseType.Type.GetAttributeInfo("x"); stateBaseType.yAttribute = stateBaseType.Type.GetAttributeInfo("y"); transitionType.Type = typeCollection.GetNodeType("transitionType"); transitionType.eventAttribute = transitionType.Type.GetAttributeInfo("event"); transitionType.guardAttribute = transitionType.Type.GetAttributeInfo("guard"); transitionType.actionAttribute = transitionType.Type.GetAttributeInfo("action"); transitionType.fromStateAttribute = transitionType.Type.GetAttributeInfo("fromState"); transitionType.fromPositionAttribute = transitionType.Type.GetAttributeInfo("fromPosition"); transitionType.toStateAttribute = transitionType.Type.GetAttributeInfo("toState"); transitionType.toPositionAttribute = transitionType.Type.GetAttributeInfo("toPosition"); reactionType.Type = typeCollection.GetNodeType("reactionType"); reactionType.eventAttribute = reactionType.Type.GetAttributeInfo("event"); reactionType.guardAttribute = reactionType.Type.GetAttributeInfo("guard"); reactionType.actionAttribute = reactionType.Type.GetAttributeInfo("action"); annotationType.Type = typeCollection.GetNodeType("annotationType"); annotationType.textAttribute = annotationType.Type.GetAttributeInfo("text"); annotationType.xAttribute = annotationType.Type.GetAttributeInfo("x"); annotationType.yAttribute = annotationType.Type.GetAttributeInfo("y"); prototypeFolderType.Type = typeCollection.GetNodeType("prototypeFolderType"); prototypeFolderType.nameAttribute = prototypeFolderType.Type.GetAttributeInfo("name"); prototypeFolderType.prototypeFolderChild = prototypeFolderType.Type.GetChildInfo("prototypeFolder"); prototypeFolderType.prototypeChild = prototypeFolderType.Type.GetChildInfo("prototype"); prototypeType.Type = typeCollection.GetNodeType("prototypeType"); prototypeType.nameAttribute = prototypeType.Type.GetAttributeInfo("name"); prototypeType.stateChild = prototypeType.Type.GetChildInfo("state"); prototypeType.transitionChild = prototypeType.Type.GetChildInfo("transition"); stateType.Type = typeCollection.GetNodeType("stateType"); stateType.nameAttribute = stateType.Type.GetAttributeInfo("name"); stateType.xAttribute = stateType.Type.GetAttributeInfo("x"); stateType.yAttribute = stateType.Type.GetAttributeInfo("y"); stateType.labelAttribute = stateType.Type.GetAttributeInfo("label"); stateType.widthAttribute = stateType.Type.GetAttributeInfo("width"); stateType.heightAttribute = stateType.Type.GetAttributeInfo("height"); stateType.entryActionAttribute = stateType.Type.GetAttributeInfo("entryAction"); stateType.exitActionAttribute = stateType.Type.GetAttributeInfo("exitAction"); stateType.reactionChild = stateType.Type.GetChildInfo("reaction"); stateType.statechartChild = stateType.Type.GetChildInfo("statechart"); startStateType.Type = typeCollection.GetNodeType("startStateType"); startStateType.nameAttribute = startStateType.Type.GetAttributeInfo("name"); startStateType.xAttribute = startStateType.Type.GetAttributeInfo("x"); startStateType.yAttribute = startStateType.Type.GetAttributeInfo("y"); finalStateType.Type = typeCollection.GetNodeType("finalStateType"); finalStateType.nameAttribute = finalStateType.Type.GetAttributeInfo("name"); finalStateType.xAttribute = finalStateType.Type.GetAttributeInfo("x"); finalStateType.yAttribute = finalStateType.Type.GetAttributeInfo("y"); historyStateType.Type = typeCollection.GetNodeType("historyStateType"); historyStateType.nameAttribute = historyStateType.Type.GetAttributeInfo("name"); historyStateType.xAttribute = historyStateType.Type.GetAttributeInfo("x"); historyStateType.yAttribute = historyStateType.Type.GetAttributeInfo("y"); historyStateType.typeAttribute = historyStateType.Type.GetAttributeInfo("type"); conditionalStateType.Type = typeCollection.GetNodeType("conditionalStateType"); conditionalStateType.nameAttribute = conditionalStateType.Type.GetAttributeInfo("name"); conditionalStateType.xAttribute = conditionalStateType.Type.GetAttributeInfo("x"); conditionalStateType.yAttribute = conditionalStateType.Type.GetAttributeInfo("y"); statechartRootElement = typeCollection.GetRootElement("statechart"); }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Adds property descriptors for types.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; UISchema.Initialize(typeCollection); // register UI adapters as extensions on the DOM data // register adapters on the root to define document and editing context UISchema.UIType.Type.Define(new ExtensionInfo <UI>()); UISchema.UIType.Type.Define(new ExtensionInfo <EditingContext>()); UISchema.UIType.Type.Define(new ExtensionInfo <TreeView>()); UISchema.UIType.Type.Define(new ExtensionInfo <Document>()); UISchema.UIType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); // register adapters on the root for data validation UISchema.UIType.Type.Define(new ExtensionInfo <Validator>()); // makes sure referenced resources are in package // this must be first so unique naming can work on copied resources UISchema.UIType.Type.Define(new ExtensionInfo <ReferenceValidator>()); // prevents dangling references UISchema.UIType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); // makes sure ref targets have unique ids // register adapters to define the UI object model UISchema.UIPackageType.Type.Define(new ExtensionInfo <UIPackage>()); UISchema.UIFormType.Type.Define(new ExtensionInfo <UIForm>()); UISchema.UIShaderType.Type.Define(new ExtensionInfo <UIShader>()); UISchema.UITextureType.Type.Define(new ExtensionInfo <UITexture>()); UISchema.UIFontType.Type.Define(new ExtensionInfo <UIFont>()); UISchema.UISpriteType.Type.Define(new ExtensionInfo <UISprite>()); UISchema.UITextItemType.Type.Define(new ExtensionInfo <UITextItem>()); UISchema.UIRefType.Type.Define(new ExtensionInfo <UIRef>()); UISchema.UIAnimationType.Type.Define(new ExtensionInfo <UIAnimation>()); UISchema.curveType.Type.Define(new ExtensionInfo <Curve>()); UISchema.curveType.Type.Define(new ExtensionInfo <CurveLimitValidator>()); UISchema.controlPointType.Type.Define(new ExtensionInfo <ControlPoint>()); // // tag UI types with display info; it will be used both in the palette // and in the UITreeLister tree view. UISchema.UIType.Type.SetTag( new NodeTypePaletteItem( UISchema.UIType.Type, "UI".Localize(), "UI Container".Localize(), "Sce.Atf.Resources.Data16.png")); UISchema.UIPackageType.Type.SetTag( new NodeTypePaletteItem( UISchema.UIPackageType.Type, "Package".Localize(), "Package, containing a complete collection of UI items".Localize(), "DomTreeEditorSample.Resources.package.png")); UISchema.UIFormType.Type.SetTag( new NodeTypePaletteItem( UISchema.UIFormType.Type, "Form".Localize(), "Form, containing a UI screen".Localize(), "DomTreeEditorSample.Resources.form.png")); UISchema.UISpriteType.Type.SetTag( new NodeTypePaletteItem( UISchema.UISpriteType.Type, "Sprite".Localize(), "A moveable UI element".Localize(), "DomTreeEditorSample.Resources.sprite.png")); UISchema.UIShaderType.Type.SetTag( new NodeTypePaletteItem( UISchema.UIShaderType.Type, "Shader".Localize(), "Shader for rendering graphics".Localize(), "DomTreeEditorSample.Resources.shader.png")); UISchema.UITextureType.Type.SetTag( new NodeTypePaletteItem( UISchema.UITextureType.Type, "Texture".Localize(), "Texture for rendering graphics".Localize(), "DomTreeEditorSample.Resources.texture.png")); UISchema.UIFontType.Type.SetTag( new NodeTypePaletteItem( UISchema.UIFontType.Type, "Font".Localize(), "Font for rendering text".Localize(), "DomTreeEditorSample.Resources.font.png")); UISchema.UITextItemType.Type.SetTag( new NodeTypePaletteItem( UISchema.UITextItemType.Type, "Text".Localize(), "Text, to display on Form".Localize(), "DomTreeEditorSample.Resources.text.png")); UISchema.UITransformType.Type.SetTag( new NodeTypePaletteItem( UISchema.UITransformType.Type, "Transform".Localize(), "Transform, for sprites and text".Localize(), "DomTreeEditorSample.Resources.transform.png")); UISchema.UIAnimationType.Type.SetTag( new NodeTypePaletteItem( UISchema.UIAnimationType.Type, "Animation".Localize(), "Color and position animation curves, for form and control".Localize(), null) ); UISchema.curveType.Type.SetTag( new NodeTypePaletteItem( UISchema.curveType.Type, "Curve".Localize(), "animation curve".Localize(), null)); // Tag UI types with descriptors for property editing //UISchema.UIObjectType.Type.SetTag( // new PropertyDescriptorCollection( // new PropertyDescriptor[] { // new AttributePropertyDescriptor( // Localizer.Localize("Name"), // UISchema.UIObjectType.nameAttribute, // null, // Localizer.Localize("Item name"), // false) // })); //UISchema.UIPackageType.Type.SetTag( // new PropertyDescriptorCollection( // new PropertyDescriptor[] { // new AttributePropertyDescriptor( // Localizer.Localize("Package"), // UISchema.UIPackageType.FxFileAttribute, // null, // Localizer.Localize("Shader file path"), // false, // new CollectionEditor()) // })); UISchema.UIShaderType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Shader".Localize(), UISchema.UIShaderType.FxFileAttribute, null, "Shader file path".Localize(), false, new FileUriEditor("Fx Files (*.fx)|*.fx")), new AttributePropertyDescriptor( "Shader param".Localize(), UISchema.UIShaderType.ShaderParamAttribute, null, "Shader param".Localize(), false, new NumericEditor(typeof(Int32))) })); UISchema.UITextureType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Texture file".Localize(), UISchema.UITextureType.TextureFileAttribute, null, "Texture file path".Localize(), false, new FileUriEditor("Texture Files (*.tga)|*.tga")), new AttributePropertyDescriptor( "Texture folder".Localize(), UISchema.UITextureType.TextureFolderAttribute, null, "Texture folder path".Localize(), false, new FolderBrowserDialogUITypeEditor("Texture folder path")), new AttributePropertyDescriptor( "Texture numbers".Localize(), UISchema.UITextureType.TextureArrayAttribute, null, "Texture number array".Localize(), false, new ArrayEditor()), new AttributePropertyDescriptor( "Texture revision date".Localize(), UISchema.UITextureType.TextureRevDateAttribute, null, "Texture revision date".Localize(), false, new DateTimeEditor()), })); UISchema.UIFontType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Font".Localize(), UISchema.UIFontType.FontFileAttribute, null, "Font file path".Localize(), false, new FileUriEditor("Font Files (*.ttf)|*.ttf")), new AttributePropertyDescriptor( "Font parameters".Localize(), UISchema.UIFontType.FontParamsAttribute, null, "Font parameters".Localize(), false, new CollectionEditor()), })); UISchema.UIAnimationType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Animation transform".Localize(), UISchema.UIAnimationType.AnimationTransformAttribute, null, "Animation transform".Localize(), false, new NumericMatrixEditor(typeof(float), 3, 3)), new AttributePropertyDescriptor( "Animal kinds".Localize(), UISchema.UIAnimationType.AnimalKindsAttribute, null, "Kinds of animal to animate".Localize(), false, new CollectionEditor()), })); UISchema.UIControlType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new ChildAttributePropertyDescriptor( "Translation".Localize(), UISchema.UITransformType.TranslateAttribute, UISchema.UIControlType.TransformChild, null, "Item position".Localize(), false, new NumericTupleEditor(typeof(float), new string[] { "X", "Y", "Z" })), new ChildAttributePropertyDescriptor( "Rotation".Localize(), UISchema.UITransformType.RotateAttribute, UISchema.UIControlType.TransformChild, null, "Item rotation".Localize(), false, new NumericTupleEditor(typeof(float), new string[] { "X", "Y", "Z" })), new ChildAttributePropertyDescriptor( "Scale".Localize(), UISchema.UITransformType.ScaleAttribute, UISchema.UIControlType.TransformChild, null, "Item scale".Localize(), false, new UniformArrayEditor <float>()) })); // only one namespace break; } }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters for types. Create PropertyDescriptors for types to use in property editors.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions // decorate circuit document type Schema.circuitDocumentType.Type.Define(new ExtensionInfo <CircuitDocument>()); // document info //Schema.circuitDocumentType.Type.Define(new ExtensionInfo<SampleCircuitEditingContext>()); // document info Schema.circuitDocumentType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); // ties sub-context histories into document dirty bit Schema.circuitDocumentType.Type.Define(new ExtensionInfo <PrototypingContext>()); // document-wide prototype hierarchy Schema.circuitDocumentType.Type.Define(new ExtensionInfo <TemplatingContext>()); // document-wide template hierarchy //Schema.circuitDocumentType.Type.Define(new ExtensionInfo<UniqueIdValidator>()); // ensures all ids are unique throughout document Schema.circuitDocumentType.Type.Define(new ExtensionInfo <CategoryUniqueIdValidator>()); // ensures all ids are local unique in its category Schema.circuitDocumentType.Type.Define(new ExtensionInfo <CircuitValidator>()); // validate group hierarchy // ReferenceValidator should be the last validator attached to the root DomNode to fully track // all the DOM editings of all other validators to update references properly Schema.circuitDocumentType.Type.Define(new ExtensionInfo <ReferenceValidator>()); // tracks references and targets // decorate circuit type Schema.circuitType.Type.Define(new ExtensionInfo <GlobalHistoryContext>()); Schema.circuitType.Type.Define(new ExtensionInfo <ViewingContext>()); // manages module and circuit bounds, efficient layout Schema.circuitType.Type.Define(new ExtensionInfo <LayeringContext>()); // circuit layer hierarchy Schema.circuitType.Type.Define(new ExtensionInfo <PrintableDocument>()); // printing // decorate group type Schema.groupType.Type.Define(new ExtensionInfo <CircuitEditingContext>()); // main editable circuit adapter Schema.groupType.Type.Define(new ExtensionInfo <Group>()); Schema.groupType.Type.Define(new ExtensionInfo <ViewingContext>()); #pragma warning disable 618 //mastered sub-circuits are obsolete Schema.subCircuitType.Type.Define(new ExtensionInfo <SubCircuit>()); Schema.subCircuitInstanceType.Type.Define(new ExtensionInfo <SubCircuitInstance>()); #pragma warning restore 618 Schema.connectionType.Type.Define(new ExtensionInfo <WireStyleProvider <Module, Connection, ICircuitPin> >()); RegisterCircuitExtensions(); // types are initialized, register property descriptors on module, folder types Schema.moduleType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.moduleType.labelAttribute, // 'nameAttribute' is unique id, label is user visible name null, "Module name".Localize(), false), new AttributePropertyDescriptor( "ID".Localize(), Schema.moduleType.nameAttribute, // 'nameAttribute' is unique id, label is user visible name null, "Unique ID".Localize(), true) })); Schema.layerFolderType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.layerFolderType.nameAttribute, null, "Layer name".Localize(), false) })); Schema.prototypeFolderType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.prototypeFolderType.nameAttribute, null, "Prototype folder name".Localize(), false) })); // the circuit schema defines only one type collection break; } }
/// <summary> /// Method called after the schema set has been loaded and the DomNodeTypes have been created, but /// before the DomNodeTypes have been frozen. This means that DomNodeType.SetIdAttribute, for example, has /// not been called on the DomNodeTypes. Is called shortly before OnDomNodeTypesFrozen. /// Defines DOM adapters for types. Adds information for palette to types. /// Adds PropertyDescriptors to types for property editors.</summary> /// <param name="schemaSet">XML schema sets being loaded</param> protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); // register extensions Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <WinGuiCommonDataDocument>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <WinGuiCommonDataContext>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <WinGuiWpfDataDocument>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <WinGuiWpfDataContext>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <MultipleHistoryContext>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <WinGuiCommonData>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <ReferenceValidator>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <UniqueIdValidator>()); Schema.winGuiCommonDataType.Type.Define(new ExtensionInfo <DomNodeQueryable>()); Schema.eventType.Type.Define(new ExtensionInfo <WinGuiCommon.Event>()); Schema.eventType.Type.Define(new ExtensionInfo <EventContext>()); Schema.resourceType.Type.Define(new ExtensionInfo <WinGuiCommon.Resource>()); // Enable metadata driven property editing for events and resources AdapterCreator <CustomTypeDescriptorNodeAdapter> creator = new AdapterCreator <CustomTypeDescriptorNodeAdapter>(); Schema.eventType.Type.AddAdapterCreator(creator); Schema.resourceType.Type.AddAdapterCreator(creator); // annotate types with display information for palette Schema.eventType.Type.SetTag( new NodeTypePaletteItem( Schema.eventType.Type, Localizer.Localize("Event"), Localizer.Localize("Event in a sequence"), WinGuiCommon.Resources.EventImage)); Schema.animationResourceType.Type.SetTag( new NodeTypePaletteItem( Schema.animationResourceType.Type, Localizer.Localize("Animation"), Localizer.Localize("Animation resource"), WinGuiCommon.Resources.AnimationImage)); Schema.geometryResourceType.Type.SetTag( new NodeTypePaletteItem( Schema.geometryResourceType.Type, Localizer.Localize("Geometry"), Localizer.Localize("Geometry resource"), WinGuiCommon.Resources.GeometryImage)); // register property descriptors on state, transition, folder types Schema.eventType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( Localizer.Localize("Name"), Schema.eventType.nameAttribute, null, Localizer.Localize("Event name"), false), new AttributePropertyDescriptor( Localizer.Localize("Time"), Schema.eventType.timeAttribute, null, Localizer.Localize("Event starting time"), false), new AttributePropertyDescriptor( Localizer.Localize("Duration"), Schema.eventType.durationAttribute, null, Localizer.Localize("Event duration"), false), })); Schema.animationResourceType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( Localizer.Localize("Name"), Schema.animationResourceType.nameAttribute, null, Localizer.Localize("Animation name"), false), new AttributePropertyDescriptor( Localizer.Localize("Size"), Schema.animationResourceType.sizeAttribute, null, Localizer.Localize("Size of animation, in bytes"), true), new AttributePropertyDescriptor( Localizer.Localize("# Tracks"), Schema.animationResourceType.tracksAttribute, null, Localizer.Localize("Number of tracks in animation"), true), new AttributePropertyDescriptor( Localizer.Localize("Duration"), Schema.animationResourceType.durationAttribute, null, Localizer.Localize("Duration of animation, in milliseconds"), true), new AttributePropertyDescriptor( Localizer.Localize("Compressed"), Schema.animationResourceType.compressedAttribute, null, Localizer.Localize("Whether or not animation is compressed"), false, new BoolEditor()), })); string[] primitiveKinds = new string[] { "Lines", "Line_Strips", "Polygons", "Polylist", "Triangles", "Triangle_Strips", "Bezier_Curves", "Bezier_Surfaces", "Subdivision_Surfaces" }; Schema.geometryResourceType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( Localizer.Localize("Name"), Schema.geometryResourceType.nameAttribute, null, Localizer.Localize("Geometry name"), false), new AttributePropertyDescriptor( Localizer.Localize("Size"), Schema.geometryResourceType.sizeAttribute, null, Localizer.Localize("Size of geometry, in bytes"), true), new AttributePropertyDescriptor( Localizer.Localize("# Bones"), Schema.geometryResourceType.bonesAttribute, null, Localizer.Localize("Number of bones in geometry"), true), new AttributePropertyDescriptor( Localizer.Localize("# Vertices"), Schema.geometryResourceType.verticesAttribute, null, Localizer.Localize("Number of vertices in geometry"), true), new AttributePropertyDescriptor( Localizer.Localize("Primitive Kind"), Schema.geometryResourceType.verticesAttribute, null, Localizer.Localize("Kind of primitives in geometry"), true, new EnumUITypeEditor(primitiveKinds), new EnumTypeConverter(primitiveKinds)), })); break; // schema only defines one type collection } }