From 3d9eac04977c5e8676f16b4831dcee989d69a92e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 12 Feb 2013 15:37:33 -0600 Subject: [PATCH] Support Tortoise Git icon set in Visual Studio 2012 --- SccGlyphsHelper.cs | 46 ++++++++++++++++++++++++++++++------ SccProviderOptionsControl.cs | 6 +++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/SccGlyphsHelper.cs b/SccGlyphsHelper.cs index 1d72e5d..5af91fd 100644 --- a/SccGlyphsHelper.cs +++ b/SccGlyphsHelper.cs @@ -13,6 +13,7 @@ internal static class SccGlyphsHelper // Our custom image list private static ImageList _customSccGlyphsImageList; + private static bool? _usingVisualStudio2010Icons; // Indexes of icons in our custom image list private enum CustomSccGlyphs2010 @@ -36,7 +37,7 @@ public static VsStateIcon Tracked { get { - if (GitSccOptions.IsVisualStudio2010 && GitSccOptions.Current.UseTGitIconSet) + if (UsingTortoiseGitIcons) return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Tracked); return VsStateIcon.STATEICON_CHECKEDIN; @@ -47,7 +48,7 @@ public static VsStateIcon Modified { get { - if (GitSccOptions.IsVisualStudio2010 && GitSccOptions.Current.UseTGitIconSet) + if (UsingTortoiseGitIcons) return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Modified); return VsStateIcon.STATEICON_CHECKEDOUT; @@ -58,7 +59,7 @@ public static VsStateIcon New { get { - if (GitSccOptions.IsVisualStudio2010) + if (UsingVisualStudio2010Icons) return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Untracked); return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.New); @@ -77,7 +78,7 @@ public static VsStateIcon Staged { get { - if (GitSccOptions.IsVisualStudio2010) + if (UsingVisualStudio2010Icons) return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Staged); return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.Staged); @@ -104,7 +105,7 @@ public static VsStateIcon Conflict { get { - if (GitSccOptions.IsVisualStudio2010) + if (UsingVisualStudio2010Icons) return VsStateIcon.STATEICON_DISABLED; return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.Conflicted); @@ -115,7 +116,7 @@ public static VsStateIcon Merged { get { - if (GitSccOptions.IsVisualStudio2010) + if (UsingVisualStudio2010Icons) return Modified; return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.Merged); @@ -130,6 +131,37 @@ public static VsStateIcon Default } } + private static bool UsingVisualStudio2010Icons + { + get + { + if (!_usingVisualStudio2010Icons.HasValue) + { + if (GitSccOptions.IsVisualStudio2010) + _usingVisualStudio2010Icons = true; + else + _usingVisualStudio2010Icons = GitSccOptions.Current.UseTGitIconSet; + } + + return _usingVisualStudio2010Icons.Value; + } + } + + private static bool UsingTortoiseGitIcons + { + get + { + if (!UsingVisualStudio2010Icons) + return false; + + // only reason to use the 2010 icons in 2012 is if we are using tortoise icons + if (GitSccOptions.IsVisualStudio2012) + return true; + + return GitSccOptions.Current.UseTGitIconSet; + } + } + public static uint GetCustomGlyphList(uint baseIndex) { // If this is the first time we got called, construct the image list, remember the index, etc @@ -151,7 +183,7 @@ public static uint GetCustomGlyphList(uint baseIndex) // Add the custom scc glyphs we support to the list // NOTE: VS2005 and VS2008 are limited to 4 custom scc glyphs (let's hope this will change in future versions) - Image sccGlyphs = GitSccOptions.IsVisualStudio2010 ? Resources.SccGlyphs : Resources.SccGlyphs2012; + Image sccGlyphs = UsingVisualStudio2010Icons ? Resources.SccGlyphs : Resources.SccGlyphs2012; _customSccGlyphsImageList.Images.AddStrip(sccGlyphs); } diff --git a/SccProviderOptionsControl.cs b/SccProviderOptionsControl.cs index 4a57f14..48d997f 100644 --- a/SccProviderOptionsControl.cs +++ b/SccProviderOptionsControl.cs @@ -357,12 +357,14 @@ private void SccProviderOptionsControl_Load(object sender, EventArgs e) this.checkBox1.Checked = GitSccOptions.Current.NotExpandGitExtensions; this.checkBox2.Checked = GitSccOptions.Current.NotExpandTortoiseGit; this.checkBox3.Checked = GitSccOptions.Current.UseTGitIconSet; - this.checkBox3.Enabled = GitSccOptions.IsVisualStudio2010; this.checkBox4.Checked = GitSccOptions.Current.DisableAutoRefresh; this.checkBox5.Checked = GitSccOptions.Current.DisableAutoLoad; this.checkBox6.Checked = GitSccOptions.Current.NotUseUTF8FileNames; this.chkDisableDiffMargin.Checked = GitSccOptions.Current.DisableDiffMargin; this.useVsDiffChk.Checked = GitSccOptions.Current.UseVsDiff; + + if (GitSccOptions.IsVisualStudio2012) + checkBox3.Text += " (requires restart)"; } private void button1_Click(object sender, EventArgs e) @@ -403,7 +405,7 @@ internal void Save() GitSccOptions.Current.TortoiseGitPath = this.textBox4.Text; GitSccOptions.Current.NotExpandGitExtensions = this.checkBox1.Checked; GitSccOptions.Current.NotExpandTortoiseGit = this.checkBox2.Checked; - GitSccOptions.Current.UseTGitIconSet = GitSccOptions.IsVisualStudio2010 && this.checkBox3.Checked; + GitSccOptions.Current.UseTGitIconSet = this.checkBox3.Checked; GitSccOptions.Current.DisableAutoRefresh = this.checkBox4.Checked; GitSccOptions.Current.DisableAutoLoad = this.checkBox5.Checked; GitSccOptions.Current.NotUseUTF8FileNames = this.checkBox6.Checked;