예제 #1
0
        private void LoadConfig()
        {
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (localSettings.Values["AlwaysShowNavigation"] != null)
            {
                App.AlwaysShowNavigation = (bool)localSettings.Values["AlwaysShowNavigation"];
            }
            else
            {
                App.AlwaysShowNavigation = true;
            }

            if (localSettings.Values["BlogCountOneTime"] != null)
            {
                App.BlogCountOneTime = int.Parse(localSettings.Values["BlogCountOneTime"].ToString());
            }
            else
            {
                App.BlogCountOneTime = 20;
            }

            if (localSettings.Values["Theme"] != null)
            {
                App.Theme = (ApplicationTheme)Enum.Parse(typeof(ApplicationTheme), localSettings.Values["Theme"].ToString());
            }
            else
            {
                App.Theme = ApplicationTheme.Light;
            }
        }
예제 #2
0
 public AppSetting(ApplicationTheme theme,
                   ObservableCollection <string> excludeTags,
                   bool disableDomainFronting,
                   IllustrationSortOption defaultSortOption,
                   SearchTagMatchOption searchTagMatchOption,
                   TargetFilter targetFilter,
                   int pageLimitForKeywordSearch,
                   int searchStartingFromPageNumber,
                   int pageLimitForSpotlight,
                   string?mirrorHost,
                   int maxDownloadTaskConcurrencyLevel,
                   bool displayTeachingTipWhenGeneratingAppLink,
                   int itemsNumberLimitForDailyRecommendations,
                   bool filtrateRestrictedContent,
                   bool useFileCache)
 {
     Theme                                   = theme;
     ExcludeTags                             = excludeTags;
     DisableDomainFronting                   = disableDomainFronting;
     DefaultSortOption                       = defaultSortOption;
     TagMatchOption                          = searchTagMatchOption;
     TargetFilter                            = targetFilter;
     PageLimitForKeywordSearch               = pageLimitForKeywordSearch;
     SearchStartingFromPageNumber            = searchStartingFromPageNumber;
     PageLimitForSpotlight                   = pageLimitForSpotlight;
     MirrorHost                              = mirrorHost;
     MaxDownloadTaskConcurrencyLevel         = maxDownloadTaskConcurrencyLevel;
     DisplayTeachingTipWhenGeneratingAppLink = displayTeachingTipWhenGeneratingAppLink;
     ItemsNumberLimitForDailyRecommendations = itemsNumberLimitForDailyRecommendations;
     FiltrateRestrictedContent               = filtrateRestrictedContent;
     UseFileCache                            = useFileCache;
 }
예제 #3
0
 private void ChangeTheme(ApplicationTheme theme)
 {
     if (theme != Scontroller.GetAppTheme())
     {
         _Scontroller.UpdateAppTheme(theme);
     }
 }
예제 #4
0
        public static void SetRequestedTheme(Application application, ApplicationTheme requestedTheme)
        {
            RequestedTheme = requestedTheme;
            var requestedThemeName = (requestedTheme == ApplicationTheme.Default || requestedTheme == ApplicationTheme.Dark) ? "Default" : "Light";

            application.Startup += (sender, args) =>
            {
                var themeResource = new Uri($"pack://application:,,,/Fluent.UI.Controls;component/Themes/ThemeResources.{requestedThemeName}.xaml", UriKind.Absolute);
                application.Resources.MergedDictionaries.Insert(0, new SharedResourceDictionary {
                    Source = themeResource
                });

                var assemblyType  = Type.GetType("Fluent.UI.Controls.ButtonExtension, Fluent.UI.Controls");
                var extensionType = Type.GetType("Fluent.UI.Core.FrameworkElementExtension, Fluent.UI.Core");

                foreach (var type in Assembly.GetAssembly(assemblyType).GetTypes())
                {
                    if (type.GetCustomAttributes(typeof(DefaultStyleTargetAttribute), true).Length > 0)
                    {
                        var targetType = type.GetAttributeValue((DefaultStyleTargetAttribute x) => x.TargetType);
                        MergeThemeResource(application, (ElementTheme)requestedTheme, targetType);
                    }
                }
            };
        }
