Example #1
0
        /// <summary>
        /// Gets item's display information</summary>
        /// <param name="item">Item being displayed</param>
        /// <param name="info">Item info, to fill out</param>
        public void GetInfo(object item, ItemInfo info)
        {
            DomNode node = item as DomNode;

            if (node != null)
            {
                if (node.Type == UISchema.UIRefType.Type)
                {
                    info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.RefImage);
                    string   label    = string.Empty;
                    UIRef    uiRef    = node.As <UIRef>();
                    UIObject uiTarget = uiRef.UIObject;
                    if (uiTarget != null)
                    {
                        label = uiTarget.Name;
                    }

                    info.Label = "[" + label + "]";
                }
                else if (node.Is <Curve>())
                {
                    Curve cv = node.Cast <Curve>();
                    info.Label      = string.IsNullOrWhiteSpace(cv.DisplayName) ? cv.Name : cv.DisplayName;
                    info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.CurveImage);
                }
                else
                {
                    NodeTypePaletteItem paletteItem = node.Type.GetTag <NodeTypePaletteItem>();
                    if (paletteItem != null)
                    {
                        info.ImageIndex = info.GetImageList().Images.IndexOfKey(paletteItem.ImageName);
                    }

                    info.Label = node.GetId();
                }

                info.IsLeaf = !GetChildren(item).Any();
            }
            else
            {
                EmptyRef emptyRef = item as EmptyRef;
                if (emptyRef != null)
                {
                    info.Label      = "Ref";
                    info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.RefEmptyImage);
                    info.IsLeaf     = true;
                }
            }

            if (string.IsNullOrEmpty(info.Label))
            {
                throw new ArgumentException("info.lable");
            }
        }
Example #2
0
        /// <summary>
        /// Gets display information for the item</summary>
        /// <param name="item">Item</param>
        /// <param name="info">Information object, which client can fill out</param>
        public void GetInfo(object item, ItemInfo info)
        {
            DomNodeType         nodeType    = (DomNodeType)item;
            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                info.Label       = paletteItem.Name;
                info.Description = paletteItem.Description;
                info.ImageIndex  = info.GetImageList().Images.IndexOfKey(paletteItem.ImageName);
            }
        }
