Ejemplo n.º 1
0
 private void Theme_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (OnThemeChanged != null)
     {
         OnThemeChanged.Invoke(theme.SelectedItem as string);
     }
 }
Ejemplo n.º 2
0
        public static void ChangeTheme(ThemeType theme)
        {
            var mergedDictionaries = Application.Current.Resources.MergedDictionaries;

            if (mergedDictionaries != null)
            {
                mergedDictionaries.Clear();

                CrossSettings.Current.AddOrUpdateValue("SelectedTheme", (int)theme);

                switch (theme)
                {
                case ThemeType.Light:
                {
                    mergedDictionaries.Add(new LightTheme());
                    break;
                }

                case ThemeType.Dark:
                {
                    mergedDictionaries.Add(new DarkTheme());
                    break;
                }

                default:
                    mergedDictionaries.Add(new LightTheme());
                    break;
                }

                OnThemeChanged?.Invoke(new object(), new ThemeChangedEventArgs(theme));
            }
        }
 public int OnBroadcastMessage(uint msg, IntPtr wParam, IntPtr lParam)
 {
     if (msg == WM_SYSCOLORCHANGE)
     {
         OnThemeChanged?.Invoke(this, EventArgs.Empty);
     }
     return(VSConstants.S_OK);
 }
Ejemplo n.º 4
0
        public void WatchTheme()
        {
            var    currentUser = WindowsIdentity.GetCurrent();
            string query       = string.Format(
                CultureInfo.InvariantCulture,
                @"SELECT * FROM RegistryValueChangeEvent WHERE Hive = 'HKEY_USERS' AND KeyPath = '{0}\\{1}' AND ValueName = '{2}'",
                currentUser.User.Value,
                RegistryKeyPath.Replace(@"\", @"\\"),
                RegistryValueName);

            try
            {
                var watcher = new ManagementEventWatcher(query);
                watcher.EventArrived += (sender, args) =>
                {
                    WindowsTheme newWindowsTheme = GetWindowsTheme();
                    if (newWindowsTheme != CurrentTheme)
                    {
                        var acnt = (SolidColorBrush)SystemParameters.WindowGlassBrush;
                        acnt.Freeze();
                        OnThemeChanged?.Invoke(this, new ThemeChangeEventArgs
                        {
                            CurrentTheme = newWindowsTheme,
                            AccentColor  = acnt.Color
                        });
                        // React to new theme
                        CurrentTheme = newWindowsTheme;
                    }
                };

                // Start listening for events
                watcher.Start();

                DispatcherTimer accentWatcher = new DispatcherTimer
                {
                    Interval = TimeSpan.FromSeconds(5),
                };

                accentWatcher.Tick += AccentWatcher_Tick;

                accentWatcher.Start();
            }
            catch (Exception)
            {
                // This can fail on Windows 7
            }

            WindowsTheme initialTheme = GetWindowsTheme();
        }
Ejemplo n.º 5
0
        private void AccentWatcher_Tick(object sender, EventArgs e)
        {
            var acnt = (SolidColorBrush)SystemParameters.WindowGlassBrush;

            acnt.Freeze();
            var clr = acnt.Color;

            if (clr != CurrentAccent)
            {
                CurrentAccent = clr;

                OnThemeChanged?.Invoke(this, new ThemeChangeEventArgs
                {
                    CurrentTheme = CurrentTheme,
                    AccentColor  = CurrentAccent
                });
            }
        }
Ejemplo n.º 6
0
        public static bool SetTheme(Theme theme, bool invokeChanged = true)
        {
            bool themeChanged = currentTheme != theme;

            if (themeChanged)
            {
                currentTheme = theme;
                Application.Current.UserAppTheme = theme switch
                {
                    Theme.Light => OSAppTheme.Light,
                    Theme.Dark => OSAppTheme.Dark,
                    _ => OSAppTheme.Unspecified
                };
            }
            if (invokeChanged)
            {
                OnThemeChanged?.Invoke(new ThemeChangedEventArgs(IsEffectivelyLight));
            }
            return(themeChanged);
        }
        public void ApplyTheme(bool panelrefreshaswell = false)     // set true if your changing the theme
        {
            panel_close.Visible    = !ExtendedControls.Theme.Current.WindowsFrame;
            panel_minimize.Visible = !ExtendedControls.Theme.Current.WindowsFrame;
            label_version.Visible  = !ExtendedControls.Theme.Current.WindowsFrame && !EDDOptions.Instance.DisableVersionDisplay;

            // note in no border mode, this is not visible on the title bar but it is in the taskbar..
            this.Text = "EDDiscovery" + (EDDOptions.Instance.DisableVersionDisplay ? "" : " " + label_version.Text);

            ExtendedControls.Theme.Current.ApplyStd(this);

            statusStripEDD.Font = contextMenuStripTabs.Font = this.Font;

            OnThemeChanged?.Invoke();

            if (panelrefreshaswell)
            {
                Controller.RefreshDisplays(); // needed to cause them to cope with theme change
            }
            this.Refresh();                   // force thru refresh to make sure its repainted
        }
        public void ApplyTheme(bool panelrefreshaswell = false)     // set true if your changing the theme
        {
            panel_close.Visible    = !theme.WindowsFrame;
            panel_minimize.Visible = !theme.WindowsFrame;
            label_version.Visible  = !theme.WindowsFrame && !EDDOptions.Instance.DisableVersionDisplay;

            // note in no border mode, this is not visible on the title bar but it is in the taskbar..
            this.Text = "EDDiscovery" + (EDDOptions.Instance.DisableVersionDisplay ? "" : " " + label_version.Text);

            theme.ApplyStd(this);

            statusStrip.Font = contextMenuStripTabs.Font = this.Font;

            this.Refresh();                                             // force thru refresh to make sure its repainted

            //System.Diagnostics.Debug.WriteLine("Label version " + label_version.Location + " " + label_version.Size + " " + mainMenu.Size);

            OnThemeChanged?.Invoke();

            if (panelrefreshaswell)
            {
                Controller.RefreshDisplays(); // needed to cause them to cope with theme change
            }
        }
Ejemplo n.º 9
0
 public static void SetTheme(string name)
 {
     Name = name;
     OnThemeChanged?.Invoke();
 }
Ejemplo n.º 10
0
 private void RaiseThemeChanged(ThemeChangedEventArgs e)
 {
     OnThemeChanged?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 11
0
 private void ThemeChanged()
 {
     SetupColors();
     OnThemeChanged?.Invoke(this, EventArgs.Empty);
 }