예제 #5
0
        private static void ParseStyleforThemes(ApplicationTheme theme)
        {
            string ThemeColor = (theme == ApplicationTheme.Light) ? nameof(ElementTheme.Light) : nameof(ElementTheme.Default);

            try
            {
                var myResourceDictionary = new ResourceDictionary();
                myResourceDictionary.Source = new Uri("ms-appx:///Styles/Custom.xaml", UriKind.RelativeOrAbsolute);
                ResourceDictionary themeResource = myResourceDictionary.ThemeDictionaries[ThemeColor] as ResourceDictionary;

                Style HamburgerMenuStyle = themeResource["HamburgerMenuStyle"] as Style;

                NavButtonCheckedForegroundBrush = ((from item in HamburgerMenuStyle.Setters.Cast <Setter>().Where(item => item.Property == HamburgerMenu.NavButtonCheckedForegroundProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
                NavButtonCheckedBackgroundBrush = ((from item in HamburgerMenuStyle.Setters.Cast <Setter>().Where(item => item.Property == HamburgerMenu.NavButtonCheckedBackgroundProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
                NavButtonCheckedIndicatorBrush  = ((from item in HamburgerMenuStyle.Setters.Cast <Setter>().Where(item => item.Property == HamburgerMenu.NavButtonCheckedIndicatorBrushProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
                NavButtonBackgroundBrush        = ((from item in HamburgerMenuStyle.Setters.Cast <Setter>().Where(item => item.Property == HamburgerMenu.NavButtonBackgroundProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
                SecondarySeparatorBrush         = ((from item in HamburgerMenuStyle.Setters.Cast <Setter>().Where(item => item.Property == HamburgerMenu.SecondarySeparatorProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
            }

            catch
            {
                // PopulateDefaultColors() will take care of this!
            }

            NavButtonCheckedForegroundBrush = NavButtonCheckedForegroundBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonCheckedForegroundBrush)];
            NavButtonCheckedBackgroundBrush = NavButtonCheckedBackgroundBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonCheckedBackgroundBrush)];
            NavButtonCheckedIndicatorBrush  = NavButtonCheckedIndicatorBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonCheckedIndicatorBrush)];
            NavButtonBackgroundBrush        = NavButtonBackgroundBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonBackgroundBrush)];
            SecondarySeparatorBrush         = SecondarySeparatorBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(SecondarySeparatorBrush)];
        }
예제 #6
0
        /// <summary>
        /// Handles the changing of the application theme by changing the current application
        /// theme to the specified new theme throughout the application.
        /// </summary>
        /// <param name="newTheme">The theme to change to.</param>
        private void OnThemeChanged(ApplicationTheme newTheme)
        {
            // Change the theme throughout the application
            var themeService = IoC.Get <IThemeService>();

            themeService.ChangeTheme(newTheme);
        }
        public void RefreshStyles(ApplicationTheme theme, bool clearExisting = false)
        {
            DebugWrite($"Theme: {theme}");

            RequestedTheme = theme.ToElementTheme();
            RefreshStyles(AccentColor, clearExisting);
        }
        public void RefreshStyles(ApplicationTheme theme)
        {
            DebugWrite($"Theme: {theme}");

            RequestedTheme = theme.ToElementTheme();
            RefreshStyles(AccentColor);
        }
        public void RefreshStyles(ApplicationTheme theme)
        {
            DebugWrite($"Theme: {theme}");

            RequestedTheme = theme.ToElementTheme();
            RefreshStyles(AccentColor);
        }
예제 #10
0
 public MainWindow()
 {
     InitializeComponent();
     themeListener           = new ThemeListener();
     currentApplicationTheme = ApplicationTheme.Light;
     followSystemTheme       = true;
 }
예제 #11
0
        public App()
        {
            ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            apptheme = this.RequestedTheme;
            if (localSettings.Values["theme"] == null)
            {
                localSettings.Values["theme"] = "light";
                this.RequestedTheme           = ApplicationTheme.Light;
            }
            else if (localSettings.Values["theme"].ToString() == "light")
            {
                this.RequestedTheme = ApplicationTheme.Light;
            }
            else if (localSettings.Values["theme"].ToString() == "night")
            {
                this.RequestedTheme = ApplicationTheme.Dark;
            }
            if (localSettings.Values["sound"] == null)
            {
                localSettings.Values["sound"] = "0";
            }
            else if (localSettings.Values["sound"].ToString() == "0")
            {
                ElementSoundPlayer.State = ElementSoundPlayerState.Off;
            }
            else
            {
                ElementSoundPlayer.State  = ElementSoundPlayerState.On;
                ElementSoundPlayer.Volume = 1.0;
            }
            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }
예제 #12
0
        public void RefreshStyles(ApplicationTheme theme, bool clearExisting = false)
        {
            DebugWrite($"Theme: {theme}");

            RequestedTheme = theme.ToElementTheme();
            RefreshStyles(AccentColor, clearExisting);
        }
예제 #13
0
        //テーマを設定するApp.xaml.csでしか変更できない模様
        private void setTheme()
        {
            //ダークモード・ライトテーマを読み込む
            if (setting.Values["setting_theme"] != null)
            {
                switch (setting.Values["setting_theme"])
                {
                case "setting_theme_dark":
                    //ダーク
                    RequestedTheme = ApplicationTheme.Dark;
                    break;

                case "setting_theme_light":
                    //ライト
                    RequestedTheme = ApplicationTheme.Light;
                    break;

                case "setting_theme_auto":
                    //Windowsの設定に従う
                    ApplicationTheme appTheme = Application.Current.RequestedTheme;
                    if (appTheme == 0)
                    {
                        //ライト
                        RequestedTheme = ApplicationTheme.Light;
                    }
                    else
                    {
                        //ダーク
                        RequestedTheme = ApplicationTheme.Dark;
                    }
                    break;
                }
            }
        }
        public void ApplicationThemeTest()
        {
            var operation = new ApplicationTheme {
                Name = "theme"
            };

            Assert.AreEqual("theme", operation.Name);
        }
예제 #15
0
        protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app)
        {
            base.InitializeApp(pluginManager, app);

            ApplicationTheme theme = Mvx.IoCProvider.Resolve <ISettingsService>().Theme;
            //(app as UWPApplication).RequestedTheme =
            //    (Windows.UI.Xaml.ApplicationTheme)((theme == ApplicationTheme.Default) ? ApplicationTheme.Light : theme);
        }
        /// <summary>
        /// Start is called before the first frame
        /// </summary>
        void Start()
        {
            this.spriteRenderer = this.gameObject.GetComponent <SpriteRenderer>();

            this.spriteRenderer.sprite = ApplicationTheme.CurrentTheme.GetBackground();

            ApplicationTheme.ScaleBackground(this.gameObject, ApplicationTheme.CurrentTheme.GetBackground());
        }
예제 #17
0
 internal void UpdateTheme(ApplicationTheme theme)
 {
     if (ThemeManager.Current.ApplicationTheme != theme)
     {
         ThemeManager.Current.ApplicationTheme           = theme;
         ModernWpf.ThemeManager.Current.ApplicationTheme = theme == ApplicationTheme.Light ? (ModernWpf.ApplicationTheme?)ModernWpf.ApplicationTheme.Light : (ModernWpf.ApplicationTheme?)ModernWpf.ApplicationTheme.Dark;
     }
 }
예제 #18
0
 /// <summary>
 /// Sets the application theme colors
 /// </summary>
 /// <returns></returns>
 public static IApplicationBuilder UseTheme(this IApplicationBuilder builder, ApplicationColors colors)
 {
     builder.BuildActionsCoordinator.AddAction(DefaultBuildActions.ApplicationThemeAction((container) =>
     {
         ApplicationTheme.SetTheme(colors);
     }));
     return(builder);
 }
예제 #19
0
파일: Application.cs 프로젝트: jokm1/uno-2
        private void SetRequestedTheme(ApplicationTheme requestedTheme)
        {
            if (requestedTheme != _requestedTheme)
            {
                _requestedTheme = requestedTheme;

                OnRequestedThemeChanged();
            }
        }
예제 #20
0
        private void DarkThemeToggle_Toggled(object sender, RoutedEventArgs e)
        {
            ApplicationTheme selectedTheme = this.DarkThemeToggle.IsOn ? ApplicationTheme.Dark : ApplicationTheme.Light;

            Settings.ApplicationTheme = selectedTheme;
            var appShell = Window.Current.Content as AppShell;

            appShell.RequestedTheme = selectedTheme == ApplicationTheme.Dark ? ElementTheme.Dark : ElementTheme.Light;
        }
 public SettingsPage()
 {
     InitializeComponent();
     _SerializationService = SerializationService.Json;
     // load the apptheme setting
     _settings         = SettingsService.Instance;
     _startTheme       = _settings.AppTheme;
     _startSystemTheme = _settings.UseSystemTheme;
 }
예제 #22
0
        public void UpdateAppTheme(ApplicationTheme theme)
        {
            userSettings.applicationTheme = theme;
            SaveSettings();

            // TODO: change theme dynamically
            // update listview styles
            //App._shell.RequestedTheme = (ElementTheme)theme;
        }
예제 #23
0
        public ApplicationThemeTest()
        {
            TestBootstrapper bootstrapper = new TestBootstrapper();

            bootstrapper.Run();

            ctt        = new ApplicationTheme();
            colorBrush = new SolidColorBrush(Color.FromRgb(200, 100, 0));
        }
예제 #24
0
        internal void UpdateSkin(ApplicationTheme theme)
        {
            ThemeManager.Current.ApplicationTheme = theme;
            var demoResources = new ResourceDictionary
            {
                Source = PackUriHelper.GetAbsoluteUri("HandyControlDemo", $"/Resources/Themes/Basic/Colors/{theme.ToString()}.xaml")
            };

            Resources.MergedDictionaries[0].MergedDictionaries.InsertOrReplace(1, demoResources);
        }
예제 #25
0
        public void OnThemeChanged(ApplicationTheme theme)
        {
            var applicationTheme = ControlzEx.Theming.ThemeManager.Current.DetectTheme(Application.Current);

            if (applicationTheme != null)
            {
                Plugin.Contract.Theming.ThemeManager.ChangeTheme(this.Resources, applicationTheme.BaseColorScheme);
                ControlzEx.Theming.ThemeManager.Current.ChangeTheme(this, this.Resources, applicationTheme);
            }
        }
예제 #26
0
 internal static void SaveTheme(ApplicationTheme theme)
 {
     try
     {
         ApplicationData.Current.RoamingSettings.Values["Theme"] = (int)theme;
     }
     catch (Exception)
     {
     }
 }
예제 #27
0
 public static void SetTheme(ApplicationTheme theme)
 {
     if (ApplicationData.Current.LocalSettings.Values.ContainsKey(ThemeTypeKey))
     {
         ApplicationData.Current.LocalSettings.Values[ThemeTypeKey] = theme.ToString();
     }
     else
     {
         ApplicationData.Current.LocalSettings.Values.Add(ThemeTypeKey, theme.ToString());
     }
 }
예제 #28
0
 public static void SetApplicationTheme(ApplicationTheme theme)
 {
     if (theme == ApplicationTheme.Dark)
     {
         GoToDarkTheme();
     }
     else
     {
         GoToLightTheme();
     }
 }
예제 #29
0
 /// <summary>
 /// Validates and sets the application theme.
 /// </summary>
 /// <param name="theme">The theme from the settings.</param>
 private void ValidateAndSetTheme(ApplicationTheme theme)
 {
     if (Enum.IsDefined(typeof(ApplicationTheme), theme))
     {
         Theme = theme;
     }
     else
     {
         Theme = GetDefaultValue <ApplicationTheme>(nameof(Theme));
     }
 }
예제 #30
0
        private ElementTheme ToElementTheme(ApplicationTheme theme)
        {
            switch (theme)
            {
            case ApplicationTheme.Light:
                return(ElementTheme.Light);

            case ApplicationTheme.Dark:
            default:
                return(ElementTheme.Dark);
            }
        }
예제 #31
0
        private void SetApplicationTheme()
        {
            if (this.settings == null)
            {
                this.RequestedTheme = ApplicationTheme.Dark;
                return;
            }

            ApplicationTheme theme = this.settings.Theme;

            this.RequestedTheme = theme;
        }
예제 #32
0
        public static ElementTheme ToElementTheme(this ApplicationTheme theme)
        {
            switch (theme)
            {
            case ApplicationTheme.Light:
                return(ElementTheme.Light);

            case ApplicationTheme.Dark:
            default:
                return(ElementTheme.Dark);
            }
        }
예제 #33
0
 public void ApplyAppTheme(ApplicationTheme value)
 {
     switch (value)
     {
         case ApplicationTheme.Light:
             Views.Shell.SetThemeColors(ElementTheme.Light);
             break;
         case ApplicationTheme.Dark:
             Views.Shell.SetThemeColors(ElementTheme.Dark);
             break;
         default:
             Views.Shell.SetThemeColors(ElementTheme.Default);
             break;
     }
 }
예제 #34
0
        public ChangeLogWindow(ApplicationTheme theme)
        {
            this.Entries = new ObservableCollection<ChangeLogEntry>();

              if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
              {
            this.Entries.Add(new ChangeLogHeader("Second Entry"));
            this.Entries.Add(new ChangeLogContent("The second entry goes on top of the first entry, since the item on top is the newest"));
            this.Entries.Add(new ChangeLogHeader("First Entry"));
            this.Entries.Add(new ChangeLogContent("The first entry is short and sweet"));
            this.Entries.Add(new ChangeLogContent("The second line of the first entry is longer.  This should hopefully show what the line looks like when it has to wrap due to a lot of text."));
              }

              this.Loaded += ChangeLogWindow_Loaded;
              InitializeComponent();

              SetApplicationThemeBasedOnSettings(theme);
        }
예제 #35
0
 public void ApplyAppTheme(ApplicationTheme value)
 {
     BootStrapper.Current.NavigationService.Dispatcher.Dispatch(() =>
     {
         switch (value)
         {
             case ApplicationTheme.Light:
                 Shell.Instance.RequestedTheme = ElementTheme.Light;
                 break;
             case ApplicationTheme.Dark:
                 Shell.Instance.RequestedTheme = ElementTheme.Dark;
                 break;
             default:
                 Shell.Instance.RequestedTheme = ElementTheme.Default;
                 break;
         }
         BootStrapper.Current.NavigationService.Refresh();
     });
 }
예제 #36
0
        /// <summary>
        /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの
        ///最初の行であるため、main() または WinMain() と論理的に等価です。
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync();
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            if (_localSettings.Values.ContainsKey(Constants.ThemeDefault))
            {
                var themeType = (ThemeTypes)_localSettings.Values[Constants.ThemeDefault];
                switch (themeType)
                {
                    case ThemeTypes.Light:
                        RequestedTheme = ApplicationTheme.Light;
                        break;
                    case ThemeTypes.Dark:
                        RequestedTheme = ApplicationTheme.Dark;
                        break;
                    case ThemeTypes.YOSPOS:
                        RequestedTheme = ApplicationTheme.Dark;
                        break;
                }
            }
            SelectedTheme = RequestedTheme;
            try
            {
                DataSource ds = new DataSource();
                SaclopediaDataSource sds = new SaclopediaDataSource();
                BookmarkDataSource bds = new BookmarkDataSource();
                ds.InitDatabase();
                ds.CreateDatabase();
                bds.InitDatabase();
                bds.CreateDatabase();
                sds.InitDatabase();
                sds.CreateDatabase();
            }
            catch
            {

            }
            Container = AutoFacConfiguration.Configure();
        }
예제 #37
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);

            // Save the OS Theme before we override the value
            OSTheme = this.RequestedTheme;

            // Only set requested theme when color is defined. Otherwise use system value
            ElementTheme theme = Models.Settings.Instance.AppTheme;
            if (theme == ElementTheme.Dark)
            {
                this.RequestedTheme = ApplicationTheme.Dark;
            }
            else if (theme == ElementTheme.Light)
            {
                this.RequestedTheme = ApplicationTheme.Light;
            }

            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }
예제 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayableTheme"/>.
 /// </summary>
 /// <param name="displayName"></param>
 /// <param name="theme"></param>
 public DisplayableTheme(string displayName, ApplicationTheme theme)
 {
     this.DisplayName = displayName;
     this.Theme = theme;
 }
        private void SetTheme(ApplicationTheme theme, bool raiseEvent)
        {
            var oldTheme = this.Theme;
            var elementTheme = ElementTheme.Default;

            if (Application.Current.RequestedTheme != theme) {
                elementTheme = ElementTheme.Light;
                if (theme == ApplicationTheme.Dark) {
                    elementTheme = ElementTheme.Dark;
                }
            }
            this.root.RequestedTheme = elementTheme;

            if (raiseEvent && oldTheme != this.Theme) {
                OnThemeChanged();
            }
        }
예제 #40
0
 public void ApplyAppTheme(ApplicationTheme value)
 {
     Views.Shell.HamburgerMenu.RefreshStyles(value);
 }
예제 #41
0
		public static void SetRequestedTheme(ApplicationTheme theme, bool UseBackgroundChecked)
		{

			WindowWrapper.Current().Dispatcher.Dispatch(() =>
			{
				(Window.Current.Content as FrameworkElement).RequestedTheme = theme.ToElementTheme();

				ParseStyleforThemes(theme);

				HamburgerMenu.NavButtonCheckedForeground = NavButtonCheckedForegroundBrush;

				HamburgerMenu.NavButtonCheckedBackground = (UseBackgroundChecked) ?
					NavButtonCheckedBackgroundBrush : NavButtonBackgroundBrush;

				HamburgerMenu.NavButtonCheckedIndicatorBrush = (UseBackgroundChecked) ?
					Colors.Transparent.ToSolidColorBrush() : NavButtonCheckedIndicatorBrush;

				HamburgerMenu.SecondarySeparator = SecondarySeparatorBrush;

				List<HamburgerButtonInfo> NavButtons = HamburgerMenu.PrimaryButtons.ToList();
				NavButtons.InsertRange(NavButtons.Count, HamburgerMenu.SecondaryButtons.ToList());

				List<HamburgerMenu.InfoElement> LoadedNavButtons = new List<HamburgerMenu.InfoElement>();

				foreach (var hbi in NavButtons)
				{
					StackPanel sp = hbi.Content as StackPanel;
					if (hbi.ButtonType == HamburgerButtonInfo.ButtonTypes.Literal) continue;
					ToggleButton tBtn = sp.Parent as ToggleButton;
					Button btn = sp.Parent as Button;

					if (tBtn != null)
					{
						var button = new HamburgerMenu.InfoElement(tBtn);
						LoadedNavButtons.Add(button);
					}
					else if (btn != null)
					{
						var button = new HamburgerMenu.InfoElement(btn);
						LoadedNavButtons.Add(button);
						continue;
					}
					else
					{
						continue;
					}

					Rectangle indicator = tBtn.FirstChild<Rectangle>();
					indicator.Visibility = ((!hbi.IsChecked ?? false)) ? Visibility.Collapsed : Visibility.Visible;

					if (!hbi.IsChecked ?? false) continue;

					ContentPresenter cp = tBtn.FirstAncestor<ContentPresenter>();
					cp.Background = NavButtonCheckedBackgroundBrush;
					cp.Foreground = NavButtonCheckedForegroundBrush;
				}

				LoadedNavButtons.ForEach(x => x.RefreshVisualState());

			});
		}
예제 #42
0
		private static void ParseStyleforThemes(ApplicationTheme theme)
		{
			string ThemeColor = (theme == ApplicationTheme.Light) ? nameof(ElementTheme.Light) : nameof(ElementTheme.Default);

			try
			{
				var myResourceDictionary = new ResourceDictionary();
				myResourceDictionary.Source = new Uri("ms-appx:///Styles/Custom.xaml", UriKind.RelativeOrAbsolute);
				ResourceDictionary themeResource = myResourceDictionary.ThemeDictionaries[ThemeColor] as ResourceDictionary;

				Style HamburgerMenuStyle = themeResource["HamburgerMenuStyle"] as Style;

				NavButtonCheckedForegroundBrush = ((from item in HamburgerMenuStyle.Setters.Cast<Setter>().Where(item => item.Property == HamburgerMenu.NavButtonCheckedForegroundProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
				NavButtonCheckedBackgroundBrush = ((from item in HamburgerMenuStyle.Setters.Cast<Setter>().Where(item => item.Property == HamburgerMenu.NavButtonCheckedBackgroundProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
				NavButtonCheckedIndicatorBrush = ((from item in HamburgerMenuStyle.Setters.Cast<Setter>().Where(item => item.Property == HamburgerMenu.NavButtonCheckedIndicatorBrushProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
				NavButtonBackgroundBrush = ((from item in HamburgerMenuStyle.Setters.Cast<Setter>().Where(item => item.Property == HamburgerMenu.NavButtonBackgroundProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
				SecondarySeparatorBrush = ((from item in HamburgerMenuStyle.Setters.Cast<Setter>().Where(item => item.Property == HamburgerMenu.SecondarySeparatorProperty) select item).SingleOrDefault())?.Value as SolidColorBrush;
			}

			catch
			{
				// PopulateDefaultColors() will take care of this!
			}

			NavButtonCheckedForegroundBrush = NavButtonCheckedForegroundBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonCheckedForegroundBrush)];
			NavButtonCheckedBackgroundBrush = NavButtonCheckedBackgroundBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonCheckedBackgroundBrush)];
			NavButtonCheckedIndicatorBrush = NavButtonCheckedIndicatorBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonCheckedIndicatorBrush)];
			NavButtonBackgroundBrush = NavButtonBackgroundBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(NavButtonBackgroundBrush)];
			SecondarySeparatorBrush = SecondarySeparatorBrush ?? HamburgerMenuDefaultColors[ThemeColor + nameof(SecondarySeparatorBrush)];
		}
 public void RefreshStyles(ApplicationTheme? theme = null)
 {
     RequestedTheme = theme?.ToElementTheme() ?? RequestedTheme;
     RefreshStyles(AccentColor);
 }
예제 #44
0
        // TODO: This should be extracted out so it can be shared by this window and the main application
        private void SetApplicationThemeBasedOnSettings(ApplicationTheme theme)
        {
            Debug.Assert(Application.Current.Resources.MergedDictionaries.Count <= 6, "There are more resource dictionaries than expected.");

              if (this.Resources.MergedDictionaries.Count == 6)
              {
            this.Resources.MergedDictionaries.RemoveAt(5);
              }

              var dict = new ResourceDictionary() { Source = new Uri(GetApplicationThemeResource(theme), UriKind.RelativeOrAbsolute) };
              this.Resources.MergedDictionaries.Add(dict);

              this.GlowBrush.Color = (Color)this.FindResource("WindowGlowColor");
        }
예제 #45
0
        private string GetApplicationThemeResource(ApplicationTheme theme)
        {
            switch (theme)
              {
            case ApplicationTheme.Light:
              return @"pack://*****:*****@"pack://application:,,,/Resources/DarkThemeColors.xaml";

            default:
              return @"pack://application:,,,/Resources/ThemeColors.xaml";
              }
        }
예제 #46
0
        public void ChangeTheme(ApplicationTheme background, Windows.UI.Color accentColor)
        {

        }
예제 #47
0
 public AssociatedThemeBrushAttribute(ApplicationTheme associatedTheme, ThemeBrushTarget target, Brush associatedBrush)
 {
     this.AssociatedBrush = associatedBrush;
       this.AssociatedTheme = associatedTheme;
       this.Target = target;
 }
예제 #48
0
 public AssociatedThemeBrushAttribute(ApplicationTheme associatedTheme, ThemeBrushTarget target, string associatedBrush)
 {
     this.AssociatedBrush = (SolidColorBrush)new BrushConverter().ConvertFromString(associatedBrush);
       this.AssociatedTheme = associatedTheme;
       this.Target = target;
 }