Example #1
0
		public static void RegisterpCloudClient(pCloudClient client)
		{
			if (SimpleIoc.Default.IsRegistered<pCloudClient>())
			{
				SimpleIoc.Default.Unregister<pCloudClient>();
			}

			SimpleIoc.Default.Register<pCloudClient>(() => client);
			var localStorageService = SimpleIoc.Default.GetInstance<LocalStorageService>();
			localStorageService.Set(LocalStorageConstants.AuthTokenKey, client.AuthToken, LocalStorageConstants.LoginContainer);
		}
        public FolderViewModel(long folderId)
        {
            this.client = SimpleIoc.Default.GetInstance<pCloudClient>();

            this.Items = new SortedObservableCollection<StorageItem>();
            this.Items.SortDescriptors.Add(LambdaSortDescriptor.Create<StorageItem, bool>(item => item is Folder, ListSortDirection.Descending));
            this.Items.SortDescriptors.Add(new SortDescriptor("Name", ListSortDirection.Ascending));

            this.SelectedItems = new ObservableCollection<StorageItem>();
            this.SelectedItems.CollectionChanged += OnSelectedItemsCollectionChanged;

            this.NavigateToItemCommand = new RelayCommand<ItemClickEventArgs>(this.NavigateToItem);
            this.RefreshCommand = new RelayCommand(() => this.Refresh());
            this.UploadCommand = new RelayCommand(() => this.Upload());
            this.SelectAllCommand = new RelayCommand(this.SelectAll);
            this.ClearSelectionCommand = new RelayCommand(this.SelectedItems.Clear, this.SelectedItems.Any);
            this.DeleteItemsCommand = new RelayCommand(() => this.DeleteSelectedItems(), this.SelectedItems.Any);
            this.OpenWithCommand = new RelayCommand(() => this.OpenSelectedFile(), () => this.SelectedItems.Count == 1 && this.SelectedItems.Single() is File);
			this.CopyLinkCommand = new RelayCommand(() => this.CopyLink(), () => this.SelectedItems.Count == 1 && this.SelectedItems.Single() is File);

            this.Populate(folderId);
        }
 public pCloudContext(pCloudClient client)
 {
     Client = client;
 }