public AddingProcessViewModel(IStore <ApplicationState> appStore, IPhotoProvider photoProvider) : base(appStore)
        {
            PhotoProvider = photoProvider ?? throw new ArgumentNullException("PhotoProvider is null in AddingProcessViewModel.");

            isNextButtonVisible  = false;
            isPhotoButtonVisible = true;

            placeTypePickerItemList = new List <string>
            {
                "Skatepark", "Skatespot", "DIY"
            };

            var userSubscription = appStore
                                   .DistinctUntilChanged(state => new { state.UserState.User })
                                   .SubscribeWithError(state =>
            {
                var user = state.UserState.User;
                CheckIfUserIsLoggedIn(user);
            }, error => { });

            if (appStore.GetState().PlacesData.ReportState.Value?.ReportType == ReportType.Update)
            {
                BindUpdatingPlaceToView();
            }
        }
Exemple #2
0
 public ProgressivePhotoSearch(IPhotoProvider provider, PhotoTag photoTag, GeoPoint location, DateTime startDate, DateTime endDate, UInt16 radius)
 {
     Provider  = provider;
     PhotoTag  = photoTag;
     Location  = location;
     StartDate = startDate;
     EndDate   = endDate;
     Radius    = radius;
 }
Exemple #3
0
 public DashboardController(
     ILogger <HomeController> logger,
     IPhotoProvider photoProvider,
     IWeatherProvider weatherProvider,
     IQuoteRepository quoteRepository,
     UserManager <ApplicationUser> userManager)
 {
     _logger          = logger;
     _photoProvider   = photoProvider;
     _weatherProvider = weatherProvider;
     _quoteRepository = quoteRepository;
     _userManager     = userManager;
 }
Exemple #4
0
        public ActiveRoutine(
            IServiceProvider serviceProvider,
            FileCachingService fileCache,
            CVAdsAPIClient cvAdsAPIClient,
            GeolocationDBAPIClient geoLocationAPIClient,
            LoginResponse smartDeviceState)
        {
            this.fileCache            = fileCache;
            this.cvAdsAPIClient       = cvAdsAPIClient;
            this.geoLocationAPIClient = geoLocationAPIClient;
            this.smartDeviceState     = smartDeviceState;

            photoProvider        = serviceProvider.GetService <IPhotoProvider>();
            imageDisplayer       = serviceProvider.GetService <IImageDisplayer>();
            configurationManager = serviceProvider.GetService <IConfigurationManager>();
        }
        /// <summary>
        /// Импорт фотографий
        /// </summary>
        /// <param name="provider">
        /// Провайдер фотографий
        /// </param>
        /// <param name="progress">
        /// Прогресс
        /// </param>
        /// <param name="token">
        /// Токен отмены
        /// </param>
        public void Import(IPhotoProvider provider, IProgress<ImportProgress> progress, ICancellationToken token)
        {
            this.logService.Info("Начало импорта фотографий");

            var settings = this.settingsService.GetSettings();

            this.logService.Trace("Путь до альбома: {0}", settings.AlbumeRootPath);
            this.logService.Trace("Формат пути по дате съемки: {0}", settings.PhotoTakenDateToPathFormat);
            this.logService.Trace("Формат пути без даты съемки: {0}", settings.EmptyDatePathFormat);

            var total = provider.GetPhotos().Count();
            var current = 0;
            foreach (var photo in provider.GetPhotos())
            {
                if (token != null && token.IsCancellationRequested)
                {
                    this.logService.Info("Импорт фотографий прерван");
                    break;
                }

                this.logService.Info("Импорт фотографии '{0}'", photo.FileName);

                var directory = this.GetDirectory(photo, settings);

                this.logService.Trace("Дата съемки: {0}", photo.DateTaken);
                this.logService.Trace("Папка импорта: '{0}'", directory);

                try
                {
                    var path = this.CopyPhotoIfNeeded(directory, photo);
                    OnImportProgress(progress, path, (++current * 100) / total);
                }
                catch (Exception e)
                {
                    this.logService.Error(e, "Ошибка импорта фотографии '{0}'", photo.FileName);
                }
            }

            this.logService.Info("Завершение импорта фотографий");
        }
Exemple #6
0
        public RegisterUserViewModel(
            IStore <ApplicationState> appStore,
            IRegisterUserActionCreator registerUserActionCreator,
            IPhotoProvider photoProvider
            ) : base(appStore)
        {
            CancelSubscriptions();

            this.photoProvider             = photoProvider ?? throw new ArgumentNullException(nameof(photoProvider));
            this.registerUserActionCreator = registerUserActionCreator ?? throw new ArgumentNullException(nameof(registerUserActionCreator));

            var registerSubscription = appStore
                                       .DistinctUntilChanged(state => new { state.UserState.Registration })
                                       .SubscribeWithError(state =>
            {
                var registrationState = state.UserState.Registration;

                if (registrationState.Status == Status.Setting)
                {
                    IsBusy = true;
                    IsErrorMessageVisible = false;
                }
                else if (registrationState.Status == Status.Success)
                {
                    IsBusy = false;
                    IsErrorMessageVisible = false;
                    App.Current.MainPage.Navigation.PopModalAsync();
                    App.Current.MainPage.DisplayAlert("Success", "Registration completed. You can login now.", "Ok");
                }
                else if (registrationState.Status == Status.Error)
                {
                    IsBusy                = false;
                    ErrorMessage          = registrationState.Error.Message;
                    IsErrorMessageVisible = true;
                }
            }, error => { appStore.Dispatch(new SetErrorAction(error, "Sub in RegisterUserViewModel.")); });

            subscriptions.Add(registerSubscription);
        }
