public HomePageViewModel(IPageDialogService pageDialogService, IMonkeyManager monkeyManager, INavigationService navigationService) { _pageDialogService = pageDialogService; _monkeyManager = monkeyManager; _navigationService = navigationService; var monkey = _monkeyManager.GetMonkey <List <GroupFinded> >(Constants.GROUPED_FINDED); if (monkey != null) { GroupFindeds = monkey.Item.ToObservableCollection(); } ViewPeopleCommand = new DelegateCommand <GroupFinded>(async(people) => { await CallGallery(people.PeopleName, people.PeoplePhotos); }); ViewFindedCommand = new DelegateCommand <GroupFinded>(async(people) => { await CallGallery(Constants.MAIN_TITLE, people.SearchedPeople); }); CallSearchedPageCommand = new DelegateCommand(async() => { await _navigationService.NavigateAsync(NavigationConstants.SearchPeople); }); DeleteCommand = new DelegateCommand <GroupFinded>((people) => { GroupFindeds.Remove(people); _monkeyManager.SaveMokey <List <GroupFinded> >(GroupFindeds.ToList(), Constants.GROUPED_FINDED); }); }
public GalleryPageViewModel(IPageDialogService pageDialogService, IMonkeyManager monkeyManager, INavigationService navigationService) { _pageDialogService = pageDialogService; _monkeyManager = monkeyManager; _navigationService = navigationService; var recognitionAppService = new RecognitionAppService(); ViewImageCommand = new DelegateCommand <PersonFace>((image) => { SelectedImage = image; ShowingDetail = false; }); DetailImageCommand = new DelegateCommand(async() => { if (SelectedImage == null) { await pageDialogService.DisplayAlertAsync("Alert", Constants.IMAGE_NOT_SELECTED, "Ok"); return; } var detail = await recognitionAppService.GetAttribtsFromImage(SelectedImage.ImageStream); DetailInfo = string.Join(", ", detail.Attributes.Select(e => e.GetInfo())); ValueSmile = detail.Attributes.Select(d => d.Emotion.Happiness).Average(); ShowingDetail = true; }); }