private void DefineModuleType( XmlQualifiedName name, string displayName, string description, string imageName, ElementType.Pin[] inputs, ElementType.Pin[] outputs, SchemaLoader loader) { // turn input pins into attributes on the type var attributes = new List <AttributeInfo>(); foreach (ElementType.Pin pin in inputs) { attributes.Add( new AttributeInfo( pin.Name, (pin.TypeName == BooleanPinTypeName) ? BooleanPinType : FloatPinType)); } // create the type var type = new DomNodeType( name.ToString(), Schema.moduleType.Type, attributes, EmptyArray <ChildInfo> .Instance, EmptyArray <ExtensionInfo> .Instance); // add it to the schema-defined types loader.AddNodeType(name.ToString(), type); // create an element type and add it to the type metadata // For now, let all circuit elements be used as 'connectors' which means // that their pins will be used to create the pins on a master instance. bool isConnector = true; //(inputs.Length + outputs.Length) == 1; type.SetTag <ICircuitElementType>( new ElementType( displayName, isConnector, new Size(), ResourceUtil.GetImage32(imageName), inputs, outputs)); // add the type to the palette m_paletteService.AddItem( new NodeTypePaletteItem( type, displayName, description, imageName), PaletteCategory, this); }
/// <summary> /// Prepare metadata for the module type, to be used by the palette and circuit drawing engine</summary> /// <param name="name"> Schema full name of the DomNodeType for the module type</param> /// <param name="displayName">Display name for the module type</param> /// <param name="description"></param> /// <param name="imageName">Image name </param> /// <param name="inputs">Define input pins for the module type</param> /// <param name="outputs">Define output pins for the module type</param> /// <param name="loader">XML schema loader </param> /// <param name="domNodeType">optional DomNode type for the module type</param> /// <returns>DomNodeType that was created (or the domNodeType parameter, if it wasn't null)</returns> protected DomNodeType DefineModuleType( XmlQualifiedName name, string displayName, string description, string imageName, ElementType.Pin[] inputs, ElementType.Pin[] outputs, SchemaLoader loader, DomNodeType domNodeType = null) { if (domNodeType == null) { // create the type domNodeType = new DomNodeType( name.ToString(), Schema.moduleType.Type, EmptyArray <AttributeInfo> .Instance, EmptyArray <ChildInfo> .Instance, EmptyArray <ExtensionInfo> .Instance); } DefineCircuitType(domNodeType, displayName, imageName, inputs, outputs); // add it to the schema-defined types loader.AddNodeType(name.ToString(), domNodeType); // add the type to the palette m_paletteService.AddItem( new NodeTypePaletteItem( domNodeType, displayName, description, imageName), PaletteCategory, this); return(domNodeType); }
/// <summary> /// Prepare metadata for the module type, to be used by the palette and circuit drawing engine</summary> /// <param name="name"> Schema full name of the DomNodeType for the module type</param> /// <param name="displayName">Display name for the module type</param> /// <param name="description"></param> /// <param name="imageName">Image name </param> /// <param name="inputs">Define input pins for the module type</param> /// <param name="outputs">Define output pins for the module type</param> /// <param name="loader">XML schema loader </param> /// <param name="domNodeType">optional DomNode type for the module type</param> /// <returns>DomNodeType that was created (or the domNodeType parameter, if it wasn't null)</returns> protected DomNodeType DefineModuleType( XmlQualifiedName name, string displayName, string description, string imageName, ElementType.Pin[] inputs, ElementType.Pin[] outputs, SchemaLoader loader, DomNodeType domNodeType = null) { if (domNodeType == null) // create the type domNodeType = new DomNodeType( name.ToString(), Schema.moduleType.Type, EmptyArray<AttributeInfo>.Instance, EmptyArray<ChildInfo>.Instance, EmptyArray<ExtensionInfo>.Instance); DefineCircuitType(domNodeType, displayName, imageName, inputs, outputs); // add it to the schema-defined types loader.AddNodeType(name.ToString(), domNodeType); // add the type to the palette m_paletteService.AddItem( new NodeTypePaletteItem( domNodeType, displayName, description, imageName), PaletteCategory, this); return domNodeType; }
private void DefineModuleType( XmlQualifiedName name, string displayName, string description, string imageName, ElementType.Pin[] inputs, ElementType.Pin[] outputs, SchemaLoader loader) { // turn input pins into attributes on the type var attributes = new List<AttributeInfo>(); foreach (ElementType.Pin pin in inputs) attributes.Add( new AttributeInfo( pin.Name, (pin.TypeName == BooleanPinTypeName) ? BooleanPinType : FloatPinType)); // create the type var type = new DomNodeType( name.ToString(), Schema.moduleType.Type, attributes, EmptyArray<ChildInfo>.Instance, EmptyArray<ExtensionInfo>.Instance); // add it to the schema-defined types loader.AddNodeType(name.ToString(), type); // create an element type and add it to the type metadata // For now, let all circuit elements be used as 'connectors' which means // that their pins will be used to create the pins on a master instance. bool isConnector = true; //(inputs.Length + outputs.Length) == 1; type.SetTag<ICircuitElementType>( new ElementType( displayName, isConnector, new Size(), ResourceUtil.GetImage32(imageName), inputs, outputs)); // add the type to the palette m_paletteService.AddItem( new NodeTypePaletteItem( type, displayName, description, imageName), PaletteCategory, this); }