Skip to content
代码片段 群组 项目
提交 ae390a7d 编辑于 作者: Joey Robichaud's avatar Joey Robichaud
浏览文件

Fix saving naming styles options page

- Allow page controls to store settings to option store before updating service
- Reload page control settings after a cancel or save
上级 876532e6
分支 main v1
No related tags found
无相关合并请求
......@@ -12,9 +12,6 @@
<TargetLatestRuntimePatch>false</TargetLatestRuntimePatch>
<SelfContained>true</SelfContained>
<!-- Do not build again when publishing -->
<NoBuild>true</NoBuild>
<PublishDir>$(ArtifactsDir)tools\ILAsm\$(Configuration)\</PublishDir>
</PropertyGroup>
......
......@@ -12,7 +12,9 @@ internal abstract class AbstractOptionPage : UIElementDialogPage
{
private static IOptionService s_optionService;
private static OptionStore s_optionStore;
private static bool s_needsLoadOnNextActivate = true;
private static bool s_needsToUpdateOptionStore = true;
private bool _needsLoadOnNextActivate = true;
protected abstract AbstractOptionPageControl CreateOptionPage(IServiceProvider serviceProvider, OptionStore optionStore);
......@@ -50,16 +52,22 @@ protected override void OnActivate(System.ComponentModel.CancelEventArgs e)
{
EnsureOptionPageCreated();
if (s_needsLoadOnNextActivate)
if (s_needsToUpdateOptionStore)
{
// Reset the option store to the current state of the options.
s_optionStore.SetOptions(s_optionService.GetOptions());
s_optionStore.SetRegisteredOptions(s_optionService.GetRegisteredOptions());
s_needsLoadOnNextActivate = false;
s_needsToUpdateOptionStore = false;
}
pageControl.LoadSettings();
if (_needsLoadOnNextActivate)
{
// For pages that don't use option bindings we need to load setting changes.
pageControl.LoadSettings();
_needsLoadOnNextActivate = false;
}
}
public override void LoadSettingsFromStorage()
......@@ -81,19 +89,33 @@ public override void LoadSettingsFromStorage()
// they may have been changed programmatically. Therefore, we'll set a flag so we load
// next time
s_needsLoadOnNextActivate = pageControl != null;
// If we are being canceled after the pageControl has already been created then
// we need to reset the option store on next load.
s_needsToUpdateOptionStore = pageControl != null;
// For pages that don't use option bindings we need to load settings when it is
// activated next.
_needsLoadOnNextActivate = true;
}
public override void SaveSettingsToStorage()
{
EnsureOptionPageCreated();
// Allow page controls to perist their settings to the option store before updating the
// option service.
pageControl.SaveSettings();
// Save the changes that were accumulated in the option store.
s_optionService.SetOptions(s_optionStore.GetOptions());
// Make sure we load the next time a page is activated, in case that options changed
// programmatically between now and the next time the page is activated
s_needsLoadOnNextActivate = true;
s_needsToUpdateOptionStore = true;
// For pages that don't use option bindings we need to load settings when it is
// activated next.
_needsLoadOnNextActivate = true;
}
protected override void OnClosed(EventArgs e)
......
......@@ -158,15 +158,7 @@ internal virtual void LoadSettings()
internal virtual void SaveSettings()
{
foreach (var bindingExpression in _bindingExpressions)
{
if (!bindingExpression.IsDirty)
{
continue;
}
bindingExpression.UpdateSource();
}
}
internal virtual void Close()
......
......@@ -177,10 +177,7 @@ internal override void SaveSettings()
namingStyles.ToImmutableAndFree(),
namingRules.ToImmutableAndFree());
var oldOptions = OptionStore.GetOptions();
var newOptions = oldOptions.WithChangedOption(SimplificationOptions.NamingPreferences, _languageName, info);
OptionStore.SetOptions(newOptions);
OptionLogger.Log(oldOptions, newOptions);
OptionStore.SetOption(SimplificationOptions.NamingPreferences, _languageName, info);
}
internal override void LoadSettings()
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册