Example #3
0
        /// <summary>
        /// Converts the palette item into an object that can be inserted into an
        /// IInstancingContext</summary>
        /// <param name="item">Item to convert</param>
        /// <returns>Object that can be inserted into an IInstancingContext</returns>
        public object Convert(object item)
        {
            DomNodeType         nodeType    = (DomNodeType)item;
            DomNode             node        = new DomNode(nodeType);
            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                node.SetAttribute(nodeType.IdAttribute, paletteItem.Name);
            }
            return(node);
        }
        /// <summary>
        /// Parses annotations in schema sets. Override this to handle custom annotations.
        /// Supports annotations for property descriptors and palette items.</summary>
        /// <param name="schemaSet">XML schema sets being loaded</param>
        /// <param name="annotations">Dictionary of annotations in schema</param>
        protected override void ParseAnnotations(
            XmlSchemaSet schemaSet,
            IDictionary <NamedMetadata, IList <XmlNode> > annotations)
        {
            base.ParseAnnotations(schemaSet, annotations);

            IList <XmlNode> xmlNodes;

            foreach (DomNodeType nodeType in m_typeCollection.GetNodeTypes())
            {
                // parse XML annotation for property descriptors
                if (annotations.TryGetValue(nodeType, out xmlNodes))
                {
                    PropertyDescriptorCollection propertyDescriptors = Sce.Atf.Dom.PropertyDescriptor.ParseXml(nodeType, xmlNodes);

                    // Customizations
                    // The flags and enum support from annotation used to be in ATF 2.8.
                    //  Please request this feature from the ATF team if you need it and a ParseXml overload
                    //  can probably be created.
                    System.ComponentModel.PropertyDescriptor gameFlow = propertyDescriptors["Special Event"];
                    if (gameFlow != null)
                    {
                        FlagsUITypeEditor editor = (FlagsUITypeEditor)gameFlow.GetEditor(typeof(FlagsUITypeEditor));
                        editor.DefineFlags(new string[] {
                            "Reward==Give player the reward",
                            "Trophy==Give player the trophy",
                            "LevelUp==Level up",
                            "BossDies==Boss dies",
                            "PlayerDies==Player dies",
                            "EndCinematic==End cinematic",
                            "EndGame==End game",
                        });
                    }

                    nodeType.SetTag <PropertyDescriptorCollection>(propertyDescriptors);

                    // parse type annotation to create palette items
                    XmlNode xmlNode = FindElement(xmlNodes, "scea.dom.editors");
                    if (xmlNode != null)
                    {
                        string menuText = FindAttribute(xmlNode, "menuText");
                        if (menuText != null) // must have menu text and category
                        {
                            string description       = FindAttribute(xmlNode, "description");
                            string image             = FindAttribute(xmlNode, "image");
                            NodeTypePaletteItem item = new NodeTypePaletteItem(nodeType, menuText, description, image);
                            nodeType.SetTag <NodeTypePaletteItem>(item);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Finishes initializing component by adding palette information and defining module types</summary>
        public virtual void Initialize()
        {
            // add palette info to annotation type, and register with palette
            var annotationItem = new NodeTypePaletteItem(
                annotationType.Type,
                "Comment".Localize(),
                "Create a moveable resizable comment on the circuit canvas".Localize(),
                Sce.Atf.Resources.AnnotationImage);

            if (m_paletteService != null)
            {
                m_paletteService.AddItem(annotationItem, "Misc".Localize("abbreviation for miscellaneous"), this);
            }

            // define editable properties on annotation
            annotationType.Type.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Text".Localize(),
                    annotationType.textAttribute,
                    null,
                    "Comment Text".Localize(),
                    false),
                new AttributePropertyDescriptor(
                    "Background Color".Localize(),                           // name
                    annotationType.backcolorAttribute,                       //AttributeInfo
                    null,                                                    // category
                    "Comment's background color".Localize(),                 //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
                new AttributePropertyDescriptor(
                    "Foreground Color".Localize(),                           // name
                    annotationType.foreColorAttribute,                       //AttributeInfo
                    null,                                                    // category
                    "Comment's foreground color".Localize(),                 //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
            }));


            CreateChildCollectionEditor();

            InitializeProperties();

            LoadNodeDefinition();
        }
Example #6
0
        /// <summary>
        /// Finishes initializing component by adding event and resource items to palette</summary>
        void IInitializable.Initialize()
        {
            string category = "Events and Resources";

            m_paletteService.AddItem(Schema.eventType.Type, category, this);
            foreach (DomNodeType resourceType in m_schemaLoader.GetNodeTypes(Schema.resourceType.Type))
            {
                NodeTypePaletteItem paletteItem = resourceType.GetTag <NodeTypePaletteItem>();
                if (paletteItem != null)
                {
                    m_paletteService.AddItem(resourceType, category, this);
                }
            }
        }
Example #7
0
        /// <summary>
        /// Gets the palette image for the specified type</summary>
        /// <remarks>If there is no image for the specified type, it iterates
        /// through the base class hierarchy to find one</remarks>
        /// <param name="nodeType">DomNodeType</param>
        /// <param name="imageList">ImageList to use for finding the image</param>
        /// <returns>Index of the image if found, -1 if unsuccessful</returns>
        public static int GetTypeImageIndex(DomNodeType nodeType, ImageList imageList)
        {
            int imageIndex = -1;

            if (nodeType != null)
            {
                NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();
                if (paletteItem != null)
                {
                    imageIndex = imageList.Images.IndexOfKey(paletteItem.ImageName);
                }
            }
            return(imageIndex);
        }
Example #8
0
        /// <summary>
        /// Finishes initializing component by adding event and resource items to palette</summary>
        void IInitializable.Initialize()
        {
            string category = "Nodes";

            m_paletteService.AddItem(bitBoxSchema.graphType.Type, category, this);
            foreach (DomNodeType resourceType in m_schemaLoader.GetNodeTypes(bitBoxSchema.nodeType.Type))
            {
                NodeTypePaletteItem paletteItem = resourceType.GetTag <NodeTypePaletteItem>();
                if (paletteItem != null)
                {
                    m_paletteService.AddItem(resourceType, category, this);
                }
            }
        }
Example #9
0
        public void Initialize()
        {
            RegisterSettings();

            // Register palette items based on the schema file's annotations.
            foreach (DomNodeType nodeType in m_schemaLoader.TypeCollection.GetNodeTypes())
            {
                NodeTypePaletteItem item = nodeType.GetTagLocal <NodeTypePaletteItem>();
                if (item != null)
                {
                    Console.WriteLine("reg: " + nodeType.Name);
                    m_paletteService.AddItem(nodeType, item.Category, this);
                }
            }

            m_mainWindow.Loaded += delegate
            {
                if (ResourceRoot == null)
                {
                    ResourceRoot = Application.StartupPath + "\\";
                }
            };


            if (m_scriptingService != null)
            {
                // load this assembly into script domain.
                m_scriptingService.LoadAssembly(GetType().Assembly);
                m_scriptingService.LoadAssembly(Assembly.GetAssembly(typeof(LevelEditorCore.IDesignView)));
                m_scriptingService.LoadAssembly(Assembly.GetAssembly(typeof(RenderingInterop.RenderCommands)));
                m_scriptingService.LoadAssembly(Assembly.GetAssembly(typeof(LevelEditorXLE.Patches)));
                m_scriptingService.ImportAllTypes("LevelEditor");
                m_scriptingService.ImportAllTypes("LevelEditor.DomNodeAdapters");
                m_scriptingService.ImportAllTypes("LevelEditorCore");
                m_scriptingService.ImportAllTypes("Sce.Atf.Controls.Adaptable.Graphs");
                m_scriptingService.ImportAllTypes("RenderingInterop");

                m_scriptingService.SetVariable("editor", this);
                m_scriptingService.SetVariable("bookmarkLister", m_bookmarkLister);

                m_contextRegistry.ActiveContextChanged += delegate
                {
                    EditingContext  editingContext = m_contextRegistry.GetActiveContext <EditingContext>();
                    IHistoryContext hist           = m_contextRegistry.GetActiveContext <IHistoryContext>();
                    m_scriptingService.SetVariable("editingContext", editingContext);
                    m_scriptingService.SetVariable("hist", hist);
                };
            }
        }
Example #10
0
        object IPaletteClient.Convert(object item)
        {
            DomNodeType nodeType = (DomNodeType)item;
            DomNode     node     = new DomNode(nodeType);

            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();
            AttributeInfo       idAttribute = nodeType.IdAttribute;

            if (paletteItem != null &&
                idAttribute != null)
            {
                node.SetAttribute(idAttribute, paletteItem.Name);
            }
            return(node);
        }
        /// <summary>
        /// Finish component initialization by setting up palette items</summary>
        void IInitializable.Initialize()
        {
            string category = "Events and Resources";

            m_paletteService.AddItem(DomTypes.eventType.Type, category, this);
            foreach (DomNodeType domType in m_domTypes)
            {
                if (DomTypes.resourceType.Type.IsAssignableFrom(domType))
                {
                    NodeTypePaletteItem paletteItem = domType.GetTag <NodeTypePaletteItem>();
                    if (paletteItem != null)
                    {
                        m_paletteService.AddItem(domType, category, this);
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        /// Gets item's display information</summary>
        /// <param name="item">Item being displayed</param>
        /// <param name="info">Item info, to fill out</param>
        public void GetInfo(object item, ItemInfo info)
        {
            DomNode node = item as DomNode;

            if (node != null)
            {
                if (node.Type == UISchema.UIRefType.Type)
                {
                    info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.RefImage);
                    string   label    = string.Empty;
                    UIRef    uiRef    = node.As <UIRef>();
                    UIObject uiTarget = uiRef.UIObject;
                    if (uiTarget != null)
                    {
                        label = uiTarget.Name;
                    }

                    info.Label = "[" + label + "]";
                }
                else
                {
                    NodeTypePaletteItem paletteItem = node.Type.GetTag <NodeTypePaletteItem>();
                    if (paletteItem != null)
                    {
                        info.ImageIndex = info.GetImageList().Images.IndexOfKey(paletteItem.ImageName);
                        info.Label      = node.GetId();
                    }
                }

                info.IsLeaf = !Enumerable.Any(GetChildren(item));
                return;
            }
            else
            {
                EmptyRef emptyRef = item as EmptyRef;
                if (emptyRef != null)
                {
                    info.Label      = "Ref";
                    info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.RefEmptyImage);
                    info.IsLeaf     = true;
                }
            }
        }
Example #13
0
        void IPaletteClient.GetInfo(object item, ItemInfo info)
        {
            DomNodeType nodeType = item as DomNodeType;

            if (nodeType != null)
            {
                NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();
                if (paletteItem != null)
                {
                    info.Label       = paletteItem.Name;
                    info.Description = paletteItem.Description;
                    info.ImageIndex  = info.GetImageList().Images.IndexOfKey(paletteItem.ImageName);
                }

                if (info.ImageIndex == -1)
                {
                    info.ImageIndex = Util.GetTypeImageIndex(nodeType, info.GetImageList());
                }
            }
        }
        /// <summary>
        /// Finishes initializing component by adding state and annotation type to palette</summary>
        void IInitializable.Initialize()
        {
            string category = "FSM";
            // add state type to palette
            DomNodeType         stateType   = Schema.stateType.Type;
            NodeTypePaletteItem paletteItem = stateType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                m_paletteService.AddItem(stateType, category, this);
            }

            // add annotation type to palette
            NodeTypePaletteItem annotationItem = Schema.annotationType.Type.GetTag <NodeTypePaletteItem>();

            if (annotationItem != null)
            {
                m_paletteService.AddItem(Schema.annotationType.Type, category, this);
            }
        }
        /// <summary>
        /// Converts the palette item into an object that can be inserted into an
        /// IInstancingContext</summary>
        /// <param name="item">Item to convert</param>
        /// <returns>Object that can be inserted into an IInstancingContext</returns>
        object IPaletteClient.Convert(object item)
        {
            DomNodeType nodeType = (DomNodeType)item;
            DomNode     node     = new DomNode(nodeType);

            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                if (nodeType.IdAttribute != null)
                {
                    node.SetAttribute(nodeType.IdAttribute, paletteItem.Name); // unique id, for referencing
                }
                if (nodeType == Schema.stateType.Type)
                {
                    node.SetAttribute(Schema.stateType.labelAttribute, paletteItem.Name);   // user visible name for state
                }
            }
            return(node);
        }
Example #16
0
        /// <summary>
        /// Converts the palette item into an object that can be inserted into an
        /// IInstancingContext</summary>
        /// <param name="item">Item to convert</param>
        /// <returns>Object that can be inserted into an IInstancingContext</returns>
        object IPaletteClient.Convert(object item)
        {
            DomNodeType nodeType = (DomNodeType)item;
            DomNode     node     = new DomNode(nodeType);

            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                if (nodeType.IdAttribute != null)
                {
                    node.SetAttribute(nodeType.IdAttribute, paletteItem.Name); // unique id, for referencing
                }
                if (bitBoxSchema.nodeType.Type.IsAssignableFrom(nodeType))
                {
                    //string nodeName = m_uniqueNamer.Name();
                    node.SetAttribute(bitBoxSchema.nodeType.nameAttribute, paletteItem.Name);
                }
            }
            return(node);
        }
        /// <summary>
        /// Finishes initializing component by adding information to types for palette</summary>
        void IInitializable.Initialize()
        {
            string statechartCategory = "Statecharts".Localize();

            // add annotation type to palette
            NodeTypePaletteItem annotationItem = Schema.annotationType.Type.GetTag <NodeTypePaletteItem>();

            if (annotationItem != null)
            {
                m_paletteService.AddItem(Schema.annotationType.Type, statechartCategory, this);
            }

            // add state and pseudostate types to palette
            foreach (DomNodeType stateType in m_schemaLoader.GetNodeTypes(Schema.stateBaseType.Type))
            {
                NodeTypePaletteItem stateItem = stateType.GetTag <NodeTypePaletteItem>();
                if (stateItem != null)
                {
                    m_paletteService.AddItem(stateType, statechartCategory, this);
                }
            }
        }
        /// <summary>
        /// Converts the palette item into an object that can be inserted into an
        /// IInstancingContext</summary>
        /// <param name="item">Item to convert</param>
        /// <returns>Object that can be inserted into an IInstancingContext</returns>
        object IPaletteClient.Convert(object item)
        {
            DomNodeType nodeType = (DomNodeType)item;
            DomNode     node     = new DomNode(nodeType);

            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                if (nodeType.IdAttribute != null)
                {
                    node.SetAttribute(nodeType.IdAttribute, paletteItem.Name); // unique id, for referencing
                }
                if (nodeType == DomTypes.eventType.Type)
                {
                    node.SetAttribute(DomTypes.eventType.nameAttribute, paletteItem.Name);
                }
                else if (DomTypes.resourceType.Type.IsAssignableFrom(nodeType))
                {
                    node.SetAttribute(DomTypes.resourceType.nameAttribute, paletteItem.Name);
                }
            }
            return(node);
        }
Example #19
0
        /// <summary>
        /// Finishes initializing component by adding palette information and defining module types</summary>
        public virtual void Initialize()
        {
            // add palette info to annotation type, and register with palette
            var annotationItem = new NodeTypePaletteItem(
                Schema.annotationType.Type,
                "Comment".Localize(),
                "Create a moveable resizable comment on the circuit canvas".Localize(),
                Resources.AnnotationImage);

            m_paletteService.AddItem(annotationItem, PaletteCategory, this);

            // define editable properties on annotation
            Schema.annotationType.Type.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Text".Localize(),
                    Schema.annotationType.textAttribute,
                    null,
                    "Comment Text".Localize(),
                    false),
                new AttributePropertyDescriptor(
                    "Comment Color".Localize(),                              // name
                    Schema.annotationType.backcolorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment background color".Localize(),                   //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
            }));

            // define pin/connection pens

            m_diagramTheme.RegisterCustomPen(BooleanPinTypeName, new Pen(Color.LightSeaGreen, 2));
            m_diagramTheme.RegisterCustomPen(FloatPinTypeName, new Pen(Color.LightSeaGreen, 2));

            // define module types

            DefineModuleType(
                new XmlQualifiedName("buttonType", Schema.NS),
                "Button".Localize(),
                "On/Off Button".Localize(),
                Resources.ButtonImage,
                EmptyArray <ElementType.Pin> .Instance,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), BooleanPinTypeName, 0)
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("lightType", Schema.NS),
                "Light".Localize(),
                "Light source".Localize(),
                Resources.LightImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), BooleanPinTypeName, 0)
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("speakerType", Schema.NS),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                Resources.SpeakerImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), FloatPinTypeName, 0)
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("andType", Schema.NS),
                "And".Localize(),
                "Logical AND".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("orType", Schema.NS),
                "Or".Localize(),
                "Logical OR".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("soundType", Schema.NS),
                "Sound".Localize(),
                "Sound Player".Localize(),
                Resources.SoundImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("On".Localize(), "boolean", 0),
                new ElementType.Pin("Reset".Localize(), "boolean", 1),
                new ElementType.Pin("Pause".Localize(), "boolean", 2),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "float", 0),
            },
                m_schemaLoader);
        }
