1
我正試圖在settings.cs文件中保存一系列布爾值。這是我目前的保存方法。在設置文件中保存標誌屬性枚舉
private void SaveConfiguration()
{
VisibilitySwitchesFlags VisibilitySwitchesSaves = 0;
if (_menu.TreeItemDictionary[VisibilityItems.ReferenceLines].Checked)
VisibilitySwitchesSaves = VisibilitySwitchesFlags.ReferenceLinesChecked;
if (_menu.TreeItemDictionary[VisibilityItems.ShowProfilePoints].Checked)
VisibilitySwitchesSaves = VisibilitySwitchesFlags.ShowProfilePointsChecked;
Settings.Default.VisibilityViewStates = (int)VisibilitySwitchesSaves;//convert to int
Settings.Default.Save();
}
,這裏是我的Load方法:
private void LoadConfiguration()
{
VisibilitySwitchesFlags flags =(VisibilitySwitchesFlags)Settings.Default.VisibilityViewStates;
_menu.TreeItemDictionary[VisibilityItems.ReferenceLines].Checked = flags.HasFlag(VisibilitySwitchesFlags.ReferenceLinesChecked);
_menu.TreeItemDictionary[VisibilityItems.ShowProfilePoints].Checked = flags.HasFlag(VisibilitySwitchesFlags.ShowProfilePointsChecked);
}
負載後,看來,我保存不成功。我的方法有錯嗎?