Пример #1
0
            public override void SetValue(object component, object value)
            {
                if (m_font != null && m_font.Equals(value))
                {
                    return;
                }

                if (m_font != null)
                {
                    m_font.Dispose();
                }
                m_font = (Font)value;

                DomNode param = m_domObject.GetChild(SkinSchema.valueInfoType.constructorParamsChild);

                foreach (var arg in param.GetChildren(SkinSchema.constructorParamsType.valueInfoChild))
                {
                    string typeName = (string)arg.GetAttribute(SkinSchema.valueInfoType.typeAttribute);

                    Type type = SkinUtil.GetType(typeName);
                    if (type == typeof(string))
                    {
                        arg.SetAttribute(SkinSchema.valueInfoType.valueAttribute, m_font.FontFamily.Name);
                    }
                    else if (type == typeof(float))
                    {
                        arg.SetAttribute(SkinSchema.valueInfoType.valueAttribute, m_font.Size.ToString());
                    }
                    else if (type == typeof(FontStyle))
                    {
                        arg.SetAttribute(SkinSchema.valueInfoType.valueAttribute, m_font.Style.ToString());
                    }
                }
            }
Пример #2
0
        public IEnumerable <object> GetChildren(object parent)
        {
            DomNode domNode = parent.As <DomNode>();

            if (domNode != null)
            {
                GameReference gameRef = domNode.As <GameReference>();
                if (gameRef != null && gameRef.Target != null)
                {
                    domNode = gameRef.Target.As <DomNode>();
                }

                foreach (ChildInfo childInfo in domNode.Type.Children)
                {
                    // todo use schema annotatoin to mark types that need to have ref slot.
                    bool isReference = Schema.gameObjectReferenceType.Type.IsAssignableFrom(childInfo.Type) ||
                                       Schema.resourceReferenceType.Type.IsAssignableFrom(childInfo.Type);

                    bool hasChild = false;
                    foreach (DomNode child in domNode.GetChildren(childInfo))
                    {
                        hasChild = true;
                        if (child.Is <IListable>())
                        {
                            yield return(child);
                        }
                    }
                    if ((hasChild == false || childInfo.IsList) && isReference)
                    {
                        yield return(new Slot(domNode, childInfo));
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Writes the given document to the given stream</summary>
        /// <param name="document">EventSequenceDocument</param>
        /// <param name="stream">Stream to write to</param>
        public static void Write(EventSequenceDocument document, Stream stream)
        {
            using (StreamWriter writer = new StreamWriter(stream))
            {
                writer.WriteLine("eventSequence");

                DomNode root = document.DomNode;
                foreach (DomNode eventNode in root.GetChildren(DomTypes.eventSequenceType.eventChild))
                {
                    WriteEvent(eventNode, writer);
                }
            }
        }
Пример #4
0
        private static void WriteEvent(DomNode eventNode, StreamWriter writer)
        {
            StringBuilder lineBuilder = new StringBuilder(
                "event name=\"" + eventNode.GetAttribute(DomTypes.eventType.nameAttribute) + "\"");

            WriteAttribute(eventNode, "time", lineBuilder);
            WriteAttribute(eventNode, "duration", lineBuilder);
            writer.WriteLine(lineBuilder.ToString());

            foreach (DomNode resourceNode in eventNode.GetChildren(DomTypes.eventType.resourceChild))
            {
                WriteResource(resourceNode, writer);
            }
        }
Пример #5
0
Файл: Node.cs Проект: zparr/ATF
        /// <summary>
        /// Gets enumeration of the children of the object</summary>
        /// <returns>Enumeration of the children of the object</returns>
        public IEnumerable <object> GetChildren()
        {
            foreach (DomNode dom in DomNode.GetChildren(Schema.node.nodeChild))
            {
                yield return(dom);
            }

            foreach (DomNode dom in DomNode.GetChildren(Schema.node.instance_geometryChild))
            {
                yield return(dom);
            }

            foreach (DomNode dom in DomNode.GetChildren(Schema.node.instance_controllerChild))
            {
                yield return(dom);
            }
        }
Пример #6
0
            public override object GetValue(object component)
            {
                try
                {
                    if (m_font == null)
                    {
                        DomNode   param     = m_domObject.GetChild(SkinSchema.valueInfoType.constructorParamsChild);
                        string    fname     = null;
                        float     fontSize  = 1.0f;
                        FontStyle fontStyle = FontStyle.Regular;

                        foreach (var arg in param.GetChildren(SkinSchema.constructorParamsType.valueInfoChild))
                        {
                            string typeName = (string)arg.GetAttribute(SkinSchema.valueInfoType.typeAttribute);
                            Type   type     = SkinUtil.GetType(typeName);
                            string val      = (string)arg.GetAttribute(SkinSchema.valueInfoType.valueAttribute);

                            if (type == typeof(string))
                            {
                                fname = val;
                            }
                            else if (type == typeof(float))
                            {
                                fontSize = float.Parse(val);
                            }
                            else if (type == typeof(FontStyle))
                            {
                                fontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), val);
                            }
                        }
                        m_font = new Font(fname, fontSize, fontStyle);
                    }
                }
                catch { } // suppress parsing error.

                return(m_font);
            }
Пример #7
0
        private static void WriteEvent(DomNode eventNode, StreamWriter writer)
        {
            StringBuilder lineBuilder = new StringBuilder(
                "event name=\"" + eventNode.GetAttribute(DomTypes.eventType.nameAttribute) + "\"");
            WriteAttribute(eventNode, "time", lineBuilder);
            WriteAttribute(eventNode, "duration", lineBuilder);
            writer.WriteLine(lineBuilder.ToString());

            foreach (DomNode resourceNode in eventNode.GetChildren(DomTypes.eventType.resourceChild))
                WriteResource(resourceNode, writer);
        }