public SettingsViewModel() { this.IsDarkThemeEnabled = ThemeManager.DetectAppStyle().Item1.Name.EndsWith("Dark"); this.BaseColors = new ObservableCollection <Accent>(ThemeManager.Accents); this.BaseColor = ThemeManager.DetectAppStyle().Item2; this.ThemeChangedCommand = new RelayCommand <bool>( isChecked => { var appTheme = ThemeManager.GetInverseAppTheme(ThemeManager.DetectAppStyle().Item1); this.isDarkThemeEnabled = !this.isDarkThemeEnabled; ThemeManager.ChangeAppTheme(Application.Current, appTheme.Name); Properties.Settings.Default["ThemeName"] = appTheme.Name; Properties.Settings.Default["ThemeResourceAddress"] = appTheme.Resources.Source.OriginalString; Properties.Settings.Default.Save(); }); this.BaseColorChanged = new RelayCommand <Accent>( newBaseColor => { this.BaseColor = newBaseColor; var appTheme = ThemeManager.DetectAppStyle().Item1; ThemeManager.ChangeAppStyle(Application.Current, newBaseColor, appTheme); Properties.Settings.Default["BaseColorName"] = newBaseColor.Name; Properties.Settings.Default["BaseColorResourceAddress"] = newBaseColor.Resources.Source.OriginalString; Properties.Settings.Default.Save(); }); }
public void SetTheme(string theme) { log.Info($"Switched theme to {theme}"); ThemeManager.ChangeAppTheme(Application.Current, theme); Properties.Settings.Default.Theme = theme; Properties.Settings.Default.Save(); }
private void App_OnStartup(object sender, StartupEventArgs e) { // // Arguments: // - RCP filePath (string) // - Dark mode (bool) // - User level (UserLevel) // - Update URL (string) // - Culture (string) // // Retrieve the arguments string[] args = e.Args; // Make sure we have 5 arguments if (args.Length != 5) { ShutdownApplication("The number of launch arguments need to be 5"); return; } // Attempt to get the file path RCPFilePath = args[0]; // Make sure the file exists if (!File.Exists(RCPFilePath)) { ShutdownApplication("The file specified in the first launch argument does not exist"); return; } // Get the dark mode value var darkMode = !Boolean.TryParse(args[1], out bool dm) || dm; // Set the app theme ThemeManager.ChangeAppTheme(this, $"Base{(darkMode ? "Dark" : "Light")}"); // Get the user level CurrentUserLevel = Enum.TryParse(args[2], out UserLevel ule) ? ule : UserLevel.Normal; // Get the update URL UpdateURL = args[3]; try { // Get the culture info var ci = new CultureInfo(args[4]); // Update the current thread cultures CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture = ci; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error setting culture", MessageBoxButton.OK, MessageBoxImage.Error); } // Create and show the main window new MainWindow().Show(); }
public MainWindow() { InitializeComponent(); CrearDatosDePrueba(); ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); }
private void tbtTheme_Click(object sender, RoutedEventArgs e) { string themeName = (tbtTheme.IsChecked.HasValue && tbtTheme.IsChecked.Value) ? "BaseLight" : "BaseDark"; AppSettings.Default.Theme = themeName; AppSettings.Default.Save( ); ThemeManager.ChangeAppTheme(Application.Current, themeName); }
protected override void OnStartup(StartupEventArgs e) { var theme = ThemeManager.DetectAppStyle(this); if (Settings.Default.DarkTheme) { ThemeManager.ChangeAppTheme(this, "BaseDark"); } }
private void ComboThemes_SelectionChanged(object sender, SelectionChangedEventArgs e) { string text = (sender as ComboBox).SelectedItem.ToString(); ThemeManager.ChangeAppTheme(Application.Current, text); var currentUser = Singleton <User> .GetInstance(); currentUser.Theme = text; Singleton <IPersistance> .GetInstance().ChangeStyle(currentUser, text, currentUser.Accent); }
/// <summary> /// Change the AppTheme /// </summary> /// <param name="name">Name of the AppTheme</param> public static void ChangeAppTheme(string name) { AppTheme theme = ThemeManager.GetAppTheme(name); // If user has renamed / removed a custom theme --> fallback default if (theme != null) { ThemeManager.ChangeAppTheme(Application.Current, name); } }
public WpfCliente() { InitializeComponent(); cboActividadEmpresa.ItemsSource = new ActividadEmpresa().ReadAll(); cboTipoEmpresa.ItemsSource = new TipoEmpresa().ReadAll(); if (sw.contraste == 1) { ThemeManager.ChangeAppTheme(this, "BaseDark"); } }
private void LoadSettings( ) { ThemeManager.ChangeAppTheme(Application.Current, AppSettings.Default.Theme); var accent = ThemeManager.GetAccent(AppSettings.Default.Accent); var theme = ThemeManager.DetectAppStyle(Application.Current); ThemeManager.ChangeAppStyle(Application.Current, accent, theme.Item1); cbAccent.SelectedValue = accent; tbtTheme.IsChecked = AppSettings.Default.Theme == "BaseLight"; }
private void Button_Click(object sender, RoutedEventArgs e) { if (ThemeManager.DetectAppStyle().Item1.Name == "BaseLight") { ThemeManager.ChangeAppTheme(Application.Current, "BaseDark"); } else { ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); } }
private void TswCambioDeTema_Click(object sender, RoutedEventArgs e) { if (!TswCambioDeTema.IsChecked.Value) { ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); } else { ThemeManager.ChangeAppTheme(Application.Current, "BaseDark"); } }
private void GetSavedSettings() { var SavedTheme = _globalConfigService.Get(AppSettingsParam.AppTheme); var SavedColor = _globalConfigService.Get(AppSettingsParam.AppColor); ThemeManager.ChangeAppTheme(Application.Current, SavedTheme.ToString()); var NewTheme = ThemeManager.DetectAppStyle(Application.Current); var NewColor = ThemeManager.GetAccent(SavedColor.ToString()); ThemeManager.ChangeAppStyle(Application.Current, NewColor, NewTheme.Item1); }
protected override void OnStartup(StartupEventArgs e) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); RegistryKey RegistryCU = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64); RegistryKey key = RegistryCU.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", true); if (key.GetValue("AppsUseLightTheme").ToString() == "1") { ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); } base.OnStartup(e); }
public static void ChangeTheme(Accent accent, AppTheme theme) { Accent defaultAccent = ThemeManager.GetAccent("Cyan"); AppTheme defaultAppTheme = ThemeManager.GetAppTheme("BaseLight"); ThemeManager.ChangeAppStyle(Application.Current, accent ?? defaultAccent, theme ?? defaultAppTheme); if (theme != null) { ThemeManager.ChangeAppTheme(Application.Current, theme.Name); } else { ThemeManager.ChangeAppTheme(Application.Current, defaultAppTheme.Name); } }
public WpfListaContrato(object ventana_origen) { InitializeComponent(); objeto = ventana_origen; cboTipoEvento.ItemsSource = new TipoEvento().ReadAll(); dtgContrato.ItemsSource = new Contrato().ReadAll(); if (objeto.GetType() == typeof(MainWindow)) { btnTraspasar.Visibility = Visibility.Hidden; } if (sw.contraste == 1) { ThemeManager.ChangeAppTheme(this, "BaseDark"); } }
public WpfContrato() { InitializeComponent(); ServiceReferenceUF.Service1Client WS = new ServiceReferenceUF.Service1Client(); txtValorUF.Text = WS.UF().ToString(); cboTipoEvento.ItemsSource = new TipoEvento().ReadAll(); limpiar(); verificarArchivoBinario(); dt.Interval = TimeSpan.FromMinutes(5); //cada 5min dt.Tick += dtTiempo; dt.Start(); //inicia el timer if (sw.contraste == 1) { ThemeManager.ChangeAppTheme(this, "BaseDark"); } }
void timer_Elapsed(object sender, ElapsedEventArgs e) { this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { if (pgbLogoff.Value < 50) { pgbLogoff.Value += 1; } else { ThemeManager.ChangeAppTheme(Application.Current, "BaseDark"); timer.Stop(); LoginScreen loginScreen = new LoginScreen(); loginScreen.Show(); this.Close(); } })); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { MainWindow mw = null; Point3d startLoc = Point3d.Unset; int theme = 0; string colorName = ""; if (!DA.GetData <MainWindow>("Window", ref mw)) { return; } if (DA.GetData <Point3d>("Starting Location", ref startLoc)) { mw.Left = startLoc.X; mw.Top = startLoc.Y; } if (DA.GetData <int>("Theme", ref theme)) { switch (theme) { case 0: ThemeManager.ChangeAppTheme(mw, "BaseLight"); break; case 1: ThemeManager.ChangeAppTheme(mw, "BaseDark"); break; default: AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "That's not a valid theme - only 0 or 1 (light or dark) can be used."); break; } } if (DA.GetData <string>("Accent Color", ref colorName)) { Tuple <AppTheme, Accent> currStyle = ThemeManager.DetectAppStyle(mw); ThemeManager.ChangeAppStyle(mw, ThemeManager.GetAccent(colorName), currStyle.Item1); } }
private void tgsTema_IsCheckedChanged(object sender, System.EventArgs e) { try { ThemeManager.ChangeAppTheme(Application.Current, "BaseDark"); ImageBrush DarkImage = new ImageBrush(); Image imageDark = new Image(); imageDark.Source = new BitmapImage( new Uri( "pack://application:,,,/IMAGES/Wallpaper Oficial SPPDI material.png")); DarkImage.ImageSource = imageDark.Source; grdPrincipal.Background = DarkImage; DarkImage.Stretch = Stretch.Fill; //Mudar a cor do botao logoff SolidColorBrush solidDark = new SolidColorBrush(); solidDark.Color = Color.FromArgb(255, 38, 38, 38); btnFzrLogoff.Background = solidDark; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void tgsTema_Checked(object sender, System.Windows.RoutedEventArgs e) { try { ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); ImageBrush LightImage = new ImageBrush(); Image image = new Image(); image.Source = new BitmapImage( new Uri( "pack://application:,,,/IMAGES/Wallpaper Oficial SPPDI material LIGHT.png")); LightImage.ImageSource = image.Source; grdPrincipal.Background = LightImage; LightImage.Stretch = Stretch.Fill; //Mudar a cor do botao Logoff SolidColorBrush solidLight = new SolidColorBrush(); solidLight.Color = Color.FromArgb(255, 147, 147, 147); btnFzrLogoff.Background = solidLight; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static ResourceDictionary CreateTheme(string baseColorScheme, Color accentBaseColor, string name = null, bool changeImmediately = false) { name = name ?? $"RuntimeTheme_{baseColorScheme}_{accentBaseColor.ToString().Replace("#", string.Empty)}"; var generatorParameters = GetGeneratorParameters(); var themeTemplateContent = GetThemeTemplateContent(); var variant = generatorParameters.BaseColorSchemes.First(x => x.Name == baseColorScheme); var colorScheme = new ColorScheme(); colorScheme.Name = accentBaseColor.ToString().Replace("#", string.Empty); var values = colorScheme.Values; values.Add("AccentBaseColor", accentBaseColor.ToString()); values.Add("AccentColor", Color.FromArgb(204, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString()); values.Add("AccentColor2", Color.FromArgb(153, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString()); values.Add("AccentColor3", Color.FromArgb(102, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString()); values.Add("AccentColor4", Color.FromArgb(51, accentBaseColor.R, accentBaseColor.G, accentBaseColor.B).ToString()); values.Add("HighlightColor", accentBaseColor.ToString()); values.Add("IdealForegroundColor", IdealTextColor(accentBaseColor).ToString()); var xamlContent = new ColorSchemeGenerator().GenerateColorSchemeFileContent(generatorParameters, variant, colorScheme, themeTemplateContent, name, name); var resourceDictionary = (ResourceDictionary)XamlReader.Parse(xamlContent); ThemeManager.AddAppTheme(name, resourceDictionary); // Apply theme if (changeImmediately) { ThemeManager.ChangeAppTheme(Application.Current, name); } return(resourceDictionary); }
/// <summary> /// On app start /// </summary> /// <param name="e">Startup EventArgs</param> protected override void OnStartup(StartupEventArgs e) { Settings.BESettings.LoadSettings(); Process process = Process.GetCurrentProcess(); process.PriorityClass = ProcessPriorityClass.Normal; // Set the current thread to run at 'Highest' Priority Thread thread = Thread.CurrentThread; thread.Priority = ThreadPriority.Highest; Boolean dmi = true; System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Current.DispatcherUnhandledException += this.Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += this.CurrentDomain_UnhandledException; System.Windows.Forms.Application.ThreadException += this.Application_ThreadException; if (!File.Exists(Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer\Settings.sqlite"))) { var beAppDataPath = Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer"); if (!Directory.Exists(beAppDataPath)) { Directory.CreateDirectory(beAppDataPath); } File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.sqlite"), Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer\Settings.sqlite")); } //// loads current Ribbon color theme try { switch (Settings.BESettings.CurrentTheme) { case "Dark": ThemeManager.ChangeAppTheme(this, "BaseDark"); break; default: ThemeManager.ChangeAppTheme(this, "BaseLight"); break; } } catch (Exception ex) { // MessageBox.Show(String.Format("An error occurred while trying to load the theme data from the Registry. \n\r \n\r{0}\n\r \n\rPlease let us know of this issue at http://bugtracker.better-explorer.com/", ex.Message), "RibbonTheme Error - " + ex.ToString()); MessageBox.Show( $"An error occurred while trying to load the theme data from the Registry. \n\r \n\rRibbonTheme Error - {ex}\n\r \n\rPlease let us know of this issue at http://bugtracker.better-explorer.com/", ex.Message); } if (e.Args.Any()) { dmi = e.Args.Length >= 1; IsStartWithStartupTab = e.Args.Contains("/norestore"); if (e.Args[0] != "-minimized") { this.Properties["cmd"] = e.Args[0]; } else { IsStartMinimized = true; } } if (!ApplicationInstanceManager.CreateSingleInstance(Assembly.GetExecutingAssembly().GetName().Name, this.SingleInstanceCallback) && dmi) { return; // exit, if same app. is running } base.OnStartup(e); try { this.SelectCulture(Settings.BESettings.Locale); } catch { // MessageBox.Show(String.Format("A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {0}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/.", Locale)); MessageBox.Show($"A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {Settings.BESettings.Locale}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/."); this.Shutdown(); } }
private void NightModeCheckBox_Checked(object sender, RoutedEventArgs e) { ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); ThemeManager.ChangeAppTheme(Application.Current, "BaseDark"); GlobalConsts.Theme = ThemeManager.GetAppTheme("BaseDark"); }
/// <summary> /// Change the AppTheme /// </summary> /// <param name="name">Name of the AppTheme</param> public static void ChangeAppTheme(string name) { ThemeManager.ChangeAppTheme(Application.Current, name); }
private static void ChangeAppTheme(string themeName) { ThemeManager.ChangeAppTheme(Application.Current, themeName); }
/// <summary> /// This is the constructor for the MainWindow ViewModel /// </summary> public MainWindowViewModel(IKeyManager Manager, DataProvider data, IReader reader, IDialogCoordinator dialogCoordinator, bool IsTesting = false) { AddLicenses(); //connect delegate commands to icommand handlers _changeToHeightCommand = new DelegateCommand(OnChangeToHeight); _changeToLoadCommand = new DelegateCommand(OnChangeToLoad); _changeToAboutCommand = new DelegateCommand(OnChangeToAbout); _changeToAccelerationGraphCommand = new DelegateCommand(OnChangeToAccelerationGraph); _changeToAccelerationTimedCommand = new DelegateCommand(OnChangeToAccelerationTimed); _changeToAngleGraphCommand = new DelegateCommand(OnChangeToAngleGraph); _changeToAngleTimedCommand = new DelegateCommand(OnChangeToAngleTimed); _changeToMapRouteCommand = new DelegateCommand(OnChangeToMapRoute); _changeToMapTimedCommand = new DelegateCommand(OnChangeToMapTimed); _changeToVelocityGraphCommand = new DelegateCommand(OnChangeToVelocityGraph); _changeToVelocityTimedCommand = new DelegateCommand(OnChangeToVelocityTimed); _changeToHorizonCommand = new DelegateCommand(OnChangeToHorizonCommand); dataProvider = data; coordinator = dialogCoordinator; manager = Manager; MapEnabled = true; _mapAvailable = true; if (!reader.FileExists("CIDER.cfg")) { reader.WriteAllText("", "CIDER.cfg"); } if (!manager.Fetch()) { MapEnabled = false; _mapAvailable = false; displayApiKeyInfo = true; } if (!IsTesting) { if (ThemeManager.DetectAppStyle().Item1 == ThemeManager.GetAppTheme("BaseDark")) { var theme = ThemeManager.DetectAppStyle(); ThemeManager.ChangeAppTheme(App.Current, "BaseDark"); } } // Check the license try { LicenseWriter licenseWriter = new LicenseWriter(reader); _licenseAccepted = licenseWriter.ReadAgreementState(); LicenseManager.LicensesAccepted = _licenseAccepted; if (_licenseAccepted == false) { Licenses licenses = new Licenses(); licenses.Show(); _licenseAccepted = LicenseManager.LicensesAccepted; } } catch (Exception ex) { logger.Error(ex, "Couldn't configure License State"); _licenseAccepted = false; } ButtonState(false); MapEnabled = false; if (_licenseAccepted) { ButtonState(true); } KeyManager.MapKeyChangedEvent += KeyManager_MapKeyChangedEvent; LicenseHolder.LicenseChangedEvent += LicenseHolder_LicenseChangedEvent; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { MainWindow mw = null; Point3d startLoc = Point3d.Unset; int theme = 0; string colorName = ""; if (!DA.GetData <MainWindow>("Window", ref mw)) { return; } //if the user has spec'd a location, move the window if (DA.GetData <Point3d>("Starting Location", ref startLoc)) { mw.Left = startLoc.X; mw.Top = startLoc.Y; } //set the theme if (DA.GetData <int>("Theme", ref theme)) { switch (theme) { case 0: ThemeManager.ChangeAppTheme(mw, "BaseLight"); break; case 1: ThemeManager.ChangeAppTheme(mw, "BaseDark"); break; default: AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "That's not a valid theme - only 0 or 1 (light or dark) can be used."); break; } } //set title bar visibility bool showTitleBar = true; DA.GetData <bool>("Show Title Bar", ref showTitleBar); SetTitleBarVisibility(mw, showTitleBar); //set background color System.Drawing.Color backgroundColor = System.Drawing.Color.Transparent; if (DA.GetData <System.Drawing.Color>("Background Color", ref backgroundColor)) { mw.Background = new SolidColorBrush(HUI_Util.ToMediaColor(backgroundColor)); } //set accent color if (DA.GetData <string>("Accent Color", ref colorName)) { //get the current accent and theme so that theme can be preserved while accent changes Tuple <AppTheme, Accent> currStyle = ThemeManager.DetectAppStyle(mw); ThemeManager.ChangeAppStyle(mw, ThemeManager.GetAccent(colorName), currStyle.Item1); } }
public void Initialize() { // Check for updates of installed wholesome files ThemeManager.ChangeAppTheme(Application.Current, "BaseDark"); }
public void Dispose() { ThemeManager.ChangeAppTheme(Application.Current, "BaseLight"); }