Example #20
0
        /// <summary>
        /// Finishes initializing component by adding palette information and defining module types</summary>
        public virtual void Initialize()
        {
            // add palette info to annotation type, and register with palette
            var annotationItem = new NodeTypePaletteItem(
                Schema.annotationType.Type,
                "Comment".Localize(),
                "Create a moveable resizable comment on the circuit canvas".Localize(),
                Resources.AnnotationImage);

            m_paletteService.AddItem(
                annotationItem, "Misc".Localize("abbreviation for miscellaneous"), this);

            // define editable properties on annotation
            Schema.annotationType.Type.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Text".Localize(),
                    Schema.annotationType.textAttribute,
                    null,
                    "Comment Text".Localize(),
                    false),
                new AttributePropertyDescriptor(
                    "Background Color".Localize(),                           // name
                    Schema.annotationType.backcolorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment's background color".Localize(),                 //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
                new AttributePropertyDescriptor(
                    "Foreground Color".Localize(),                           // name
                    Schema.annotationType.foreColorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment's foreground color".Localize(),                 //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
            }));

            // define module types

            DefineModuleType(
                new XmlQualifiedName("buttonType", Schema.NS),
                "Button".Localize(),
                "On/Off Button".Localize(),
                Resources.ButtonImage,
                EmptyArray <ElementType.Pin> .Instance,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), BooleanPinTypeName, 0)
            },
                m_schemaLoader);

            var lightType = DefineModuleType(
                new XmlQualifiedName("lightType", Schema.NS),
                "Light".Localize(),
                "Light source".Localize(),
                Resources.LightImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), BooleanPinTypeName, 0)
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);

            // define and add new attribute to light type.
            var featuresAttribute = new AttributeInfo("features".Localize(), AttributeType.IntType);

            featuresAttribute.DefaultValue = 3;
            lightType.Define(featuresAttribute);
            // create property descriptor for the above attribute.
            FlagsUITypeEditor  featuresEditor    = new FlagsUITypeEditor(new[] { "ENERGY STAR", "High CRI" }, new[] { 1, 2 });
            FlagsTypeConverter featuresConverter = new FlagsTypeConverter(new[] { "Energy Star", "High CRI" }, new[] { 1, 2 });

            lightType.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Features".Localize(),
                    featuresAttribute,
                    null,                  //category
                    "Features".Localize(), //description
                    false,
                    featuresEditor,
                    featuresConverter)         //is not read-only
            }));



            DomNodeType speakerNodeType = DefineModuleType(
                new XmlQualifiedName("speakerType", Schema.NS),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                Resources.SpeakerImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), FloatPinTypeName, 0),
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);
            var speakerManufacturerInfo = new AttributeInfo("Manufacturer".Localize(), AttributeType.StringType);

            // add bass level attribute to demo/test BoundedFloatEditor()
            float bassMin   = -1;
            float bassMax   = 1;
            var   bassLevel = new AttributeInfo("bassLevel".Localize("bass level"), AttributeType.FloatType);

            bassLevel.AddRule(new NumericMinRule(bassMin, true));
            bassLevel.AddRule(new NumericMaxRule(bassMax, true));
            bassLevel.DefaultValue = 0.1f;
            //bassLevel.def
            speakerNodeType.Define(bassLevel);

            speakerNodeType.Define(speakerManufacturerInfo);
            speakerNodeType.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Manufacturer".Localize(),
                    speakerManufacturerInfo,
                    null,                      //category
                    "Manufacturer".Localize(), //description
                    false),

                new AttributePropertyDescriptor(
                    "Bass Level".Localize(),
                    bassLevel,
                    null,                    //category
                    "Bass Level".Localize(), //description
                    false,
                    new BoundedFloatEditor(bassMin, bassMax))
            }));

            DefineModuleType(
                new XmlQualifiedName("soundType", Schema.NS),
                "Sound".Localize(),
                "Sound Player".Localize(),
                Resources.SoundImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("On".Localize(), "boolean", 0),
                new ElementType.Pin("Reset".Localize(), "boolean", 1),
                new ElementType.Pin("Pause".Localize(), "boolean", 2),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "float", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("andType", Schema.NS),
                "And".Localize(),
                "Logical AND".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("orType", Schema.NS),
                "Or".Localize(),
                "Logical OR".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("16To1MultiplexerType", Schema.NS),
                "16-to-1 Multiplexer".Localize(),
                "16-to-1 Multiplexer".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
                new ElementType.Pin("In3".Localize(), "boolean", 2),
                new ElementType.Pin("In4".Localize(), "boolean", 3),
                new ElementType.Pin("In5".Localize(), "boolean", 4),
                new ElementType.Pin("In6".Localize(), "boolean", 5),
                new ElementType.Pin("In7".Localize(), "boolean", 6),
                new ElementType.Pin("In8".Localize(), "boolean", 7),
                new ElementType.Pin("In9".Localize(), "boolean", 8),
                new ElementType.Pin("In10".Localize(), "boolean", 9),
                new ElementType.Pin("In11".Localize(), "boolean", 10),
                new ElementType.Pin("In12".Localize(), "boolean", 11),
                new ElementType.Pin("In13".Localize(), "boolean", 12),
                new ElementType.Pin("In14".Localize(), "boolean", 13),
                new ElementType.Pin("In15".Localize(), "boolean", 14),
                new ElementType.Pin("In16".Localize(), "boolean", 15),
                new ElementType.Pin("Select1".Localize("The name of a pin on a circuit element"), "boolean", 16),
                new ElementType.Pin("Select2".Localize("The name of a pin on a circuit element"), "boolean", 17),
                new ElementType.Pin("Select3".Localize("The name of a pin on a circuit element"), "boolean", 18),
                new ElementType.Pin("Select4".Localize("The name of a pin on a circuit element"), "boolean", 19),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("1To16DemultiplexerType", Schema.NS),
                "1-to-16 Demultiplexer".Localize(),
                "1-to-16 Demultiplexer".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Data".Localize(), "boolean", 0),
                new ElementType.Pin("Select1".Localize("The name of a pin on a circuit element"), "boolean", 1),
                new ElementType.Pin("Select2".Localize("The name of a pin on a circuit element"), "boolean", 2),
                new ElementType.Pin("Select3".Localize("The name of a pin on a circuit element"), "boolean", 3),
                new ElementType.Pin("Select4".Localize("The name of a pin on a circuit element"), "boolean", 4),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out1".Localize(), "boolean", 0),
                new ElementType.Pin("Out2".Localize(), "boolean", 1),
                new ElementType.Pin("Out3".Localize(), "boolean", 2),
                new ElementType.Pin("Out4".Localize(), "boolean", 3),
                new ElementType.Pin("Out5".Localize(), "boolean", 4),
                new ElementType.Pin("Out6".Localize(), "boolean", 5),
                new ElementType.Pin("Out7".Localize(), "boolean", 6),
                new ElementType.Pin("Out8".Localize(), "boolean", 7),
                new ElementType.Pin("Out9".Localize(), "boolean", 8),
                new ElementType.Pin("Out10".Localize(), "boolean", 9),
                new ElementType.Pin("Out11".Localize(), "boolean", 10),
                new ElementType.Pin("Out12".Localize(), "boolean", 11),
                new ElementType.Pin("Out13".Localize(), "boolean", 12),
                new ElementType.Pin("Out14".Localize(), "boolean", 13),
                new ElementType.Pin("Out15".Localize(), "boolean", 14),
                new ElementType.Pin("Out16".Localize(), "boolean", 15),
            },
                m_schemaLoader);
        }
