From b8245ab7edf39201276e12af10ca37f17e14742f Mon Sep 17 00:00:00 2001 From: Henk-Jan Lebbink Date: Mon, 7 Mar 2016 13:53:20 +0100 Subject: [PATCH] Option Pages only show info to restart VS when needed --- CSHARP/OptionsPage/OptionsPageAsmDoc.cs | 27 ++++++--- .../OptionsPage/OptionsPageCodeCompletion.cs | 56 ++++++++++++++++--- CSHARP/OptionsPage/OptionsPageCodeFolding.cs | 35 ++++++++++-- .../OptionsPageSyntaxHighlighting.cs | 53 +++++++++++++++--- 4 files changed, 143 insertions(+), 28 deletions(-) diff --git a/CSHARP/OptionsPage/OptionsPageAsmDoc.cs b/CSHARP/OptionsPage/OptionsPageAsmDoc.cs index 27eccf38..3d722e0f 100644 --- a/CSHARP/OptionsPage/OptionsPageAsmDoc.cs +++ b/CSHARP/OptionsPage/OptionsPageAsmDoc.cs @@ -43,8 +43,8 @@ public class OptionsPageAsmDoc : DialogPage protected override void OnActivate(CancelEventArgs e) { base.OnActivate(e); - this._useAsmDoc = Properties.Settings.Default.CodeFolding_On; - this._asmDocUrl = Properties.Settings.Default.CodeFolding_EndTag; + this._useAsmDoc = Properties.Settings.Default.AsmDoc_On; + this._asmDocUrl = Properties.Settings.Default.AsmDoc_url; } /// @@ -95,18 +95,27 @@ protected override void OnDeactivate(CancelEventArgs e) protected override void OnApply(PageApplyEventArgs e) { //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO:{0}:OnApply", this.ToString())); - string title = null;// "Save Changes"; - string message = "Press OK to save changes. You may need to restart visual studio for the changes to take effect."; - int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + bool changed = false; + bool restartNeeded = false; - if (result == (int)VSConstants.MessageBoxResult.IDCANCEL) { - e.ApplyBehavior = ApplyKind.Cancel; - } else { + if (Properties.Settings.Default.AsmDoc_On != this._useAsmDoc) { Properties.Settings.Default.AsmDoc_On = this._useAsmDoc; + changed = true; + } + if (Properties.Settings.Default.AsmDoc_url != this._asmDocUrl) { Properties.Settings.Default.AsmDoc_url = this._asmDocUrl; + changed = true; + restartNeeded = true; + } + if (changed) { Properties.Settings.Default.Save(); - base.OnApply(e); } + if (restartNeeded) { + string title = null; + string message = "You may need to restart visual studio for the changes to take effect."; + int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + } + base.OnApply(e); } #endregion Event Handlers diff --git a/CSHARP/OptionsPage/OptionsPageCodeCompletion.cs b/CSHARP/OptionsPage/OptionsPageCodeCompletion.cs index 953c3417..46f25925 100644 --- a/CSHARP/OptionsPage/OptionsPageCodeCompletion.cs +++ b/CSHARP/OptionsPage/OptionsPageCodeCompletion.cs @@ -162,29 +162,71 @@ protected override void OnDeactivate(CancelEventArgs e) protected override void OnApply(PageApplyEventArgs e) { //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO:{0}:OnApply", this.ToString())); - string title = null; //"Save Changes"; - string message = "Press OK to save changes. You may need to restart visual studio for the changes to take effect."; - int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + bool changed = false; + bool restartNeeded = false; - if (result == (int)VSConstants.MessageBoxResult.IDCANCEL) { - e.ApplyBehavior = ApplyKind.Cancel; - } else { + + if (Properties.Settings.Default.CodeCompletion_On != this._useCodeCompletion) { Properties.Settings.Default.CodeCompletion_On = this._useCodeCompletion; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_x86 != this._x86) { Properties.Settings.Default.CodeCompletion_x86 = this._x86; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_i686 != this._i686) { Properties.Settings.Default.CodeCompletion_i686 = this._i686; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_mmx != this._mmx) { Properties.Settings.Default.CodeCompletion_mmx = this._mmx; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_sse != this._sse) { Properties.Settings.Default.CodeCompletion_sse = this._sse; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_sse2 != this._sse2) { Properties.Settings.Default.CodeCompletion_sse2 = this._sse2; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_sse3 != this._sse3) { Properties.Settings.Default.CodeCompletion_sse3 = this._sse3; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_ssse3 != this._ssse3) { Properties.Settings.Default.CodeCompletion_ssse3 = this._ssse3; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_sse41 != this._sse41) { Properties.Settings.Default.CodeCompletion_sse41 = this._sse41; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_sse42 != this._sse42) { Properties.Settings.Default.CodeCompletion_sse42 = this._sse42; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_avx != this._avx) { Properties.Settings.Default.CodeCompletion_avx = this._avx; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_avx2 != this._avx2) { Properties.Settings.Default.CodeCompletion_avx2 = this._avx2; + changed = true; + } + if (Properties.Settings.Default.CodeCompletion_knc != this._knc) { Properties.Settings.Default.CodeCompletion_knc = this._knc; + changed = true; + } + if (changed) { Properties.Settings.Default.Save(); - base.OnApply(e); } + if (restartNeeded) { + string title = null; + string message = "You may need to restart visual studio for the changes to take effect."; + int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + } + base.OnApply(e); } #endregion Event Handlers diff --git a/CSHARP/OptionsPage/OptionsPageCodeFolding.cs b/CSHARP/OptionsPage/OptionsPageCodeFolding.cs index 2e9e88a4..9bf27c38 100644 --- a/CSHARP/OptionsPage/OptionsPageCodeFolding.cs +++ b/CSHARP/OptionsPage/OptionsPageCodeFolding.cs @@ -101,19 +101,46 @@ protected override void OnDeactivate(CancelEventArgs e) protected override void OnApply(PageApplyEventArgs e) { //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO:{0}:OnApply", this.ToString())); - string title = null;// "Save Changes"; + bool changed = false; + bool restartNeeded = false; + + if (Properties.Settings.Default.CodeFolding_On != this._useCodeFolding) { + Properties.Settings.Default.CodeFolding_On = this._useCodeFolding; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.CodeFolding_BeginTag != this._beginTag) { + Properties.Settings.Default.CodeFolding_BeginTag = this._beginTag; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.CodeFolding_EndTag != this._endTag) { + Properties.Settings.Default.CodeFolding_EndTag = this._endTag; + changed = true; + restartNeeded = true; + } + if (changed) { + Properties.Settings.Default.Save(); + } + if (restartNeeded) { + string title = null; + string message = "You may need to restart visual studio for the changes to take effect."; + int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + } + base.OnApply(e); + + /* + string title = null; string message = "Press OK to save changes. You may need to restart visual studio for the changes to take effect."; int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); if (result == (int)VSConstants.MessageBoxResult.IDCANCEL) { e.ApplyBehavior = ApplyKind.Cancel; } else { - Properties.Settings.Default.CodeFolding_On = this._useCodeFolding; - Properties.Settings.Default.CodeFolding_BeginTag = this._beginTag; - Properties.Settings.Default.CodeFolding_EndTag = this._endTag; Properties.Settings.Default.Save(); base.OnApply(e); } + */ } #endregion Event Handlers diff --git a/CSHARP/OptionsPage/OptionsPageSyntaxHighlighting.cs b/CSHARP/OptionsPage/OptionsPageSyntaxHighlighting.cs index eccc22aa..0711d1b8 100644 --- a/CSHARP/OptionsPage/OptionsPageSyntaxHighlighting.cs +++ b/CSHARP/OptionsPage/OptionsPageSyntaxHighlighting.cs @@ -136,26 +136,63 @@ protected override void OnDeactivate(CancelEventArgs e) protected override void OnApply(PageApplyEventArgs e) { //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO:{0}:OnApply", this.ToString())); - string title = null; //"Save Changes"; - string message = "Press OK to save changes. You may need to restart visual studio for the changes to take effect."; - int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + bool changed = false; + bool restartNeeded = false; - if (result == (int)VSConstants.MessageBoxResult.IDCANCEL) { - e.ApplyBehavior = ApplyKind.Cancel; - } else { + if (Properties.Settings.Default.SyntaxHighlighting_On != this._useSyntaxHighlighting) { Properties.Settings.Default.SyntaxHighlighting_On = this._useSyntaxHighlighting; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Opcode != this._colorMnemonic) { Properties.Settings.Default.SyntaxHighlighting_Opcode = this._colorMnemonic; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Register != this._colorRegister) { Properties.Settings.Default.SyntaxHighlighting_Register = this._colorRegister; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Remark != this._colorRemark) { Properties.Settings.Default.SyntaxHighlighting_Remark = this._colorRemark; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Directive != this._colorDirective) { Properties.Settings.Default.SyntaxHighlighting_Directive = this._colorDirective; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Constant != this._colorConstant) { Properties.Settings.Default.SyntaxHighlighting_Constant = this._colorConstant; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Jump != this._colorJump) { Properties.Settings.Default.SyntaxHighlighting_Jump = this._colorJump; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Label != this._colorLabel) { Properties.Settings.Default.SyntaxHighlighting_Label = this._colorLabel; + changed = true; + restartNeeded = true; + } + if (Properties.Settings.Default.SyntaxHighlighting_Misc != this._colorMisc) { Properties.Settings.Default.SyntaxHighlighting_Misc = this._colorMisc; - + changed = true; + restartNeeded = true; + } + if (changed) { Properties.Settings.Default.Save(); - base.OnApply(e); } + if (restartNeeded) { + string title = null; + string message = "You may need to restart visual studio for the changes to take effect."; + int result = VsShellUtilities.ShowMessageBox(Site, message, title, OLEMSGICON.OLEMSGICON_QUERY, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); + } + base.OnApply(e); } #endregion Event Handlers