public void Activate() { themeLoader = new ThemeLoader(); var mainPage = new ContentPage() { ThemeChangeSensitive = true, AppBar = new AppBar() { AutoNavigationContent = false, Title = "NUI theme sample", //Actions = new View[] { closeButton }, }, Content = new ScrollableBase() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(20, 20) }, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, Padding = new Extents(30, 30, 20, 20) } }; string[] ids = (string[])themeLoader.QueryIds(); if (ids != null && ids.Contains("org.tizen.default-dark-theme") || ids.Contains("org.tizen.default-light-theme")) { var title = $"Current theme: {(themeLoader.CurrentTheme.Id == "org.tizen.default-dark-theme" ? "Dark" : "Light")}"; mainPage.Content.Add(CreateClickableItem("Theme change", title, delegate(View view) { TextLabel text = view.Children[1] as TextLabel; if (themeLoader.CurrentTheme.Id == "org.tizen.default-dark-theme") { var theme = themeLoader.LoadTheme("org.tizen.default-light-theme"); Tizen.Log.Info("test", $"Id: {theme.Id}, Version: {theme.Version}"); themeLoader.CurrentTheme = theme; text.Text = "Current theme: Light"; } else { var theme = themeLoader.LoadTheme("org.tizen.default-dark-theme"); Tizen.Log.Info("test", $"Id: {theme.Id}, Version: {theme.Version}"); themeLoader.CurrentTheme = theme; text.Text = "Current theme: Dark"; } })); mainPage.Content.Add(CreateItem("Switch", CreateSwitchExample())); } else { mainPage.AppBar.Title = "No proper theme is found!"; } NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(mainPage); }
public void Should_override_imported_color_When_current_theme_redefines_it( [Values(KnownColor.Control)] KnownColor colorName, [ValueSource(nameof(TestColorValues))] Color baseColor, [ValueSource(nameof(AlternativeTestColorValues))] Color colorOverride) { var pathProvider = CreateMockPathProvider(); var resolver = new ThemeCssUrlResolver(pathProvider); string themePath = Path.Combine(pathProvider.AppThemesDirectory, "theme.css"); string baseThemePath = Path.Combine(pathProvider.AppThemesDirectory, "base.css"); var mockFileReader = CreateMockFileReader(new Dictionary <string, string> { [baseThemePath] = GetThemeContent(colorName, baseColor), [themePath] = "@import url(\"base.css\");" + Environment.NewLine + GetThemeContent(colorName, colorOverride) }); var loader = new ThemeLoader(resolver, mockFileReader); var theme = loader.LoadTheme(themePath, new ThemeId("theme", isBuiltin: true), allowedClasses: ThemeVariations.None); theme.GetColor(colorName).ToArgb().Should().Be(colorOverride.ToArgb()); }
public MainPage() { var themeLoader = new ThemeLoader(); themeLoader.LoadTheme(); InitializeComponent(); repository = new Repository(); period = new Period(); pageService = new PageService(); initializeDatabase = new InitializeDatabase(pageService); period.Init(DateTime.Now, PeriodType.Month); trans = repository.GetTransactions(period); navigationBarViewModel = new NavigationBarViewModel(trans, pageService, repository, period); charts = new ChartsViewModel(navigationBarViewModel, pageService, repository); transactionsViewModel = new TransactionsViewModel(navigationBarViewModel, pageService, repository, period); MainVM = new MainPageViewModel(pageService, repository, initializeDatabase); this.BindingContext = MainVM; overview.BindingContext = charts; transactions.BindingContext = transactionsViewModel; MessagingCenter.Subscribe <NavigationBarViewModel>(this, MessagingString.UpdatePeriod, RefreshTransactions); MessagingCenter.Subscribe <SettingsPage>(this, MessagingString.UpdateTransactionsAfterSettingsChange, RefreshTransactions); MessagingCenter.Subscribe <SettingsViewModel>(this, MessagingString.UpdateTransactionsAfterReset, RefreshTransactions); MessagingCenter.Subscribe <TransactionsDetailsViewModel>(this, MessagingString.UpdateTransactions, RefreshTransactions); MessagingCenter.Subscribe <TransactionsViewModel>(this, MessagingString.DeleteTransactions, RefreshTransactions); MessagingCenter.Subscribe <TransactionsViewModel>(this, MessagingString.RefreshTransactions, RefreshTransactions); }
private void ThemePicker_SelectedIndexChanged(object sender, EventArgs e) { var theme = themePicker.Items[themePicker.SelectedIndex]; var app = (Application.Current as App); app.Properties[Themes.ThemeKey] = theme; app.SavePropertiesAsync(); var themeLoader = new ThemeLoader(); themeLoader.LoadTheme(); themeLoader.SetNavigationBarColor(); ExitPage(); }
/// <summary> /// Creates the WPF application and loads resource dictionaries. /// </summary> private void CreateApplication() { LoadingForm.Status = Resources.LoadingResources; new Application(); try { Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; Application.ResourceAssembly = Assembly.GetExecutingAssembly(); Application.Current.Resources.MergedDictionaries.Add(ThemeLoader.LoadTheme(Settings.DisplayMode)); } catch (Exception ex) { MessageWindow.Show(string.Format(CultureInfo.CurrentCulture, Resources.LoadResourceDictionariesFailed, ex.Message), Resources.SessionSummaryName, MessageWindowType.Close); } }
public void Should_honor_css_import_directive( [Values(KnownColor.Control)] KnownColor colorName, [ValueSource(nameof(TestColorValues))] Color baseColor) { var pathProvider = CreateMockPathProvider(); var resolver = new ThemeCssUrlResolver(pathProvider); string themePath = Path.Combine(pathProvider.AppThemesDirectory, "theme.css"); string baseThemePath = Path.Combine(pathProvider.AppThemesDirectory, "base.css"); var mockFileReader = CreateMockFileReader(new Dictionary <string, string> { [baseThemePath] = GetThemeContent(colorName, baseColor), [themePath] = "@import url(\"base.css\");", }); var loader = new ThemeLoader(resolver, mockFileReader); var theme = loader.LoadTheme(themePath, new ThemeId("theme", isBuiltin: true), allowedClasses: ThemeVariations.None); theme.GetColor(colorName).ToArgb().Should().Be(baseColor.ToArgb()); }
protected override void OnCreate() { base.OnCreate(); themeLoader = new ThemeLoader(); var closeButton = new Button() { Text = "Exit" }; closeButton.Clicked += (s, e) => { Exit(); }; var mainPage = new ContentPage() { ThemeChangeSensitive = true, AppBar = new AppBar() { AutoNavigationContent = false, Title = "NUI theme sample", Actions = new View[] { closeButton }, }, Content = new ScrollableBase() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(20, 20) }, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, Padding = new Extents(30, 30, 20, 20) } }; var title = $"Current theme: {(themeLoader.CurrentTheme.Id == "org.tizen.default-dark-theme" ? "Dark" : "Light")}"; mainPage.Content.Add(CreateClickableItem("Theme change", title, delegate(View view) { TextLabel text = view.Children[1] as TextLabel; if (themeLoader.CurrentTheme.Id == "org.tizen.default-dark-theme") { var theme = themeLoader.LoadTheme("org.tizen.default-light-theme"); Tizen.Log.Info("JYJY", $"Id: {theme.Id}, Version: {theme.Version}"); themeLoader.CurrentTheme = theme; text.Text = "Current theme: Light"; } else { var theme = themeLoader.LoadTheme("org.tizen.default-dark-theme"); Tizen.Log.Info("JYJY", $"Id: {theme.Id}, Version: {theme.Version}"); themeLoader.CurrentTheme = theme; text.Text = "Current theme: Dark"; } })); mainPage.Content.Add(CreateItem("Switch", CreateSwitchExample())); mainPage.Content.Add(CreateItem("RadioButton", CreateRadioButtonExample())); mainPage.Content.Add(CreateClickableItem("AlertDialog", "Click to post alert", delegate(View view) { var dialogPage = new DialogPage() { ScrimColor = new Color("#888888BB"), Content = new AlertDialog() { Title = "Notice", Message = "Please touch outer area to dismiss", // Actions = actions, }, }; NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(dialogPage); })); mainPage.Content.Add(CreateItem("CheckBox", CreateCheckBoxExample())); mainPage.Content.Add(CreateClickableItem("Exit", "Click to exit application", delegate(View view) { Exit(); })); NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(mainPage); }
private static Theme LoadTheme(ThemeLoader loader, params string[] variations) => loader.LoadTheme( "arbitrary\\theme-path.css", new ThemeId("arbitrary_theme_name", isBuiltin: true), allowedClasses: variations);