private void Page_Loaded(object sender, RoutedEventArgs e) { mw.backButton.Visibility = Visibility.Hidden; Timer checkForChange = new Timer(); DataContext = new XAMLStyles { }; checkForChange.Interval = 1000; checkForChange.Elapsed += (se, ea) => { try { if (Styles.themeChanged) { Dispatcher.Invoke(() => { DataContext = new XAMLStyles { }; themeChanged(); }); } } catch { } }; checkForChange.Start(); themeChanged(); }
private void background_Loaded(object sender, RoutedEventArgs e) { Timer checkForChange = new Timer(); DataContext = new XAMLStyles { }; checkForChange.Interval = 1000; checkForChange.Elapsed += (se, ea) => { try { if (Styles.themeChanged) { Dispatcher.Invoke(() => { DataContext = new XAMLStyles { }; }); } } catch { } }; checkForChange.Start(); if (Styles.background == "#FFFFFFFF") { ColourLight.IsChecked = true; } else { ColourDark.IsChecked = true; } }
public void Page_Loaded(object sender, RoutedEventArgs e) { firstOpen = true; Timer checkForChange = new Timer(); DataContext = new XAMLStyles { }; checkForChange.Interval = 1000; checkForChange.Tick += (se, ea) => { try { if (Styles.themeChanged) { Dispatcher.Invoke(() => { DataContext = new XAMLStyles { }; }); } } catch { } }; checkForChange.Start(); DEVMODE vDevMode = new DEVMODE(); List <string> displayResolutions1 = new List <string>(); int i = 0; while (EnumDisplaySettings(null, i, ref vDevMode)) { displayResolutions1.Add($"{vDevMode.dmPelsWidth.ToString()} x {vDevMode.dmPelsHeight.ToString()} @{vDevMode.dmDisplayFrequency.ToString()}hz"); i++; } List <string> displayResolutions2 = new List <string>(displayResolutions1.Distinct()); List <string> displayResolutions3 = new List <string>(displayResolutions2); bool firstPass = true; string toCompare = ""; foreach (string str in displayResolutions2) { if (firstPass == false) { string[] bounds1; string[] bounds2; bounds1 = str.Split('@'); bounds2 = toCompare.Split('@'); bounds1[1] = bounds1[1].Substring(0, bounds1[1].Length - 2); bounds2[1] = bounds2[1].Substring(0, bounds2[1].Length - 2); if (bounds1[0] == bounds2[0]) { if (Convert.ToInt32(bounds1[1]) > Convert.ToInt32(bounds2[1])) { displayResolutions3.Remove(toCompare); } else if (Convert.ToInt32(bounds1[1]) < Convert.ToInt32(bounds2[1])) { displayResolutions3.Remove(str); } else if (Convert.ToInt32(bounds1[1]) == Convert.ToInt32(bounds2[1])) { displayResolutions3.Remove(toCompare); } } } else { firstPass = false; } toCompare = str; } foreach (string resolution in displayResolutions3) { cboResolutions.Items.Add(new ComboBoxItem { Content = resolution, Background = Styles.bc(Styles.border), Foreground = Styles.bc(Styles.foreground), BorderThickness = new Thickness(0), Style = FindResource("cboItemStyle") as Style, Height = 40, VerticalContentAlignment = VerticalAlignment.Center }); } foreach (string resolution in displayResolutions3) { string[] bounds1; bounds1 = resolution.Split('@'); if (bounds1[0].Contains(startScreenWidth.ToString()) && bounds1[0].Contains(startScreenHeight.ToString())) { cboResolutions.Text = resolution; previousComboText = resolution; break; } } }