/// <summary> /// Function to initialize the control based on the data context. /// </summary> /// <param name="dataContext">The current data context.</param> private void InitializeFromDataContext(IEditorSettingsVm dataContext) { if (dataContext == null) { ResetDataContext(); return; } RegisterPlugInSettingsPanels(dataContext); int selectedIndex = 0; for (int i = 0; i < dataContext.Categories.Count; ++i) { ISettingsCategoryViewModel category = dataContext.Categories[i]; string id = category.ID.ToString(); if ((!_panelLookup.ContainsKey(id)) || (_categoryLookup.ContainsKey(category.Name))) { continue; } if (dataContext.CurrentCategory == category) { selectedIndex = i; } ListCategories.Items.Add(category.Name); _categoryLookup[category.Name] = id; } ListCategories.SelectedIndex = selectedIndex; }
/// <summary> /// Function to retrieve the list of settings categories from loaded plug ins. /// </summary> /// <returns>The list of categories.</returns> private IEnumerable <ISettingsCategoryViewModel> GetPlugInSettingsCategories() { var result = new List <ISettingsCategoryViewModel>(); IEnumerable <EditorPlugIn> plugins = FileSystemProviders.Writers.Select(item => (EditorPlugIn)item.Value) .Concat(ContentPlugIns.PlugIns.Select(item => item.Value)) .Concat(ContentPlugIns.Importers.Select(item => item.Value)) .Concat(ToolPlugIns.PlugIns.Select(item => item.Value)); foreach (EditorPlugIn plugin in plugins) { ISettingsCategoryViewModel settings = plugin.GetPlugInSettings(); if (settings == null) { continue; } result.Add(settings); } return(result); }