Exemple #1
0
        public static AlephTheme GetFallback()
        {
            var t = new AlephTheme("DEFAULT_THEME_FALLBACK", new Version(0, 0, 0, 0), CompatibilityVersionRange.ANY, "NULL", "<!-- fallback -->", "auto generated", AlephThemeType.Fallback);

            var r = new Random();

            foreach (var propdef in AlephTheme.THEME_PROPERTIES)
            {
                switch (propdef.Item2)
                {
                case AlephTheme.AlephThemePropType.Color:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = ColorRef.GetRandom(r), XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                case AlephTheme.AlephThemePropType.Brush:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = BrushRef.CreateSolid(ColorRef.GetRandom(r)), XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                case AlephTheme.AlephThemePropType.Thickness:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = ThicknessRef.Create(r.Next(16), r.Next(16), r.Next(16), r.Next(16)), XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                case AlephTheme.AlephThemePropType.Integer:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = r.Next(16), XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                case AlephTheme.AlephThemePropType.Double:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = r.NextDouble() * 16, XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                case AlephTheme.AlephThemePropType.Boolean:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = (r.Next() % 2 == 0), XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                case AlephTheme.AlephThemePropType.CornerRadius:
                    t.AddProperty(propdef.Item1, new AlephThemePropertyValue {
                        IsIndirect = false, DirectValue = CornerRadiusRef.Create(r.Next(6)), XmlDirectValue = "random", IndirectionTarget = null
                    });
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            return(t);
        }
Exemple #2
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);
        }
        public static AlephTheme GetFallback()
        {
            var t = new AlephTheme("DEFAULT_THEME_FALLBACK", new Version(0, 0, 0, 0), CompatibilityVersionRange.ANY, "NULL", "<!-- fallback -->", true);

            var r = new Random();

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

                case AlephTheme.AlephThemePropType.Brush:
                    t.AddProperty(propdef.Item1, BrushRef.CreateSolid(ColorRef.GetRandom(r)));
                    break;

                case AlephTheme.AlephThemePropType.Thickness:
                    t.AddProperty(propdef.Item1, ThicknessRef.Create(r.Next(16), r.Next(16), r.Next(16), r.Next(16)));
                    break;

                case AlephTheme.AlephThemePropType.Integer:
                    t.AddProperty(propdef.Item1, r.Next(16));
                    break;

                case AlephTheme.AlephThemePropType.Double:
                    t.AddProperty(propdef.Item1, r.NextDouble() * 16);
                    break;

                case AlephTheme.AlephThemePropType.Boolean:
                    t.AddProperty(propdef.Item1, r.Next() % 2 == 0);
                    break;

                case AlephTheme.AlephThemePropType.CornerRadius:
                    t.AddProperty(propdef.Item1, CornerRadiusRef.Create(r.Next(6)));
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            return(t);
        }
        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);
        }
Exemple #5
0
 public AlephThemeSet(AlephTheme t0, AlephTheme t1, IReadOnlyList <AlephTheme> mm)
 {
     DefaultTheme = t0;
     BaseTheme    = t1;
     Modifiers    = mm;
 }
Exemple #6
0
 public void ReplaceTheme(AlephTheme theme)
 {
     _cache[theme.SourceFilename.ToLower()] = theme;
 }