protected override void OnCreate() { base.OnCreate(); ThemeLoader.Initialize(DirectoryInfo.Resource); NativeParent = MainWindow; LoadApplication(new App()); }
/// <summary> /// Class Fotootof Layouts Windows About Constructor. /// </summary> public WindowAboutLayout() { ThemeLoader.MergeThemeTo(Resources); InitializeComponent(); InitializeModel(); }
protected override void OnStartup(StartupEventArgs e) { try { base.OnStartup(e); // Initialize SettingsManager. SettingsManager.Settings = MiniUML.Properties.Settings.Default; // Load theme. ThemeLoader.LoadThemeAssembly(MiniUML.Properties.Settings.Default.ThemeAssembly); DocumentViewModel.LoadThemeAssemblyDelegate = new LoadThemeAssemblyDelegate(ThemeLoader.LoadThemeAssembly); // Initialize models. vm_WindowViewModel = new MainWindowViewModel(); // Load plugins. PluginLoader.LoadPlugins(MiniUML.Properties.Settings.Default.PluginDirectory, vm_WindowViewModel); // Create and show main window. IFactory mainWindowFactory = Application.Current.Resources["MainWindowFactory"] as IFactory; Window mainWindow = mainWindowFactory.CreateObject() as Window; mainWindow.DataContext = vm_WindowViewModel; mainWindow.Show(); // If exceptions occured while loading, show them now. ExceptionManager.ShowErrorDialog(true); } catch (NotImplementedException ex) { // Catch and show unhandled exceptions before killing the process. ExceptionManager.RegisterCritical(ex, "An error occured while starting the program."); } }
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); }
public void Deactivate() { NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop(); themeLoader.Dispose(); themeLoader = null; }
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 void Should_throw_When_unknown_color_name() { var mockFileReader = CreateMockFileReader(GetThemeContent("InvalidColorName", Color.Red)); var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>(); var loader = new ThemeLoader(mockCssUrlResolver, mockFileReader); loader.Invoking(l => LoadTheme(l)) .Should().Throw <ThemeException>() .Which.Message.Should().Contain("InvalidColorName"); }
public void Given_NullParameter_Constructor_ShouldThrow_ArgumentNullException() { Action action1 = () => { var service = new ThemeLoader(null, this._fileHelper.Object); }; action1.ShouldThrow <ArgumentNullException>(); Action action2 = () => { var service = new ThemeLoader(this._settings.Object, null); }; action2.ShouldThrow <ArgumentNullException>(); }
public TestConditionUC() { InitializeComponent(); theme = new ThemeLoader(); theme.LoadBaseThemes(); theme.SetThemeByName("Elite Verdana"); Theme.Current.FontSize = 12; Theme.Current.WindowsFrame = false; ExtendedControls.Theme.Current = theme; }
public void Should_throw_When_css_syntax_error() { var mockFileReader = CreateMockFileReader(GetThemeContent(KnownColor.Control, Color.Red) + "}"); var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>(); var loader = new ThemeLoader(mockCssUrlResolver, mockFileReader); loader.Invoking(l => LoadTheme(l)) .Should().Throw <ThemeException>() .Which.Message.Should().Contain("Error parsing CSS"); }
public static void Init(InitOptions options) { var resPath = options.Context?.DirectoryInfo?.Resource; if (!string.IsNullOrEmpty(resPath)) { ThemeLoader.Initialize(resPath); } Init(options.GoogleMapsAPIKey); }
public static void Init(CoreApplication context) { var resPath = context?.DirectoryInfo?.Resource; if (!string.IsNullOrEmpty(resPath)) { ThemeLoader.Initialize(resPath); } Init(); }
/// <summary> /// Init with options /// </summary> /// <param name="options"></param> public static void Init(InitOptions options) { var resPath = options.Context?.DirectoryInfo?.Resource; if (!string.IsNullOrEmpty(resPath)) { ThemeLoader.Initialize(resPath); } MainWindowProvider = options.MainWindowProvider; Init(); }
public void Should_load_any_app_color( [ValueSource(nameof(AppColorNames))] AppColor colorName, [ValueSource(nameof(TestColorValues))] Color color) { var mockFileReader = CreateMockFileReader(GetThemeContent(colorName, color)); var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>(); var loader = new ThemeLoader(mockCssUrlResolver, mockFileReader); var theme = LoadTheme(loader); theme.GetColor(colorName).ToArgb().Should().Be(color.ToArgb()); }
public void Should_load_any_themable_system_color( [ValueSource(nameof(ThemableSystemColorNames))] KnownColor colorName, [ValueSource(nameof(TestColorValues))] Color testColorValue) { var mockFileReader = CreateMockFileReader(GetThemeContent(colorName, testColorValue)); var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>(); var loader = new ThemeLoader(mockCssUrlResolver, mockFileReader); var theme = LoadTheme(loader); theme.GetColor(colorName).ToArgb().Should().Be(testColorValue.ToArgb()); }
/// <summary> /// Class Fotootof Main Menu Horizontal Layout Constructor. /// </summary> public MainMenuHorizontalLayout() { // Add custom theme to resources. ThemeLoader.MergeThemeTo(Resources); // Initialize the model. Model = new MainMenuHorizontalModel(this); // Initialize menu component InitializeComponent(); // Add extensions plugin to menu. InitializeExtensions(); }
public void Default_values_are_specified_in_invariant_theme() { var themePathProvider = new ThemePathProvider(); var themeLoader = new ThemeLoader(new ThemeCssUrlResolver(themePathProvider), new ThemeFileReader()); var repository = new ThemeRepository(new ThemePersistence(themeLoader), themePathProvider); var invariantTheme = repository.GetInvariantTheme(); invariantTheme.Should().NotBeNull(); foreach (AppColor name in Enum.GetValues(typeof(AppColor))) { Color value = invariantTheme.GetColor(name); value.Should().NotBe(Color.Empty); } }
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(); }
public void Should_tolerate_css_comment( [Values(KnownColor.Control)] KnownColor colorName, [ValueSource(nameof(TestColorValues))] Color testColorValue) { string commentedContent = "/* entire first line with comment */" + Environment.NewLine + GetThemeContent(colorName, testColorValue) + "/* comment after definition */"; var mockFileReader = CreateMockFileReader(commentedContent); var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>(); var loader = new ThemeLoader(mockCssUrlResolver, mockFileReader); var theme = LoadTheme(loader); theme.GetColor(colorName).ToArgb().Should().Be(testColorValue.ToArgb()); }
public void Should_apply_colorblind_overrides_to_app_colors( [ValueSource(nameof(AppColorNames))] AppColor colorName) { var regularColor = Color.Red; var colorblindColor = Color.Blue; var mockFileReader = CreateMockFileReader(GetThemeContent(colorName, regularColor, colorblindColor)); var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>(); var loader = new ThemeLoader(mockCssUrlResolver, mockFileReader); var regularTheme = LoadTheme(loader); regularTheme.GetColor(colorName).ToArgb().Should().Be(regularColor.ToArgb()); var colorblindTheme = LoadTheme(loader, ThemeVariations.Colorblind); colorblindTheme.GetColor(colorName).ToArgb().Should().Be(colorblindColor.ToArgb()); }
/// <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 async Task <IActionResult> Preview(PostFormViewModel model) { if (model == null) { return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest)); } var vm = new PostPreviewViewModel() { Theme = this._settings.Theme, HeadPartialViewPath = this._themeService.GetHeadPartialViewPath(this._settings.Theme), HeaderPartialViewPath = this._themeService.GetHeaderPartialViewPath(this._settings.Theme), PostPartialViewPath = this._themeService.GetPostPartialViewPath(this._settings.Theme), FooterPartialViewPath = this._themeService.GetFooterPartialViewPath(this._settings.Theme), }; var page = new PageSettings(); page.Title = "Hello World"; page.Description = "This is description"; page.Author = new Author() { Name = "joebloggs" }; page.Date = DateTime.Today; page.BaseUrl = this._settings.BaseUrl; page.Url = "/posts/post.html"; page.Pages = new List <PageSettings>(); vm.Page = page; var env = this.Resolver.GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment; var loader = new ThemeLoader(this._settings, new FileHelper(this._settings)); var site = await loader.LoadAsync(env).ConfigureAwait(false); vm.Site = site; var parsedHtml = this._markdownHelper.Parse(model.Body); vm.Html = parsedHtml; return(this.View(vm)); }
void Initialize() { ResourceDir = DirectoryInfo.Resource; MaterialGallery.ResourceDir = DirectoryInfo.Resource; ThemeLoader.Initialize(ResourceDir); _window = new Window("WatchMaterialGallery") { AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90 }; _window.BackButtonPressed += (s, e) => { Exit(); }; _window.Show(); _screenWidth = _window.ScreenSize.Width; CreateTestPage(_window); }
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()); }
public void Should_throw_When_cyclic_css_imports() { 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] = "@import url(\"theme.css\");", [themePath] = "@import url(\"base.css\");" }); var loader = new ThemeLoader(resolver, mockFileReader); loader.Invoking(_ => _.LoadTheme( themePath, new ThemeId("theme", isBuiltin: true), allowedClasses: ThemeVariations.None)) .Should().Throw <ThemeException>() .Which.Message.Should().Contain("Cycling CSS import"); }
public Greetings() { InitializeComponent(); ThemeApplier.Apply(ThemeLoader.Load(), this); }
/// <summary> /// Class XtrmAddons Fotootof Server UI Control DataGrid AclGroups List Constructor. /// </summary> public DataGridUsersLayout() { ThemeLoader.MergeThemeTo(Resources); InitializeComponent(); }
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); }
void Initialize() { ResourceDir = DirectoryInfo.Resource; ThemeLoader.Initialize(ResourceDir); _mainWindow = new Window("MaterialGallery"); _mainWindow.Show(); _mainWindow.BackButtonPressed += (s, e) => { UIExit(); }; var conformant = new Conformant(_mainWindow); conformant.Show(); var box = new Box(_mainWindow) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; box.Show(); var bg = new Background(_mainWindow) { Color = Color.White }; bg.SetContent(box); conformant.SetContent(bg); GenList list = new GenList(_mainWindow) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (data, part) => { BaseGalleryPage page = data as BaseGalleryPage; return(page == null ? "" : page.Name); } }; foreach (var page in GetGalleryPage()) { if (Elementary.GetProfile() == "tv" && page.ExceptProfile == ProfileType.TV) { continue; } list.Append(defaultClass, page); } if (ThemeLoader.Profile == TargetProfile.Wearable) { list.Prepend(defaultClass, null); list.Append(defaultClass, null); } list.ItemSelected += (s, e) => { BaseGalleryPage page = e.Item.Data as BaseGalleryPage; RunGalleryPage(page); }; list.Show(); box.PackEnd(list); }