예제 #1
0
        public AlephTheme Generate()
        {
            var t = new AlephTheme(_name, _version, _compatibility, _filename, _source, _author, _themetype);

            foreach (var propdef in AlephTheme.THEME_PROPERTIES)
            {
                var v = TryGetProperty(propdef.Item1);
                if (v == null)
                {
                    continue;
                }

                if (v.IsIndirect)
                {
                    t.AddProperty(propdef.Item1, v); continue;
                }

                switch (propdef.Item2)
                {
                case AlephTheme.AlephThemePropType.Color:
                    v.DirectValue = ColorRef.Parse(v.XmlDirectValue);
                    break;

                case AlephTheme.AlephThemePropType.Brush:
                    v.DirectValue = BrushRef.Parse(v.XmlDirectValue);
                    break;

                case AlephTheme.AlephThemePropType.Thickness:
                    v.DirectValue = ThicknessRef.Parse(v.XmlDirectValue);
                    break;

                case AlephTheme.AlephThemePropType.Integer:
                    v.DirectValue = int.Parse(v.XmlDirectValue);
                    break;

                case AlephTheme.AlephThemePropType.Double:
                    v.DirectValue = double.Parse(v.XmlDirectValue, NumberStyles.Float, CultureInfo.InvariantCulture);
                    break;

                case AlephTheme.AlephThemePropType.Boolean:
                    v.DirectValue = XElementExtensions.ParseBool(v.XmlDirectValue);
                    break;

                case AlephTheme.AlephThemePropType.CornerRadius:
                    v.DirectValue = CornerRadiusRef.Parse(v.XmlDirectValue);
                    break;

                default:
                    throw new NotSupportedException();
                }

                t.AddProperty(propdef.Item1, v);
            }

            return(t);
        }
예제 #2
0
        public AlephTheme Generate()
        {
            var t = new AlephTheme(_name, _version, _compatibility, _filename, _source, false);

            foreach (var propdef in AlephTheme.THEME_PROPERTIES)
            {
                switch (propdef.Item2)
                {
                case AlephTheme.AlephThemePropType.Color:
                    t.AddProperty(propdef.Item1, ColorRef.Parse(GetProperty(propdef.Item1)));
                    break;

                case AlephTheme.AlephThemePropType.Brush:
                    t.AddProperty(propdef.Item1, BrushRef.Parse(GetProperty(propdef.Item1)));
                    break;

                case AlephTheme.AlephThemePropType.Thickness:
                    t.AddProperty(propdef.Item1, ThicknessRef.Parse(GetProperty(propdef.Item1)));
                    break;

                case AlephTheme.AlephThemePropType.Integer:
                    t.AddProperty(propdef.Item1, int.Parse(GetProperty(propdef.Item1)));
                    break;

                case AlephTheme.AlephThemePropType.Double:
                    t.AddProperty(propdef.Item1, double.Parse(GetProperty(propdef.Item1), NumberStyles.Float, CultureInfo.InvariantCulture));
                    break;

                case AlephTheme.AlephThemePropType.Boolean:
                    t.AddProperty(propdef.Item1, XElementExtensions.ParseBool(GetProperty(propdef.Item1)));
                    break;

                case AlephTheme.AlephThemePropType.CornerRadius:
                    t.AddProperty(propdef.Item1, CornerRadiusRef.Parse(GetProperty(propdef.Item1)));
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            return(t);
        }