public WpfApplicationExtension(Application owner)
        {
            _owner = owner ?? throw new ArgumentNullException(nameof(owner));

            _themeHelper  = new WpfSystemThemeHelperExtension(null);
            _currentTheme = _themeHelper.GetSystemTheme();

            SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
        }
Esempio n. 2
0
 public void Version_AdminUpdate()
 {
     if (!EX_Admin.Power("version", "版本管理"))
     {
         AjaxNoPower();
         return;
     }
     //更新系统页面
     SystemTheme.CreateSystemPage();
     Response.Write("{\"msg\":\"OK\"}");
 }
Esempio n. 3
0
        private static void ApplyTheme(ThemeSetting theme)
        {
            var environment = DependencyService.Get <IEnvironment>();

            ResourceDictionary themeDict;
            SystemTheme        systemTheme = environment.GetOperatingSystemTheme();

            switch (theme)
            {
            case ThemeSetting.System:
                if (systemTheme == SystemTheme.Dark)
                {
                    themeDict = new DarkTheme();
                }
                else
                {
                    themeDict = new LightTheme();
                }
                break;

            case ThemeSetting.Light:
                themeDict   = new LightTheme();
                systemTheme = SystemTheme.Light;
                break;

            case ThemeSetting.Dark:
                themeDict   = new DarkTheme();
                systemTheme = SystemTheme.Dark;
                break;

            default:
                throw new NotImplementedException();
            }

            var styleDict = new ElementStyles();

            ICollection <ResourceDictionary> mergedDictionaries = currentApplication?.Resources.MergedDictionaries;

            if (mergedDictionaries != null)
            {
                mergedDictionaries.Clear();
                mergedDictionaries.Add(themeDict);

                // Need to merge theme into style dict before adding as style dict depends on theme
                styleDict.MergedDictionaries.Add(themeDict);
                mergedDictionaries.Add(styleDict);

                // Just add font dict since it doesn't depend on any others
                mergedDictionaries.Add(new AppFonts());
            }

            // Set system theme for platform-specific theming.
            environment.ApplyTheme(systemTheme);
        }
        private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
        {
            // This event is raised when the theme is changed,
            // but also for various other irrelevant reasons.
            // Check the registry first, before forcing the application
            // to refresh everything.
            var newTheme = _themeHelper.GetSystemTheme();

            if (newTheme != _currentTheme)
            {
                _currentTheme = newTheme;
                SystemThemeChanged?.Invoke(this, EventArgs.Empty);
            }
        }
Esempio n. 5
0
 public void ApplyTheme(SystemTheme theme)
 {
 }
 internal SystemPersonalisationChangedEventArgs(SystemTheme theme, bool isColorPrevalence)
 {
     Theme             = theme;
     IsColorPrevalence = isColorPrevalence;
 }