Skip to content

Commit b9c6d14

Browse files
committed
Refactor of settings, separate validation from setter
1 parent 36a8a34 commit b9c6d14

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

RetailCoder.VBE/UI/Settings/GeneralSettingsViewModel.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public bool CheckVersionAtStartup
133133
}
134134

135135
private bool _compileBeforeParse;
136-
137136
public bool CompileBeforeParse
138137
{
139138
get => _compileBeforeParse;
@@ -146,22 +145,33 @@ public bool CompileBeforeParse
146145

147146
if (value && _vbeSettings.CompileOnDemand)
148147
{
149-
var result = _messageBox.Show(RubberduckUI.GeneralSettings_CompileBeforeParse_WarnCompileOnDemandEnabled,
150-
RubberduckUI.GeneralSettings_CompileBeforeParse_WarnCompileOnDemandEnabled_Caption, MessageBoxButtons.YesNo,
151-
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
152-
if(result == DialogResult.No)
148+
if(!SynchronizeVBESettings())
153149
{
154150
return;
155151
}
156-
157-
_vbeSettings.CompileOnDemand = false;
158152
}
159153

160154
_compileBeforeParse = value;
161155
OnPropertyChanged();
162156
}
163157
}
164158

159+
private bool SynchronizeVBESettings()
160+
{
161+
var result = _messageBox.Show(RubberduckUI.GeneralSettings_CompileBeforeParse_WarnCompileOnDemandEnabled,
162+
RubberduckUI.GeneralSettings_CompileBeforeParse_WarnCompileOnDemandEnabled_Caption, MessageBoxButtons.YesNo,
163+
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
164+
165+
if (result == DialogResult.No)
166+
{
167+
return false;
168+
}
169+
170+
_vbeSettings.CompileOnDemand = false;
171+
_vbeSettings.BackGroundCompile = false;
172+
return true;
173+
}
174+
165175
private int _autoSavePeriod;
166176
public int AutoSavePeriod
167177
{

0 commit comments

Comments
 (0)