/// <summary> /// Initializes a new instance of the UserProfileViewModel class. /// </summary> public UserProfileViewModel(IExtendedNavigationService navigationService, IScoreoidClient scoreoidClient, IPhotoChooserService photoChooserService, IAsyncStorageService asyncStorageService) { _navigationService = navigationService; _scoreoidClient = scoreoidClient; _photoChooserService = photoChooserService; _asyncStorageService = asyncStorageService; if (IsInDesignMode) { CurrentPlayer = new Player { Username = "******", BestScore = 336, Rank = 1 }; } TotalScore = NumberOfGames = 0; }
public ExplorerViewModel(IMainModel mainModel, IGoogleDriveService googleDriveService, INavigationService navigationService, IMessageBoxService messageBoxService, ISystemTrayService systemTrayService, IPhotoChooserService photoChooserService) { _mainModel = mainModel; _googleDriveService = googleDriveService; _navigationService = navigationService; _messageBoxService = messageBoxService; _systemTrayService = systemTrayService; _photoChooserService = photoChooserService; Files = new ObservableCollection<GoogleFileViewModel>(); PictureFiles = new ObservableCollection<GoogleFileViewModel>(); OpenFileCommand = new RelayCommand<GoogleFileViewModel>(file => { if (IsSelectionEnabled) { return; } OpenFile(file); }); ChangeStaredStatusCommand = new RelayCommand<GoogleFileViewModel>(file => { if (IsSelectionEnabled) { return; } ChangeStaredStatus(file); }); AddFileCommand = new RelayCommand(UploadFile); EnableSelectionCommand = new RelayCommand(() => { if (IsBusy) { return; } IsSelectionEnabled = true; }); RefreshFilesCommand = new RelayCommand(RefreshFiles); DeleteFilesCommand = new RelayCommand<IList>(files => { _messageBoxService.Show("You are about to delete the selected files. Do you wish to proceed?", "Delete files?", new[] { "delete", "cancel" }, button => { if (button != 0) return; var filesArray = files .Cast<GoogleFileViewModel>() .ToArray(); IsSelectionEnabled = false; DeleteFiles(filesArray); }); }); CreateNewFolderCommand = new RelayCommand(CreateNewFolder); RenameFileCommand = new RelayCommand<GoogleFileViewModel>(RenameFile); DeleteFileCommand = new RelayCommand<GoogleFileViewModel>(file => { _messageBoxService.Show(string.Format("You are about to delete '{0}'. Do you wish to proceed?", file.Title), "Delete file?", new[] { "delete", "cancel" }, button => { if (button != 0) return; DeleteFile(file); }); }); ShowAboutCommand = new RelayCommand(() => { _navigationService.NavigateTo("/View/AboutPage.xaml"); }); PageLoadedCommand = new RelayCommand(ExecuteInitialLoad); BackKeyPressCommand = new RelayCommand<CancelEventArgs>(e => { GoogleDriveFile item; if (PivotSelectedIndex == 1) { PivotSelectedIndex = 0; e.Cancel = true; } else if (IsSelectionEnabled) { IsSelectionEnabled = false; e.Cancel = true; } else if (_mainModel.TryPop(out item)) { AbortCurrentCall(); RaisePropertyChanged(() => CurrentPath); RefreshFiles(); e.Cancel = true; } else { AbortCurrentCall(true); Files.Clear(); PictureFiles.Clear(); } }); MessengerInstance.Register<RefreshFilesMessage>(this, message => { DispatcherHelper.RunAsync(RefreshFiles); }); }