Exemple #7
0
 public PhotoCollection(IPhotoProvider provider)
 {
     Provider = provider;
 }
Exemple #8
0
 public ScreenshotsPhotoCollection() : base(new ScreenshotsPhotoProvider())
 {
     Provider = new ScreenshotsPhotoProvider();
 }
        public void SetUp()
        {
            var albumeSettingsMock = new Mock<IAlbumeSettingsService>();
            albumeSettingsMock.Setup(p => p.GetSettings())
                .Returns(
                    new AlbumeSettings
                        {
                            AlbumeRootPath = AlbumeRootPath,
                            EmptyDatePathFormat = @"Unsorted\{0:dd.MM.yyyy}",
                            PhotoTakenDateToPathFormat = @"{0:yyyy}\{0:MM. MMMM}\{0:dd}",
                            DeviceId = @"{EEC5AD98-8080-425f-922A-DABF3DE3F69A}\0000"
                        });

            this.fileSystemMock = new Mock<IFileSystemService>();

            var photoProviderMock = new Mock<IPhotoProvider>();
            photoProviderMock.Setup(p => p.GetPhotos()).Returns(() => this.photos);
            this.photoProvider = photoProviderMock.Object;

            var dateMock = new Mock<IDateTimeService>();
            dateMock.Setup(p => p.GetCurrentDateTime()).Returns(new DateTime(2010, 7, 1));

            this.importService = new ImportService(albumeSettingsMock.Object, this.fileSystemMock.Object, new LogService(), dateMock.Object);
        }
Exemple #10
0
        public UserDetailsViewModel(IStore <ApplicationState> appStore, IPhotoProvider photoProvider,
                                    IUserService userService, IUpdateUserActionCreator updateUserActionCreator, URLRepository urlRepository) : base(appStore)
        {
            this.userService             = userService ?? throw new ArgumentNullException(nameof(photoProvider));
            this.photoProvider           = photoProvider ?? throw new ArgumentNullException(nameof(photoProvider));
            this.updateUserActionCreator = updateUserActionCreator ?? throw new ArgumentNullException(nameof(updateUserActionCreator));
            this.urlRepository           = urlRepository ?? throw new ArgumentNullException(nameof(urlRepository));

            var userDetailsSubscription = appStore
                                          .DistinctUntilChanged(state => new { state.UserState.User })
                                          .SubscribeWithError(state =>
            {
                var user = state.UserState.User;
                if (user == null)
                {
                    IsUserLoggedIn = false;
                    return;
                }

                IsUserLoggedIn = true;
                SetViewFields(user);
            },
                                                              error => { appStore.Dispatch(new SetErrorAction(error, "UserDetailsSubscription in UserDetailsViewModel.")); });

            subscriptions.Add(userDetailsSubscription);

            var updateUserSubscription = appStore
                                         .DistinctUntilChanged(state => new { state.UserState.Edit })
                                         .Subscribe(state =>
            {
                var edit = state.UserState.Edit;
                if (edit.Status == Core.Enums.Status.Setting)
                {
                    IsBusy = true;
                }
                if (edit.Status == Core.Enums.Status.Error)
                {
                    IsBusy    = false;
                    var error = edit.Error as EditUserException;
                    if (error != null)
                    {
                        IsEmailValid = false;
                        if (error.ServerErrorMessage != null)
                        {
                            EmailMessage = error.ServerErrorMessage;
                        }

                        if (error.EmailOccupidMessage != null)
                        {
                            EmailMessage = error.EmailOccupidMessage;
                        }
                    }
                }
                if (edit.Status == Core.Enums.Status.Success)
                {
                    App.Current.MainPage.Navigation.PopAsync();
                }
            });

            subscriptions.Add(updateUserSubscription);
        }
Exemple #11
0
 public PhotoController(IPhotoProcessor photoProcessor, IPhotoProvider photoProvider)
 {
     this.photoProvider  = photoProvider;
     this.photoProcessor = photoProcessor;
 }
Exemple #12
0
 private void Import(IPhotoProvider provider)
 {
     using (var dialog = new ProgressDialog(this.components)
                             {
                                 WindowTitle = "Импорт",
                                 Text = string.Format("Импорт фотографий из {0}", provider.Name),
                                 Description = "Инициализация",
                                 CancellationText = "Отмена импорта",
                                 MinimizeBox = false,
                                 ProgressBarStyle = ProgressBarStyle.ProgressBar,
                                 ShowTimeRemaining = true,
                                 UseCompactPathsForText = true,
                                 UseCompactPathsForDescription = true
                             })
     {
         dialog.DoWork += (sender, args) =>
             {
                 var progressDialog = (ProgressDialog)sender;
                 var progress = new Progress<ImportProgress>(p => progressDialog.ReportProgress(p.Percent, null, p.CurrentItem));
                 this.importService.Import(provider, progress, new CancellationTokenAdapter(() => progressDialog.CancellationPending));
             };
         dialog.ShowDialog(this);
     }
 }