Skip to content

Commit

Permalink
V5.0.1 2021/11/27
Browse files Browse the repository at this point in the history
- Added option to customize timer frequency.
  • Loading branch information
mayerwin committed Nov 28, 2021
1 parent 62200e8 commit 0edc93b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CustomizeVSWindowTitle/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="5126c493-138a-46d7-a04d-ad772f6be159" Version="5.0.0" Language="en-US" Publisher="Erwin Mayer" />
<Identity Id="5126c493-138a-46d7-a04d-ad772f6be159" Version="5.0.1" Language="en-US" Publisher="Erwin Mayer" />
<DisplayName>Customize Visual Studio Window Title</DisplayName>
<Description xml:space="preserve">This lightweight extension allows changing the window title of Visual Studio to include a folder tree with a configurable min depth and max depth distance from the solution/project file, and the use of special tags to help with many other possible scenarios (Git, Hg, TFS, SVN...).
Solution-specific overriding rules are available as well to cover virtually any possible renaming needs. It can also be configured so that the rules apply only when at least two instances of Visual Studio are running with the same window title.
Expand Down
60 changes: 30 additions & 30 deletions CustomizeVSWindowTitle17/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="CustomizeVSWindowTitle17.8f96ef44-09b8-47c5-ae51-2d83310a23a1" Version="5.0.0" Language="en-US" Publisher="Erwin Mayer" />
<DisplayName>Customize Visual Studio Window Title</DisplayName>
<Description xml:space="preserve">This lightweight extension allows changing the window title of Visual Studio to include a folder tree with a configurable min depth and max depth distance from the solution/project file, and the use of special tags to help with many other possible scenarios (Git, Hg, TFS, SVN...).
<Metadata>
<Identity Id="CustomizeVSWindowTitle17.8f96ef44-09b8-47c5-ae51-2d83310a23a1" Version="5.0.1" Language="en-US" Publisher="Erwin Mayer" />
<DisplayName>Customize Visual Studio Window Title</DisplayName>
<Description xml:space="preserve">This lightweight extension allows changing the window title of Visual Studio to include a folder tree with a configurable min depth and max depth distance from the solution/project file, and the use of special tags to help with many other possible scenarios (Git, Hg, TFS, SVN...).
Solution-specific overriding rules are available as well to cover virtually any possible renaming needs. It can also be configured so that the rules apply only when at least two instances of Visual Studio are running with the same window title.
This is particularly useful when branching a solution/project: it becomes possible to easily identify which branch you are working on, in case both would have the same solution/project name.</Description>
<MoreInfo>https://www.erwinmayer.com/labs/visual-studio-2010-extension-rename-visual-studio-window-title</MoreInfo>
<License>License.txt</License>
<Icon>Icon.png</Icon>
<PreviewImage>Screenshot.png</PreviewImage>
<Tags>Git, Hg, TFS, Team Foundation Server, SVN, Window title, solution path, path, explicit title, multiple instances, rename title, change title, replace title, branch name</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
<InstallationTarget Id="Microsoft.VisualStudio.Enterprise" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
<MoreInfo>https://www.erwinmayer.com/labs/visual-studio-2010-extension-rename-visual-studio-window-title</MoreInfo>
<License>License.txt</License>
<Icon>Icon.png</Icon>
<PreviewImage>Screenshot.png</PreviewImage>
<Tags>Git, Hg, TFS, Team Foundation Server, SVN, Window title, solution path, path, explicit title, multiple instances, rename title, change title, replace title, branch name</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
<InstallationTarget Id="Microsoft.VisualStudio.Enterprise" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
</PackageManifest>
12 changes: 9 additions & 3 deletions CustomizeVSWindowTitleShared/CustomizeVSWindowTitlePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
this.GlobalSettingsWatcher.SettingsCleared = this.OnSettingsCleared;
this.SolutionSettingsWatcher.SettingsCleared = this.OnSettingsCleared;