Example #21
0
        protected override void ParseAnnotations(
            XmlSchemaSet schemaSet,
            IDictionary <NamedMetadata, IList <XmlNode> > annotations)
        {
            base.ParseAnnotations(schemaSet, annotations);

            foreach (var kv in annotations)
            {
                DomNodeType nodeType = kv.Key as DomNodeType;
                if (kv.Value.Count == 0)
                {
                    continue;
                }

                // create a hash of hidden attributes
                HashSet <string> hiddenprops = new HashSet <string>();
                foreach (XmlNode xmlnode in kv.Value)
                {
                    if (xmlnode.LocalName == "scea.dom.editors.attribute")
                    {
                        XmlAttribute hiddenAttrib = xmlnode.Attributes["hide"];
                        if (hiddenAttrib != null && hiddenAttrib.Value == "true")
                        {
                            XmlAttribute nameAttrib = xmlnode.Attributes["name"];
                            string       name       = (nameAttrib != null) ? nameAttrib.Value : null;
                            if (!string.IsNullOrWhiteSpace(name))
                            {
                                hiddenprops.Add(name);
                            }
                        }

                        LevelEditorXLE.Patches.PatchSchemaAnnotation(xmlnode);
                    }
                }

                if (hiddenprops.Count > 0)
                {
                    nodeType.SetTag(HiddenProperties, hiddenprops);
                }

                PropertyDescriptorCollection localDescriptor      = nodeType.GetTagLocal <PropertyDescriptorCollection>();
                PropertyDescriptorCollection annotationDescriptor = Sce.Atf.Dom.PropertyDescriptor.ParseXml(nodeType, kv.Value);

                // if the type already have local property descriptors
                // then add annotation driven property descriptors to it.
                if (localDescriptor != null)
                {
                    foreach (System.ComponentModel.PropertyDescriptor propDecr in annotationDescriptor)
                    {
                        localDescriptor.Add(propDecr);
                    }
                }
                else
                {
                    localDescriptor = annotationDescriptor;
                }

                if (localDescriptor.Count > 0)
                {
                    nodeType.SetTag <PropertyDescriptorCollection>(localDescriptor);
                }


                // process annotations resourceReferenceTypes.
                XmlNode rfNode = FindElement(kv.Value, Annotations.ReferenceConstraint.Name);
                if (rfNode != null)
                {
                    HashSet <string> extSet = null;
                    string           exts   = FindAttribute(rfNode, Annotations.ReferenceConstraint.ValidResourceFileExts);
                    if (!string.IsNullOrWhiteSpace(exts))
                    {
                        exts = exts.ToLower();
                        char[] sep = { ',' };
                        extSet = new HashSet <string>(exts.Split(sep, StringSplitOptions.RemoveEmptyEntries));
                    }
                    else if (m_gameEngine != null)
                    {
                        string       restype = FindAttribute(rfNode, Annotations.ReferenceConstraint.ResourceType);
                        ResourceInfo resInfo = m_gameEngine.Info.ResourceInfos.GetByType(restype);
                        if (resInfo != null)
                        {
                            extSet = new HashSet <string>(resInfo.FileExts);
                        }
                    }

                    if (extSet != null)
                    {
                        nodeType.SetTag(Annotations.ReferenceConstraint.ValidResourceFileExts, extSet);
                    }

                    nodeType.SetTag(
                        Annotations.ReferenceConstraint.ResourceType,
                        FindAttribute(rfNode, Annotations.ReferenceConstraint.ResourceType));
                }

                // todo use schema annotation to mark  Palette types.
                XmlNode xmlNode = FindElement(kv.Value, "scea.dom.editors");
                if (xmlNode != null)
                {
                    string name        = FindAttribute(xmlNode, "name");
                    string description = FindAttribute(xmlNode, "description");
                    string image       = FindAttribute(xmlNode, "image");
                    string category    = FindAttribute(xmlNode, "category");
                    string menuText    = FindAttribute(xmlNode, "menuText");
                    if (!string.IsNullOrEmpty(category))
                    {
                        NodeTypePaletteItem item = new NodeTypePaletteItem(nodeType, name, description, image, category, menuText);
                        nodeType.SetTag <NodeTypePaletteItem>(item);
                    }
                }

                // handle special extensions
                foreach (XmlNode annot in kv.Value)
                {
                    if (annot.LocalName == "LeGe.OpaqueListable")
                    {
                        var labelAttrib = annot.Attributes["label"];
                        if (labelAttrib != null)
                        {
                            string label = labelAttrib.Value;
                            nodeType.SetTag("OpaqueListable", label);
                        }
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.OpaqueListable>());
                    }
                    else if (annot.LocalName == "LeGe.GameObjectProperties")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.GameObjectProperties>());
                    }
                    else if (annot.LocalName == "LeGe.TransformUpdater")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.TransformUpdater>());
                    }
                    else if (annot.LocalName == "LeGe.TransformObject")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.TransformObject>());
                    }
                    else if (annot.LocalName == "LeGe.GameContext")
                    {
                        nodeType.Define(new ExtensionInfo <GameContext>());
                    }
                    else if (annot.LocalName == "LeGe.VisibleLockable")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.VisibleLockable>());
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        /// Finishes initializing component by adding palette information and defining module types</summary>
        public virtual void Initialize()
        {
            // add palette info to annotation type, and register with palette
            var annotationItem = new NodeTypePaletteItem(
                Schema.annotationType.Type,
                "Comment".Localize(),
                "Create a moveable resizable comment on the circuit canvas".Localize(),
                Resources.AnnotationImage);

            m_paletteService.AddItem(annotationItem, PaletteCategory, this);

            // define editable properties on annotation
            Schema.annotationType.Type.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Text".Localize(),
                    Schema.annotationType.textAttribute,
                    null,
                    "Comment Text".Localize(),
                    false),
                new AttributePropertyDescriptor(
                    "BackColor".Localize(),                                  // name
                    Schema.annotationType.backcolorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment background color".Localize(),                   //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
                new AttributePropertyDescriptor(
                    "ForeColor".Localize(),                                  // name
                    Schema.annotationType.foreColorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment foreground color".Localize(),                   //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
            }));

            // define module types

            DefineModuleType(
                new XmlQualifiedName("buttonType", Schema.NS),
                "Button".Localize(),
                "On/Off Button".Localize(),
                Resources.ButtonImage,
                EmptyArray <ElementType.Pin> .Instance,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), BooleanPinTypeName, 0)
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("lightType", Schema.NS),
                "Light".Localize(),
                "Light source".Localize(),
                Resources.LightImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), BooleanPinTypeName, 0)
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);

            DomNodeType speakerNodeType = DefineModuleType(
                new XmlQualifiedName("speakerType", Schema.NS),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                Resources.SpeakerImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), FloatPinTypeName, 0),
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);
            var speakerManufacturerInfo = new AttributeInfo("Manufacturer".Localize(), AttributeType.StringType);

            speakerNodeType.Define(speakerManufacturerInfo);
            speakerNodeType.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Manufacturer".Localize(),
                    speakerManufacturerInfo,
                    null,                      //category
                    "Manufacturer".Localize(), //description
                    false)                     //is not read-only
            }));

            DefineModuleType(
                new XmlQualifiedName("soundType", Schema.NS),
                "Sound".Localize(),
                "Sound Player".Localize(),
                Resources.SoundImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("On".Localize(), "boolean", 0),
                new ElementType.Pin("Reset".Localize(), "boolean", 1),
                new ElementType.Pin("Pause".Localize(), "boolean", 2),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "float", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("andType", Schema.NS),
                "And".Localize(),
                "Logical AND".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("orType", Schema.NS),
                "Or".Localize(),
                "Logical OR".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("16To1MultiplexerType", Schema.NS),
                "16-to-1 Multiplexer".Localize(),
                "16-to-1 Multiplexer".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize(), "boolean", 0),
                new ElementType.Pin("In2".Localize(), "boolean", 1),
                new ElementType.Pin("In3".Localize(), "boolean", 2),
                new ElementType.Pin("In4".Localize(), "boolean", 3),
                new ElementType.Pin("In5".Localize(), "boolean", 4),
                new ElementType.Pin("In6".Localize(), "boolean", 5),
                new ElementType.Pin("In7".Localize(), "boolean", 6),
                new ElementType.Pin("In8".Localize(), "boolean", 7),
                new ElementType.Pin("In9".Localize(), "boolean", 8),
                new ElementType.Pin("In10".Localize(), "boolean", 9),
                new ElementType.Pin("In11".Localize(), "boolean", 10),
                new ElementType.Pin("In12".Localize(), "boolean", 11),
                new ElementType.Pin("In13".Localize(), "boolean", 12),
                new ElementType.Pin("In14".Localize(), "boolean", 13),
                new ElementType.Pin("In15".Localize(), "boolean", 14),
                new ElementType.Pin("In16".Localize(), "boolean", 15),
                new ElementType.Pin("Select1".Localize(), "boolean", 16),
                new ElementType.Pin("Select2".Localize(), "boolean", 17),
                new ElementType.Pin("Select3".Localize(), "boolean", 18),
                new ElementType.Pin("Select4".Localize(), "boolean", 19),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("1To16DemultiplexerType", Schema.NS),
                "1-to-16 Demultiplexer".Localize(),
                "1-to-16 Demultiplexer".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Data".Localize(), "boolean", 0),
                new ElementType.Pin("Select1".Localize(), "boolean", 1),
                new ElementType.Pin("Select2".Localize(), "boolean", 2),
                new ElementType.Pin("Select3".Localize(), "boolean", 3),
                new ElementType.Pin("Select4".Localize(), "boolean", 4),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out1".Localize(), "boolean", 0),
                new ElementType.Pin("Out2".Localize(), "boolean", 1),
                new ElementType.Pin("Out3".Localize(), "boolean", 2),
                new ElementType.Pin("Out4".Localize(), "boolean", 3),
                new ElementType.Pin("Out5".Localize(), "boolean", 4),
                new ElementType.Pin("Out6".Localize(), "boolean", 5),
                new ElementType.Pin("Out7".Localize(), "boolean", 6),
                new ElementType.Pin("Out8".Localize(), "boolean", 7),
                new ElementType.Pin("Out9".Localize(), "boolean", 8),
                new ElementType.Pin("Out10".Localize(), "boolean", 9),
                new ElementType.Pin("Out11".Localize(), "boolean", 10),
                new ElementType.Pin("Out12".Localize(), "boolean", 11),
                new ElementType.Pin("Out13".Localize(), "boolean", 12),
                new ElementType.Pin("Out14".Localize(), "boolean", 13),
                new ElementType.Pin("Out15".Localize(), "boolean", 14),
                new ElementType.Pin("Out16".Localize(), "boolean", 15),
            },
                m_schemaLoader);
        }
