public ColorCategoryMapper(IOutlookSession outlookSession, IColorMappingsDataAccess colorMappingsDataAccess) { _colorMappingsDataAccess = colorMappingsDataAccess; _outlookSession = outlookSession ?? throw new ArgumentNullException(nameof(outlookSession)); var mappingEntries = colorMappingsDataAccess.Load(); _categoryByHtmlColor = mappingEntries.ToDictionary(e => e.HtmlColor, StringComparer.OrdinalIgnoreCase); _outlookColorByCategory = outlookSession.GetCategories() .Where(c => c.Color != OlCategoryColor.olCategoryColorNone) .ToDictionary(c => c.Name, c => c.Color, StringComparer.InvariantCultureIgnoreCase); }
public Options[] ShowWpfOptions(Guid?initialSelectedProfileId, GeneralOptions generalOptions, Options[] options, out OneTimeChangeCategoryTask[] oneTimeTasks) { string[] categories; using (var categoriesWrapper = GenericComObjectWrapper.Create(_session.Categories)) { categories = categoriesWrapper.Inner.ToSafeEnumerable <Category>().Select(c => c.Name).ToArray(); } var faultFinder = generalOptions.FixInvalidSettings ? new SettingsFaultFinder(EnumDisplayNameProvider.Instance) : NullSettingsFaultFinder.Instance; var optionTasks = new OptionTasks(_session, EnumDisplayNameProvider.Instance, faultFinder, _outlookSession); var viewOptions = new ViewOptions(generalOptions.EnableAdvancedView); OptionModelSessionData sessionData = new OptionModelSessionData(_outlookSession.GetCategories().ToDictionary(c => c.Name, _outlookSession.CategoryNameComparer)); var viewModel = new OptionsCollectionViewModel( generalOptions.ExpandAllSyncProfiles, GetProfileDataDirectory, _uiService, optionTasks, _profileTypeRegistry, (parent, type) => type.CreateModelFactory(parent, _outlookAccountPasswordProvider, categories, optionTasks, faultFinder, generalOptions, viewOptions, sessionData), viewOptions); _currentVisibleOptionsFormOrNull = viewModel; viewModel.SetOptionsCollection(options, initialSelectedProfileId); if (_uiService.ShowOptions(viewModel)) { oneTimeTasks = viewModel.GetOneTimeTasks(); return(viewModel.GetOptionsCollection()); } else { oneTimeTasks = null; return(null); } }
public Options[] ShowWpfOptions(Guid?initialSelectedProfileId, GeneralOptions generalOptions, Options[] options, out OneTimeChangeCategoryTask[] oneTimeTasks) { var optionTasks = new OptionTasks(_session, EnumDisplayNameProvider.Instance, _outlookSession); var viewOptions = new ViewOptions(generalOptions.EnableAdvancedView); var categories = _outlookSession .GetCategories() .GroupBy(c => c.Name, _outlookSession.CategoryNameComparer) .Select(g => g.First()) .ToArray(); var categoryNames = categories.Select(c => c.Name).ToArray(); OptionModelSessionData sessionData = new OptionModelSessionData(categories.ToDictionary(c => c.Name, _outlookSession.CategoryNameComparer)); var viewModel = new OptionsCollectionViewModel( generalOptions.ExpandAllSyncProfiles, GetProfileDataDirectory, _uiService, optionTasks, _profileTypeRegistry, (parent, type) => type.CreateModelFactory(parent, _outlookAccountPasswordProvider, categoryNames, optionTasks, generalOptions, viewOptions, sessionData), viewOptions); _currentVisibleOptionsFormOrNull = viewModel; viewModel.SetOptionsCollection(options, initialSelectedProfileId); if (_uiService.ShowOptions(viewModel)) { oneTimeTasks = viewModel.GetOneTimeTasks(); return(viewModel.GetOptionsCollection()); } else { oneTimeTasks = null; return(null); } }