예제 #1
0
        /// <summary>
        /// The constructor.
        /// </summary>
        public PageHeaderViewModel(IPetCareService petCareService)
        {
            // Get current user as UI will bind directly to it.
            CurrentUser = AppEnvironment.Instance.CurrentUser;

            IsDummyServiceEnabled = petCareService is PetCareDummyService;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPageViewModel" /> class.
        /// </summary>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="authEnforcementHandler">The auth enforcement handler.</param>
        /// <param name="dialogService">The dialog service</param>
        public MainPageViewModel(INavigationFacade navigationFacade, IPetCareService petCareService,
                                 IAuthEnforcementHandler authEnforcementHandler, IDialogService dialogService)
        {
            _navigationFacade       = navigationFacade;
            _petCareService         = petCareService;
            _authEnforcementHandler = authEnforcementHandler;
            _dialogService          = dialogService;

            // Initialize collections.
            TopImages = new ObservableCollection <ReturnAccessory>();

            try
            {
                InitializeCategoryItems().Wait();
            }
            catch (AggregateException)
            {
                //throw;
            }

            // Initialize commands
            ShowAllCommand = new RelayCommand <ReturnAccessoryCombination>(OnShowAllSelected);
            //PhotoThumbnailSelectedCommand = new RelayCommand<PhotoThumbnail>(OnPhotoThumbnailSelected);
            PhotoThumbnailSelectedCommand = new RelayCommand <ReturnAccessory>(OnPhotoThumbnailSelected);
            //HeroImageSelectedCommand = new RelayCommand<Photo>(OnHeroImageSelected);
            GiveGoldCommand     = new RelayCommand <Photo>(OnGiveGold);
            UserSelectedCommand = new RelayCommand <User>(OnUserSelected);

            IsUserSignedIn = AppEnvironment.Instance.CurrentUser != null;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamViewModel" /> class.
        /// </summary>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="authEnforcementHandler">the authentication enforcement handler</param>
        /// <param name="dialogService">The dialog service.</param>
        public StreamViewModel(INavigationFacade navigationFacade, IPetCareService petCareService,
                               IAuthEnforcementHandler authEnforcementHandler, IDialogService dialogService)
        {
            _navigationFacade       = navigationFacade;
            _authEnforcementHandler = authEnforcementHandler;
            _dialogService          = dialogService;

            Photos = new IncrementalLoadingCollection <Photo>(s =>
            {
                Func <Task <PagedResponse <Photo> > > f = async() =>
                {
                    var stream = await petCareService.GetPhotosForCategoryId(Category.Id, s);

                    if (SelectedPhotoThumbnail != null &&
                        SelectedPhoto == null)
                    {
                        SelectedPhoto = stream.Items.FindPhotoForThumbnail(SelectedPhotoThumbnail);
                    }

                    return(stream);
                };

                return(f());
            }, async() => await _dialogService.ShowGenericServiceErrorNotification());

            // Initialize commands
            RefreshCommand       = new RelayCommand(OnRefresh);
            GotoCameraCommand    = new RelayCommand(OnGotoCamera);
            GiveGoldCommand      = new RelayCommand <Photo>(OnGiveGold);
            PhotoSelectedCommand = new RelayCommand <Photo>(OnPhotoSelected);
            ContributeCommand    = new RelayCommand(OnGotoCamera);
            UserSelectedCommand  = new RelayCommand <User>(OnUserSelected);
        }
예제 #4
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="dialogService">The dialog service.</param>
        public GiveGoldViewModel(IPetCareService petCareService, IDialogService dialogService)
        {
            _petCareService = petCareService;
            _dialogService  = dialogService;

            // Initialize commands
            CancelCommand = new RelayCommand(OnCancel);
        }
예제 #5
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="authenticationHandler">The authentication handler.</param>
        /// <param name="dialogService">The dialog service.</param>
        public DebugViewModel(IPetCareService petCareService, IAuthenticationHandler authenticationHandler,
                              IDialogService dialogService)
        {
            _petCareService        = petCareService;
            _authenticationHandler = authenticationHandler;
            _dialogService         = dialogService;

            ThrowExceptionCommand = new RelayCommand(OnThrowException);
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LeaderboardViewModel" /> class.
        /// </summary>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="dialogService">The dialog service.</param>
        public LeaderboardViewModel(INavigationFacade navigationFacade, IPetCareService petCareService,
                                    IDialogService dialogService)
        {
            _navigationFacade = navigationFacade;
            _petCareService   = petCareService;
            _dialogService    = dialogService;

            PhotoSelectedCommand    = new RelayCommand <Photo>(OnPhotoSelected);
            CategorySelectedCommand = new RelayCommand <Category>(OnCategorySelected);
            UserSelectedCommand     = new RelayCommand <User>(OnUserSelected);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsViewModel" /> class.
        /// </summary>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="dialogService">The dialog service.</param>
        public SettingsViewModel(IPetCareService petCareService, INavigationFacade navigationFacade,
                                 IDialogService dialogService)
        {
            _petCareService   = petCareService;
            _navigationFacade = navigationFacade;
            _dialogService    = dialogService;

            PrivacyCommand = new RelayCommand(OnShowPrivacyPolicy);
            AboutCommand   = new RelayCommand(OnShowAbout);
            SignOutCommand = new RelayCommand(OnSignOut);
        }
예제 #8
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="dialogService">The dialog service.</param>
        public CategoriesChooserViewModel(IPetCareService petCareService, IDialogService dialogService)
        {
            _petCareService      = petCareService;
            _dialogService       = dialogService;
            _categoryMatchFinder = new CategoryMatchFinder();

            // Initialize lists
            Categories = new List <Category>();

            // Initialize commands
            AddCategoryCommand = new RelayCommand(OnAddCategory, () => CanAddCategory);
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UploadViewModel" /> class.
        /// </summary>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="authEnforcementHandler">Authentication enforcement handler.</param>
        /// <param name="uploadFinishedHandler">The handler that is called when the upload finished.</param>
        /// <param name="dialogService">The dialog service.</param>
        public UploadViewModel(INavigationFacade navigationFacade, IPetCareService petCareService,
                               IAuthEnforcementHandler authEnforcementHandler, IUploadFinishedHandler uploadFinishedHandler,
                               IDialogService dialogService)
        {
            _navigationFacade       = navigationFacade;
            _petCareService         = petCareService;
            _authEnforcementHandler = authEnforcementHandler;
            _uploadFinishedHandler  = uploadFinishedHandler;
            _dialogService          = dialogService;

            // Initialize commands
            UploadCommand         = new RelayCommand(OnUpload, () => !IsBusy);
            ChooseCategoryCommand = new RelayCommand(OnChooseCategory, () => !IsBusy);
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhotoDetailsViewModel" /> class.
        /// </summary>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="authEnforcementHandler">The auth enforcement handler.</param>
        /// <param name="dialogService">The dialog service.</param>
        public PhotoDetailsViewModel(INavigationFacade navigationFacade, IPetCareService petCareService,
                                     IAuthEnforcementHandler authEnforcementHandler, IDialogService dialogService)
        {
            _navigationFacade       = navigationFacade;
            _petCareService         = petCareService;
            _authEnforcementHandler = authEnforcementHandler;
            _dialogService          = dialogService;

            // Initialize commands
            GotoCameraCommand       = new RelayCommand(OnGotoCamera);
            DeleteAnnotationCommand = new RelayCommand(OnDeleteAnnotation);
            GiveGoldCommand         = new RelayCommand(OnGiveGold);
            ReportPhotoCommand      = new RelayCommand <ReportReason>(OnReportPhoto);
            ReportAnnotationCommand = new RelayCommand(OnReportAnnotation);
            EditPhotoCommand        = new RelayCommand(OnEditPhoto);
            UserSelectedCommand     = new RelayCommand <User>(OnUserSelected);
        }
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="dialogService">The dialog service.</param>
        public CreateCategoryViewModel(IPetCareService petCareService, IDialogService dialogService)
        {
            _petCareService      = petCareService;
            _dialogService       = dialogService;
            _categoryMatchFinder = new CategoryMatchFinder();

            // Initialize lists
            _categories = new List <Category>();

            // We use the Category data model as it
            // handles input validation.
            Category = new Category();

            // We need to be always up-to-date regarding input validation,
            // lets register for model changes
            Category.PropertyChanged += Category_PropertyChanged;
        }
예제 #12
0
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="dialogService">The dialog service.</param>
        public AboutViewModel(IPetCareService petCareService, IDialogService dialogService)
        {
            _petCareService = petCareService;
            _dialogService  = dialogService;

            // Read package version
            AppVersion = Package.Current.Id.Version.ToFormattedString();

            // Read assembly version
            var assembly         = GetType().GetTypeInfo().Assembly;
            var versionAttribute =
                assembly.GetCustomAttribute <AssemblyFileVersionAttribute>();

            AssemblyVersion = versionAttribute?.Version;

            // Initialize commands
            CopyUserIdToClipboardCommand = new RelayCommand(OnCopyUserIdToClipboard,
                                                            () => AppEnvironment.Instance.CurrentUser != null);
        }
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProfileViewModel" /> class.
        /// </summary>
        /// <param name="navigationFacade">The navigation facade.</param>
        /// <param name="petCareService">The photo service.</param>
        /// <param name="dialogService">The dialog service.</param>
        public ProfileViewModel(INavigationFacade navigationFacade, IPetCareService petCareService,
                                IDialogService dialogService)
        {
            _navigationFacade = navigationFacade;
            _petCareService   = petCareService;
            _dialogService    = dialogService;

            Photos = new IncrementalLoadingCollection <Photo>(s =>
            {
                Func <Task <PagedResponse <Photo> > > f = async() =>
                {
                    if (IsShowingCurrentUser)
                    {
                        var stream = await petCareService.GetPhotosForCurrentUser(s);
                        return(stream);
                    }

                    return(await petCareService.GetPhotosForUser(User, s));
                };
                return(f());
            }, async() => await _dialogService.ShowGenericServiceErrorNotification(),
                                                              OnPhotosLoadingFinished);

            // Photos collection is being loaded asynchronously, so we need to
            // watch it to see if the user has any pictures uploaded already.
            Photos.CollectionChanged += PhotosCollectionChanged;

            // Initialize commands
            PhotoSelectedCommand   = new RelayCommand <Photo>(OnPhotoSelected);
            DeletePhotoCommand     = new RelayCommand <Photo>(OnDeletePhoto);
            SetProfilePhotoCommand = new RelayCommand <Photo>(OnSetProfilePhoto);

            // Before pictures are retrieved from the service,
            // we want to prevent an initial notification showing up
            // that the user has no pictures.
            ArePhotosEmpty = false;
        }
예제 #14
0
 public LicensingFacade(IPetCareService petCareService,
                        IAuthEnforcementHandler authEnforcementHandler)
 {
     _petCareService         = petCareService;
     _authEnforcementHandler = authEnforcementHandler;
 }