//Every 5 seconds, we check the window titles in case we missed an event.
this.ResetTitleTimer = new System.Windows.Forms.Timer { Interval = 5000 };
this.ResetTitleTimer = new System.Windows.Forms.Timer { Interval = this.UiSettings.ResetTitleTimerMsPeriod };
this.ResetTitleTimer.Tick += this.UpdateWindowTitleAsync;
this.ResetTitleTimer.Start();
}
Expand Down Expand Up @@ -209,7 +208,12 @@ internal GlobalSettingsPageGrid UiSettings {
if (this._UiSettings == null) {
Globals.InvokeOnUIThread(() => {
this._UiSettings = this.GetDialogPage(typeof(GlobalSettingsPageGrid)) as GlobalSettingsPageGrid; // as is faster than cast
this._UiSettings.SettingsChanged += (s, e) => this.OnIdeSolutionEvent();
this._UiSettings.SettingsChanged += (s, e) => {
if (this.ResetTitleTimer.Interval != this._UiSettings.ResetTitleTimerMsPeriod) {
this.ResetTitleTimer.Interval = this._UiSettings.ResetTitleTimerMsPeriod;
}
this.OnIdeSolutionEvent();
};
});
}
return this._UiSettings;
Expand Down Expand Up @@ -323,6 +327,7 @@ private string GetVSState(string str) {
}

private void UpdateWindowTitleAsync(object state, EventArgs e) {
//WriteOutput($"UpdateWindowTitleAsync... {DateTime.Now.ToString("HH:mm:ss.fff")}");
try {
if (this.IDEName == null && Globals.DTE.MainWindow != null) {
this.IDEName = this.GetIDEName(Globals.DTE.MainWindow.Caption);
Expand Down Expand Up @@ -477,6 +482,7 @@ internal SettingsSet GetSettings(string solutionFp) {
public const string DefaultAppendedString = "\t";
public const int DefaultClosestParentDepth = 1;
public const int DefaultFarthestParentDepth = 1;
public const int DefaultResetTitleTimerMsPeriod = 5000;

private string GetPattern(string solutionFp, bool useDefault, SettingsSet settingsOverride) {
var settings = this.UiSettings;
Expand Down
10 changes: 8 additions & 2 deletions CustomizeVSWindowTitleShared/GlobalSettingsPageGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ public class GlobalSettingsPageGrid : DialogPage {
[DisplayName("Farthest parent folder depth")]
[Description("Default: 1. Distance of the farthest parent folder to be shown. 1 will only show the folder of the opened project/solution file, before the project/folder name")]
[DefaultValue(CustomizeVSWindowTitle.DefaultFarthestParentDepth)]
public int FarthestParentDepth { get; set; } = 1;
public int FarthestParentDepth { get; set; } = CustomizeVSWindowTitle.DefaultFarthestParentDepth;

[Category("General")]
[DisplayName("Closest parent folder depth")]
[Description("Default: 1. Distance of the closest parent folder to be shown. 1 will only show the folder of the opened project/solution file, before the project/folder name.")]
[DefaultValue(CustomizeVSWindowTitle.DefaultClosestParentDepth)]
public int ClosestParentDepth { get; set; } = 1;
public int ClosestParentDepth { get; set; } = CustomizeVSWindowTitle.DefaultClosestParentDepth;

[Category("General")]
[DisplayName("Rewrite timer")]
[Description("Default: 5000ms. Period to recheck if title may need to be rewritten, in case a relevant event wasn't detected.")]
[DefaultValue(CustomizeVSWindowTitle.DefaultResetTitleTimerMsPeriod)]
public int ResetTitleTimerMsPeriod { get; set; } = CustomizeVSWindowTitle.DefaultResetTitleTimerMsPeriod;

[Category("Patterns")]
[DisplayName("No document or solution open")]
Expand Down

0 comments on commit 0edc93b

Please sign in to comment.