public ActionResult Index() { var settings = _settingsService.GetSettings(); var viewModel = new ThemeSettingsViewModel { AccentCss = settings.AccentCss, BackgroundCss = settings.BackgroundCss, Tagline = settings.Tagline, UseBranding = settings.UseBranding, UseCustomCss = settings.UseCustomCss, }; /************************************************************************************ * Custom CSS is managed in "CustomCss" action ************************************************************************************ * * string customCssAbsolutePath = Server.MapPath(Constants.CUSTOM_CSS_VIRTUAL_PATH); * if (System.IO.File.Exists(customCssAbsolutePath)) * viewModel.CustomCss = System.IO.File.ReadAllText(customCssAbsolutePath); * ************************************************************************************/ return(View(viewModel)); }
public ActionResult CustomCss(ThemeSettingsViewModel viewModel) { if (!Services.Authorizer.Authorize(TheMetroTheme.Permissions.EditCustomCss, T("Couldn't update TheMetroTheme Custom CSS"))) { return(new HttpUnauthorizedResult()); } var settings = _settingsService.GetSettings(); settings.UseCustomCss = viewModel.UseCustomCss; try { string customCssAbsolutePath = Server.MapPath(Constants.CUSTOM_CSS_VIRTUAL_PATH); if (System.IO.File.Exists(customCssAbsolutePath)) { System.IO.File.WriteAllText(customCssAbsolutePath, viewModel.CustomCss); } Services.Notifier.Information(T("Your settings have been saved.")); } catch (Exception) { Services.Notifier.Error(T("it wasn't possible to save the CSS, check permissions of a themes folder")); } return(View(viewModel)); }
public ThemeSettingsWindow() { InitializeComponent(); ViewModel = new ThemeSettingsViewModel(); this.DataContext = ViewModel; }
public ThemeSettingsViewModel LoadTheme(ThemeModel theme) { ThemeSettingsViewModel result = null; try { if (theme == null) { theme = DefaultTheme; } if (theme.Path.StartsWith("/Cleverdock;component/")) { LoadComponentTheme(theme.Path); } else { var xamlPath = Path.Combine(theme.Path, "style.xaml"); var xaml = XamlHelper.LoadXaml(xamlPath); LoadResourceDictionary(xaml); var settingsPath = Path.Combine(theme.Path, "theme.json"); result = GetSettings(settingsPath); } VMLocator.Main.Theme = theme; if (ThemeChanged != null) { ThemeChanged(this, new ThemeEventArgs(theme)); } } catch (Exception ex) { MessageBox.Show("Theme \"" + theme.Name + "\" failed to load. \n" + ex.Message); LoadTheme(DefaultTheme); } return(result); }
public SettingsViewModel(AnalyserSettingsViewModel analyserViewModel, ExchangeSettingsViewModel exchangeViewModel, ThemeSettingsViewModel themeViewModel) { AnalyserSettingsViewModel = analyserViewModel; ExchangeSettingsViewModel = exchangeViewModel; ThemeSettingsViewModel = themeViewModel; }
public void ViewModelDataTest() { var viewModel = new ThemeSettingsViewModel(mock.Object); Assert.That(viewModel.SelectedLanguage, Is.EqualTo(mockData.Language)); Assert.That(viewModel.SelectedColor, Is.EqualTo(mockData.PrimaryColor)); Assert.That(viewModel.SelectedTheme, Is.EqualTo(mockData.Theme.ToString())); }
public void UpdateSettingsRecord(ThemeSettingsViewModel viewModel) { var settings = this.GetSettingsRecord(); settings.HeaderLogoUrl = viewModel.HeaderLogoUrl; settings.BaseLineText = viewModel.BaseLineText; settings.PlaceholderLogoUrl = viewModel.PlaceholderLogoUrl; settings.PlaceholderSmallLogoUrl = viewModel.PlaceholderSmallLogoUrl; _signals.Trigger("KrakeAdminSettingsChanged"); }
public ActionResult Index() { var settings = _settingsService.GetSettings(); var viewModel = new ThemeSettingsViewModel { AccentCss = settings.AccentCss, }; return(View(viewModel)); }
public ActionResult ThemeSettingsPOST(ThemeSettingsViewModel viewModel) { if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't update theme settings"))) { return(new HttpUnauthorizedResult()); } _settingsService.UpdateSettingsRecord(viewModel); Services.Notifier.Information(T("Your settings have been saved.")); return(RedirectToAction("ThemeSettings")); }
public ActionResult ThemeSettings() { var settings = _settingsService.GetSettings(); var viewModel = new ThemeSettingsViewModel { BaseLineText = settings.BaseLineText, HeaderLogoUrl = settings.HeaderLogoUrl, PlaceholderLogoUrl = settings.PlaceholderLogoUrl, }; return(View("~/Themes/KrakeDefaultTheme/Views/admin/ThemeSettings.cshtml", viewModel)); }
public ActionResult Theme() { var context = HttpContext.GetOwinContext(); var tenantInstance = context.GetTenantInstance(); var viewModel = new ThemeSettingsViewModel(); viewModel.CurrentTheme = tenantInstance.Tenant.ThemeConfig; viewModel.ThemeConfigs = _themeService.GetThemeConfigurations().Where(x => x.ThemeName != viewModel.CurrentTheme.ThemeName).ToList(); return(View(viewModel)); }
public ActionResult Index(ThemeSettingsViewModel viewModel) { if (!Services.Authorizer.Authorize(Raptor.Ericka.Permissions.ManageThemeSettings, T("Couldn't update Raptor.Ericka settings"))) { return(new HttpUnauthorizedResult()); } var settings = _settingsService.GetSettings(); settings.AccentCss = viewModel.AccentCss; Services.Notifier.Information(T("Your settings have been saved.")); return(View(viewModel)); }
public ActionResult Index() { var settings = _settingsService.GetSettings(); var viewModel = new ThemeSettingsViewModel { Swatch = settings.Swatch, UseFixedNav = settings.UseFixedNav, UseNavSearch = settings.UseNavSearch, UseFluidLayout = settings.UseFluidLayout, UseInverseNav = settings.UseInverseNav, UseStickyFooter = settings.UseStickyFooter }; return(View(viewModel)); }
private void windowTheme_Closing(object sender, System.ComponentModel.CancelEventArgs e) { ThemeSettingsViewModel.LoadThemeFromFile(); // reload theme.xml on close in-case any unsaved changes are made // make sure image is reset try { ITheme themeSettings = ThemeSettingsViewModel.GetThemeSettingsFromFile(); byte[] imageBytes = Convert.FromBase64String(themeSettings.BackgroundImageBase64); ViewModel.CurrentImageTheme = imageBytes; } catch (Exception) { ViewModel.CurrentImageTheme = null; } }
public ActionResult ThemeSettingsPOST(ThemeSettingsViewModel viewModel) { if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't update theme settings"))) { return(new HttpUnauthorizedResult()); } var settings = _settingsService.GetSettings(); settings.BaseLineText = viewModel.BaseLineText; settings.HeaderLogoUrl = viewModel.HeaderLogoUrl; settings.PlaceholderLogoUrl = viewModel.PlaceholderLogoUrl; Services.Notifier.Information(T("Your settings have been saved.")); return(RedirectToAction("ThemeSettings")); }
public void ViewModelLoadTest() { var viewModel = new ThemeSettingsViewModel(mock.Object) { SelectedLanguage = "English", SelectedColor = "Black", SelectedTheme = "Light", }; viewModel.SettingMediatorOnSaveRequested(null, EventArgs.Empty); var viewModel2 = new ThemeSettingsViewModel(mock.Object); Assert.That(viewModel2.SelectedLanguage, Is.EqualTo("English")); Assert.That(viewModel2.SelectedColor, Is.EqualTo("Black")); Assert.That(viewModel2.SelectedTheme, Is.EqualTo("Light")); }
public ActionResult Index() { var settings = _settingsService.GetSettings(); var additionalThemes = _settingsService.GetThemes(); var viewModel = new ThemeSettingsViewModel { Swatch = settings.Swatch, UseFixedNav = settings.UseFixedNav, UseNavSearch = settings.UseNavSearch, UseFluidLayout = settings.UseFluidLayout, UseInverseNav = settings.UseInverseNav, UseStickyFooter = settings.UseStickyFooter, TagLineText = settings.TagLineText, AdditionalThemes = additionalThemes, }; return(View("OptionsIndex", viewModel)); }
public ActionResult Index(ThemeSettingsViewModel viewModel) { if (!Services.Authorizer.Authorize(TheMetroTheme.Permissions.ManageThemeSettings, T("Couldn't update TheMetroTheme settings"))) { return(new HttpUnauthorizedResult()); } var settings = _settingsService.GetSettings(); settings.AccentCss = viewModel.AccentCss; settings.BackgroundCss = viewModel.BackgroundCss; settings.Tagline = viewModel.Tagline; settings.UseBranding = viewModel.UseBranding; Services.Notifier.Information(T("Your settings have been saved.")); return(View(viewModel)); }
public ActionResult Index() { AddJS("TinyColorPicker", "/cbuilderassets/js/corejs/edit-2-tinyColorPicker.js"); AddJS("ColorPicker", "/cbuilderassets/js/corejs/edit-2-colors.js"); AddJS("UIComponent", "/admin/js/UIComponents.js"); AddJS("ThemeSettings", "/admin/js/themesettings.js"); //AddJS("ColorPicker", "/lib/js/colorpicker.js"); //AddCSS("ColorPicker", "/lib/css/colorpicker.css"); string themeCSSPath = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "admin", "css", "theme.css"); string cssText = System.IO.File.ReadAllText(themeCSSPath); CssParser parser = new CssParser(); List <CssParserRule> rules = parser.ParseAll(cssText).ToList(); ThemeManagement themeManagement = new ThemeManagement(); List <MainComponentSettings> lstComponents = themeManagement.MapRulesToComponent(rules); List <MainComponentSettings> lstOtherComponents = lstComponents.FindAll(x => !x.IsPredefinedThemeSelector); List <MainComponentSettings> lstButtonComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.buttonSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstTextColorComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.textColorSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstLinkComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.linkSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstBackgroundComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.backgroundSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstPillComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.pillsSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstCapsuleComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.capsuleSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstAlertBoxComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.alertBoxSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); List <MainComponentSettings> lstBadgeComponents = lstComponents.FindAll(x => Array.IndexOf(PredefinedCSS.badgeSelectors, x.Rules.FirstOrDefault().Selectors.FirstOrDefault()) > -1); ThemeSettingsViewModel themeSettingsViewModel = new ThemeSettingsViewModel(); themeSettingsViewModel.OtherComponents = lstOtherComponents; themeSettingsViewModel.ButtonComponents = lstButtonComponents; themeSettingsViewModel.TextColorComponents = lstTextColorComponents; themeSettingsViewModel.LinkComponents = lstLinkComponents; themeSettingsViewModel.BackgroundComponents = lstBackgroundComponents; themeSettingsViewModel.PillComponents = lstPillComponents; themeSettingsViewModel.AlertBoxComponents = lstAlertBoxComponents; themeSettingsViewModel.BadgeComponents = lstBadgeComponents; return(View(themeSettingsViewModel)); }
public ActionResult Index(ThemeSettingsViewModel viewModel) { if (!Services.Authorizer.Authorize(Bootstrap.Permissions.ManageThemeSettings, T("Couldn't update Bootstrap settings"))) { return(new HttpUnauthorizedResult()); } var settings = _settingsService.GetSettings(); settings.Swatch = viewModel.Swatch; settings.UseFixedNav = viewModel.UseFixedNav; settings.UseNavSearch = viewModel.UseNavSearch; settings.UseFluidLayout = viewModel.UseFluidLayout; settings.UseInverseNav = viewModel.UseInverseNav; settings.UseStickyFooter = viewModel.UseStickyFooter; Services.Notifier.Information(T("Your settings have been saved.")); return(View(viewModel)); }
public ActionResult Settings(bool ismobile) { // we need to parse settings file var theme = new ThemeHandler(MASTERdomain, ismobile); var settingHtml = theme.GetSettingsHtml(); var settingsText = theme.GetSettingsText(); var serializer = new JavaScriptSerializer(); var settings = serializer.Deserialize <ThemeSettings>(settingsText); // set current theme settings if set if (!string.IsNullOrEmpty(MASTERdomain.theme.preset)) { settings.current = MASTERdomain.theme.preset; settingsText = serializer.Serialize(settings); } var viewmodel = new ThemeSettingsViewModel { SettingsHtml = settingHtml, SettingsJson = string.IsNullOrEmpty(settingsText) ? "{}": settingsText, ThemeTitle = MASTERdomain.theme.title, themeType = ismobile ? ThemeType.MOBILE : ThemeType.MAIN }; if (settings != null && settings.presets != null && settings.presets.Count != 0) { foreach (var key in settings.presets.Keys) { viewmodel.presetList.Add(new SelectListItem() { Text = key, Value = key, Selected = key == MASTERdomain.theme.preset }); } } return(View(viewmodel)); }
private void btnCancel_Click(object sender, RoutedEventArgs e) { ThemeSettingsViewModel.LoadThemeFromFile(); // reload theme.xml on cancel in-case any unsaved changes are made this.Close(); }
public ThemeSettings() { DataContext = new ThemeSettingsViewModel(); InitializeComponent(); }