Example #23
0
        protected override void ParseAnnotations(
            XmlSchemaSet schemaSet,
            IDictionary <NamedMetadata, IList <XmlNode> > annotations)
        {
            base.ParseAnnotations(schemaSet, annotations);

            foreach (var kv in annotations)
            {
                DomNodeType nodeType = kv.Key as DomNodeType;
                if (nodeType == null || kv.Value.Count == 0)
                {
                    continue;
                }

                // create a hash of hidden attributes
                HashSet <string> hiddenprops = new HashSet <string>();
                foreach (XmlNode xmlnode in kv.Value)
                {
                    if (xmlnode.LocalName == "scea.dom.editors.attribute")
                    {
                        XmlAttribute hiddenAttrib = xmlnode.Attributes["hide"];
                        if (hiddenAttrib != null && hiddenAttrib.Value == "true")
                        {
                            XmlAttribute nameAttrib = xmlnode.Attributes["name"];
                            string       name       = (nameAttrib != null) ? nameAttrib.Value : null;
                            if (!string.IsNullOrWhiteSpace(name))
                            {
                                hiddenprops.Add(name);
                            }
                        }
                    }
                }
                if (hiddenprops.Count > 0)
                {
                    nodeType.SetTag(HiddenProperties, hiddenprops);
                }

                PropertyDescriptorCollection localDescriptor      = nodeType.GetTagLocal <PropertyDescriptorCollection>();
                PropertyDescriptorCollection annotationDescriptor = Sce.Atf.Dom.PropertyDescriptor.ParseXml(nodeType, kv.Value);

                // if the type already have local property descriptors
                // then add annotation driven property descriptors to it.
                if (localDescriptor != null)
                {
                    foreach (System.ComponentModel.PropertyDescriptor propDecr in annotationDescriptor)
                    {
                        localDescriptor.Add(propDecr);
                    }
                }
                else
                {
                    localDescriptor = annotationDescriptor;
                }

                if (localDescriptor.Count > 0)
                {
                    nodeType.SetTag <PropertyDescriptorCollection>(localDescriptor);
                }


                // annotations resourceReferenceTypes.
                XmlNode rfNode = FindElement(kv.Value, Annotations.ReferenceConstraint.Name);
                if (rfNode != null)
                {
                    string           exts   = FindAttribute(rfNode, Annotations.ReferenceConstraint.ValidResourceFileExts);
                    char[]           sep    = { ';' };
                    HashSet <string> extSet = new HashSet <string>(exts.Split(sep, StringSplitOptions.RemoveEmptyEntries));
                    nodeType.SetTag(Annotations.ReferenceConstraint.ValidResourceFileExts, extSet);
                }

                // todo use schema annotation to mark  Palette types.
                XmlNode xmlNode = FindElement(kv.Value, "scea.dom.editors");
                if (xmlNode != null)
                {
                    string name              = FindAttribute(xmlNode, "name");
                    string description       = FindAttribute(xmlNode, "description");
                    string image             = FindAttribute(xmlNode, "image");
                    string category          = FindAttribute(xmlNode, "category");
                    string menuText          = FindAttribute(xmlNode, "menuText");
                    NodeTypePaletteItem item = new NodeTypePaletteItem(nodeType, name, description, image, category,
                                                                       menuText);
                    nodeType.SetTag <NodeTypePaletteItem>(item);
                }
            }
        }