Esempio n. 1
0
        public static void ApplyTheme(this Form window, string themeName = null)
        {
            if (string.IsNullOrEmpty(themeName))
            {
                themeName = "default.theme";
            }

            if (!Path.IsPathRooted(themeName))
            {
                themeName = Path.Combine(Application.StartupPath, themeName);
            }
            using (FileStream fs = File.OpenRead(themeName))
            {
                ThemeStyle[] styles = ThemeParser.Parse(fs);

                foreach (ThemeStyle style in styles)
                {
                    //System.Diagnostics.Debug.Print(style.TargetClass.Name);
                    if (style.Target.IsAssignableFrom(window.GetType()))
                    {
                        style.Apply(window);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void ApplyThemeResource(this Form window, string themeName = null)
        {
            ThemeStyle[] styles = ThemeParser.ParseResource("Paradoxlost.UX.WinForms.Theme.Sample.theme");

            foreach (ThemeStyle style in styles)
            {
                System.Diagnostics.Debug.Print(style.Target.Name);
                if (style.Target.IsAssignableFrom(window.GetType()))
                {
                    style.Apply(window);
                }
            }
        }
Esempio n. 3
0
        private void ParseTheme()
        {
            string themePath = Name;

            if (!IsResource)
            {
                if (!Path.IsPathRooted(themePath))
                {
                    themePath = Path.Combine(Application.StartupPath, themePath);
                }
                using (FileStream fs = File.OpenRead(themePath))
                {
                    Styles = ThemeParser.Parse(fs);
                }
            }
            else
            {
                Styles = ThemeParser.ParseResource(Name);
            }
        }