public void LoadUserSettings(SearchPanelSettingsRepository settings) { if (settings.Items != null) { var internalItems = new List <SearchPanelItemSetting>(settings.Items); for (int i = 0; i < Items.Count; i++) { SearchPanelItem item = Items[i] as SearchPanelItem; if (item != null) { var n = from x in settings.Items where x.Name == item.Name select x; if (n.Count() == 0) { SearchPanelItemSetting setting = new SearchPanelItemSetting(); setting.Name = item.Name; setting.IsActive = item.IsActive; setting.Sequence = i; internalItems.Add(setting); } } } IList <SearchPanelItem> items = new List <SearchPanelItem>(Items.Cast <SearchPanelItem>()); Items.Clear(); foreach (SearchPanelItemSetting setting in internalItems.OrderBy <SearchPanelItemSetting, int>(x => x.Sequence)) { var n = (from x in items where x.Name == setting.Name select x).FirstOrDefault(); if (n != null) { n.IsActive = setting.IsActive; Items.Add(n); } } } UpdateItems(); }
public void SaveUserSettings(SearchPanelSettingsRepository settings) { settings.Items = new SearchPanelItemSetting[Items.Count]; for (int i = 0; i < Items.Count; i++) { SearchPanelItem item = Items[i] as SearchPanelItem; if (item != null) { SearchPanelItemSetting setting = new SearchPanelItemSetting(); setting.Name = item.Name; setting.IsActive = item.IsActive; setting.Sequence = i; settings.Items[i] = setting; } } }