private void OnThemeSelected(ThemeModel selectedTheme) { foreach (var t in Themes) { t.IsSelected = t.Theme == selectedTheme.Theme; } _themeService.ChangeTheme(selectedTheme.Theme); }
/// <summary> /// On item tapped. /// </summary> /// <param name="sender"></param> void OnItemTapped(object sender) { commandManager.DisableAll(); var themeHolder = (ThemeHolder)sender; themeService.ChangeTheme(themeHolder.Theme); commandManager.EnableAll(); popupService.Pop(true); }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. #endregion public MainViewModel(IOptionService optionService, IDirectoryService directoryService, IAppService infoService, IThemeService themeService) { // Initialize services _docLib = DocLib.Instance; _optionService = optionService; _directoryService = directoryService; _themeService = themeService; _infoService = infoService; // Initialize commands GetDirectory = ReactiveCommand.Create(BrowseDirectory); ReadPDF = ReactiveCommand.Create(() => { _th = new Thread(() => StartReading()); _th.IsBackground = true; _th.Start(); }, this.IsValid()); ChangeTheme = ReactiveCommand.Create(() => { themeService.ChangeTheme(); CurrentThemeName = themeService.GetCurrentThemeName(); }); ChangeLanguage = ReactiveCommand.Create(() => { infoService.ChangeLanguage(); CurrentLanguageName = infoService.GetCurrentLanguage(); UpdateStringResources(); }); // Initialize variables PrecisionOCR = new ObservableCollection <RecognitionPrecision>(Enum.GetValues(typeof(RecognitionPrecision)).Cast <RecognitionPrecision>()); LanguageOCR = new ObservableCollection <RecognitionLanguage>(Enum.GetValues(typeof(RecognitionLanguage)).Cast <RecognitionLanguage>()); Options = new SearchOptions("", "", PrecisionOCR.FirstOrDefault(), LanguageOCR.FirstOrDefault(), false, true, false, true, false, false); Results = new ObservableCollection <QueryResult>(); Stats = new ResultStats("0/0", true, 0, "0"); ResultInfo = infoService.GetSearchInfo(SearchInfo.Init); StatusName = infoService.GetSearchStatus(SearchStatus.Ready); CurrentThemeName = themeService.GetCurrentThemeName(); CurrentLanguageName = infoService.GetCurrentLanguage(); ItemsReady = false; // Subscribe for events and set validation rules ErrorsChanged += OnValidationErrorsChanged; this.ValidationRule(x => x.Options.Keyword, key => !string.IsNullOrEmpty(key), "Keyword cannot be empty!"); this.ValidationRule(x => x.Options.Path, key => !string.IsNullOrEmpty(key) && Directory.Exists(key), "Path has to be valid!"); // Get assembly version AppVersion = infoService.GetVersion(); }
private ThemeEntity CreateTheme(string themeName, List <PositionEntry> cssFiles) { const string themeCss = "theme.css"; const string themeCssMin = "theme.min.css"; const string thumbnail = "thumbnail.jpg"; #region Write theme.css,theme.min.css using (FileStream themeFilestram = new FileStream(Path.Combine(ThemeBasePath, themeName, themeCssMin), FileMode.Create)) { using (StreamWriter writer = new StreamWriter(themeFilestram)) { if (cssFiles.All(css => !BootstrapFilter.IsMatch(css.Entry))) { writer.WriteLine("@import url(\"/lib/bootstrap/dist/css/bootstrap.min.css\");"); } writer.WriteLine("@import url(\"/css/theme-base.css\");"); foreach (var item in cssFiles.OrderBy(m => m.Position)) { writer.WriteLine("@import url(\"{0}\");", item.Entry); } } } using (FileStream themeFilestram = new FileStream(Path.Combine(ThemeBasePath, themeName, themeCss), FileMode.Create)) { using (StreamWriter writer = new StreamWriter(themeFilestram)) { if (cssFiles.All(css => !BootstrapFilter.IsMatch(css.Entry))) { writer.WriteLine("@import url(\"/lib/bootstrap/dist/css/bootstrap.min.css\");"); } writer.WriteLine("@import url(\"/css/theme-base.css\");"); foreach (var item in cssFiles.OrderBy(m => m.Position)) { writer.WriteLine("@import url(\"{0}\");", item.Entry); } } } #endregion if (!File.Exists(Path.Combine(ThemeBasePath, themeName, thumbnail)) && File.Exists(Path.Combine(ThemeBasePath, "Default", thumbnail))) { File.Copy(Path.Combine(ThemeBasePath, "Default", thumbnail), Path.Combine(ThemeBasePath, themeName, thumbnail)); } ThemeEntity themeEntity = new ThemeEntity { ID = themeName, Title = themeName, Description = "By TemplateImporter", IsActived = false, Status = (int)Easy.Constant.RecordStatus.Active, Thumbnail = $"~/{ThemeFolder}/{themeName}/{thumbnail}", Url = $"~/{ThemeFolder}/{themeName}/{themeCssMin}", UrlDebugger = $"~/{ThemeFolder}/{themeName}/{themeCss}" }; var theme = _themeService.Get(themeEntity.ID); if (theme == null) { _themeService.Add(themeEntity); } _themeService.ChangeTheme(themeEntity.ID); return(themeEntity); }