Esempio n. 1
0
        public void DeserializeXml(IResourceProvider theme, XmlReader xmlReader)
        {
            Name       = xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.Name));
            Foreground = Text.TextHelper.ParseResource(xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.Foreground)));
            if (!theme.ContainsResource(Foreground))
            {
                throw new InvalidOperationException(string.Format("Resource '{0}' not found", Foreground));
            }
            Size       = int.Parse(xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.Size)));
            FontFamily = xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.FontFamily));

            string eTextAlignment = xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.TextAlignment));

            TextAlignment = string.IsNullOrEmpty(eTextAlignment) ? TextAlignment.Leading : Text.TextHelper.ParseEnum <TextAlignment>(eTextAlignment);

            string eParagraphAlignment = xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.ParagraphAlignment));

            ParagraphAlignment = string.IsNullOrEmpty(eParagraphAlignment) ? ParagraphAlignment.Near : Text.TextHelper.ParseEnum <ParagraphAlignment>(eParagraphAlignment);

            string eFontStyle = xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.FontStyle));

            FontStyle = string.IsNullOrEmpty(eFontStyle) ? FontStyle.Normal : Text.TextHelper.ParseEnum <FontStyle>(eFontStyle);

            string eFontWeight = xmlReader.GetAttribute(ReflectionHelper.GetPropertyName((TextStyle t) => t.FontWeight));

            FontWeight = string.IsNullOrEmpty(eFontWeight) ? FontWeight.Normal : Text.TextHelper.ParseEnum <FontWeight>(eFontWeight);

            xmlReader.ReadStartElement();
        }
Esempio n. 2
0
        public void DeserializeXml(IResourceProvider resourceProvider, XmlReader xmlReader)
        {
            TargetProperty = xmlReader.GetAttribute("TargetProperty");

            TargetName = Text.TextHelper.ParseResource(xmlReader.GetAttribute("TargetName"));
            if (!resourceProvider.ContainsResource(TargetName))
            {
                throw new InvalidOperationException(String.Format("No resource '{0}' found", TargetName));
            }

            string function = xmlReader.GetAttribute("Function");

            if (!string.IsNullOrEmpty(function))
            {
                // It seems that Type.GetMethods does not return inherited methods
                var method = ReflectionHelper.GetMethod(GetType(), function) ??
                             ReflectionHelper.GetMethod(typeof(AnimationCurve <TKeyFrame>), function);

                Function = (CurveFunction)method.CreateDelegate(typeof(CurveFunction));
                string options = xmlReader.GetAttribute("Options");
                if (!string.IsNullOrEmpty(options))
                {
                    functionOptions = DeserializeOptions(method.Name, options, resourceProvider);
                }
            }

            xmlReader.ReadStartElement();

            while (xmlReader.IsStartElement())
            {
                string type     = xmlReader.LocalName;
                var    keyFrame = (ISerializableResource)
                                  Activator.CreateInstance(Type.GetType(String.Format("Odyssey.Animations.{0}, Odyssey.Common", type)));
                keyFrame.DeserializeXml(resourceProvider, xmlReader);
                AddKeyFrame((TKeyFrame)keyFrame);
            }

            xmlReader.ReadEndElement();
        }
        protected override bool ContainsResource(string resourceName)
        {
            IResourceProvider resourceProvider = Overlay;

            return(resourceProvider.ContainsResource(resourceName));
        }
Esempio n. 4
0
        bool IResourceProvider.ContainsResource(string resourceName)
        {
            IResourceProvider resourceProvider = entityMap;

            return(resourceProvider.ContainsResource(resourceName));
        }