private async Task UpdateTitleBarControllerListAsync() { await JoinableTaskFactory.SwitchToMainThreadAsync(); Window[] windows = new Window[Application.Current.Windows.Count]; Application.Current.Windows.CopyTo(windows, 0); // Destroy old ones. windowTitleBarController = windowTitleBarController.Where(x => windows.Contains(x.Key)) .ToDictionary(x => x.Key, x => x.Value); // Look for new ones to add. foreach (Window window in windows) { if (windowTitleBarController.ContainsKey(window)) { continue; } var newController = TitleBarColorController.CreateFromWindow(window); if (newController != null) { windowTitleBarController.Add(window, newController); // Check if we already saved something for this solution. // Do this in here since we call UpdateTitleBarControllerList fairly regularly and in the most cases won't have any new controllers. System.Drawing.Color color; if (Settings.GetSolutionColorSetting(VSUtils.GetCurrentSolutionPath(), out color)) { newController.SetTitleBarColor(color); } } } }
private void SolutionOpened() { // Check if we already saved something for this solution. System.Drawing.Color color; if (Settings.GetSolutionColorSetting(VSUtils.GetCurrentSolutionPath(), out color)) { TitleBarColorControl.SetTitleBarColor(color); } }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { TitleBarColorControl = new TitleBarColorController(); PickColorCommand.Initialize(this); ResetColorCommand.Initialize(this); solutionEvents = VSUtils.GetDTE().Events.SolutionEvents; solutionEvents.Opened += SolutionOpened; base.Initialize(); }
private void Execute(object sender, EventArgs e) { var dialog = new ColorDialog(); dialog.AllowFullOpen = true; dialog.Color = package.TitleBarColorControl.TryGetTitleBarColor(); if (dialog.ShowDialog() == DialogResult.OK) { package.TitleBarColorControl.SetTitleBarColor(dialog.Color); package.Settings.SaveOrOverwriteSolutionColor(VSUtils.GetCurrentSolutionPath(), dialog.Color); } }
private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var dialog = new ColorDialog(); dialog.AllowFullOpen = true; dialog.Color = package.GetMainTitleBarColor(); dialog.CustomColors = package.Settings.GetCustomColorList(); if (dialog.ShowDialog() == DialogResult.OK) { package.SetTitleBarColor(dialog.Color); package.Settings.SaveOrOverwriteSolutionColor(VSUtils.GetCurrentSolutionPath(), dialog.Color); } package.Settings.SaveCustomColorList(dialog.CustomColors); }
/// <summary> /// IVsSolutionEvents3.OnAfterOpenSolution is called BEFORE a solution is fully loaded. /// This is different from EnvDTE.Events.SolutionEvents.Opened which is loaded after a resolution was loaded due to historical reasons: /// In earlier Visual Studio versions there was no asynchronous loading, so a solution was either fully loaded or not at all. /// </summary> public override int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) { // Check if we already saved something for this solution. string solutionPath = VSUtils.GetCurrentSolutionPath(); System.Drawing.Color color; if (package.Settings.GetSolutionColorSetting(solutionPath, out color)) { package.SetTitleBarColor(color); } else if (package.Settings.IsAutomaticColorPickEnabled()) { color = RandomColorGenerator.RandomColor.GetColor(RandomColorGenerator.ColorScheme.Random, VSUtils.IsUsingDarkTheme() ? RandomColorGenerator.Luminosity.Dark : RandomColorGenerator.Luminosity.Light); package.SetTitleBarColor(color); package.Settings.SaveOrOverwriteSolutionColor(solutionPath, color); } return(0); }
private void Execute(object sender, EventArgs e) { package.ResetTitleBarColor(); package.Settings.RemoveSolutionColorSetting(VSUtils.GetCurrentSolutionPath()); }
private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); package.ResetTitleBarColor(); package.Settings.RemoveSolutionColorSetting(VSUtils.GetCurrentSolutionPath()); }