public GeneralLanguageViewModel(IAppConfigRepository appConfigRepository, GeneralLanguage item, IEnumerable<object> selectedLanguages) { _selectedLanguages = selectedLanguages.Select(x => new GeneralLanguage(x)).Where(x => x.LanguageCode != item.LanguageCode).ToList(); _innerItem = item; LanguageSetting = appConfigRepository.Settings.Where(s => s.Name.Contains("Lang")) .Expand(s => s.SettingValues) .FirstOrDefault(); if (LanguageSetting != null) { var view = CollectionViewSource.GetDefaultView(LanguageSetting.SettingValues); view.Filter = FilterItems; view.Refresh(); } InnerItem.PropertyChanged += InnerItem_PropertyChanged; }
private void RaiseLanguageAddInteractionRequest() { var item = new GeneralLanguage(); if (RaiseLanguageEditInteractionRequest(item, "Create Language".Localize())) { AddedItems.Add(item); InnerItems.Add(item); } }
private bool RaiseLanguageEditInteractionRequest(GeneralLanguage item, string title) { var result = false; var parameters = new[] { new KeyValuePair<string, object>("item", item), new KeyValuePair<string, object>("selectedLanguages",InnerItems) }; var itemVM = _vmFactory.GetViewModelInstance(parameters); var confirmation = new ConditionalConfirmation { Title = title, Content = itemVM }; LanguageConfirmRequest.Raise(confirmation, x => { result = x.Confirmed; }); return result; }
private void RaiseLanguageRemoveInteractionRequest(GeneralLanguage selectedItem) { var confirmation = new ConditionalConfirmation { Title = "Remove confirmation".Localize(null, LocalizationScope.DefaultCategory), Content = string.Format("Are you sure you want to remove Language '{0}'?".Localize(), selectedItem.LanguageCode) }; LanguageCommonConfirmRequest.Raise(confirmation, (x) => { if (x.Confirmed) { if (AddedItems.Contains(selectedItem)) AddedItems.Remove(selectedItem); else { if (UpdatedItems.Contains(selectedItem)) UpdatedItems.Remove(selectedItem); RemovedItems.Add(selectedItem); } InnerItems.Remove(selectedItem); } }); }
private void RaiseLanguageEditInteractionRequest(GeneralLanguage originalItem) { var item = new GeneralLanguage(originalItem); if (RaiseLanguageEditInteractionRequest(item, "Edit Language".Localize())) { // copy all values to original: OnUIThread(() => originalItem.InjectFrom<CloneInjection>(item)); if (!UpdatedItems.Contains(originalItem)) UpdatedItems.Add(originalItem); } }