public void CutEntity(DiskEntity selectedEntity) { if (selectedEntity.GetType().Equals(typeof(File))) { _copiedOrCutedEntity = selectedEntity; } }
private DiskEntity DetermineIcon(DiskEntity entity) { if (entity.GetType().Equals(typeof(Folder))) { entity.Icon = new BitmapImage(new Uri("/Resources/Images/folder.png", UriKind.Relative)); } else { if (((File)entity).ContentType.StartsWith("application")) { entity.Icon = new BitmapImage(new Uri("/Resources/Images/applicationFile.png", UriKind.Relative)); } else if (((File)entity).ContentType.StartsWith("audio")) { entity.Icon = new BitmapImage(new Uri("/Resources/Images/audioFile.png", UriKind.Relative)); } else if (((File)entity).ContentType.StartsWith("image")) { entity.Icon = new BitmapImage(new Uri("/Resources/Images/imageFile.png", UriKind.Relative)); } else if (((File)entity).ContentType.StartsWith("text")) { entity.Icon = new BitmapImage(new Uri("/Resources/Images/textFile.png", UriKind.Relative)); } else if (((File)entity).ContentType.StartsWith("video")) { entity.Icon = new BitmapImage(new Uri("/Resources/Images/videoFile.png", UriKind.Relative)); } else { entity.Icon = new BitmapImage(new Uri("/Resources/Images/unknownFile.png", UriKind.Relative)); } } return(entity); }
public Uri GetAnonymousShareLink(DiskEntity selectedEntity) { if (selectedEntity.GetType().Equals(typeof(Folder))) { return(_folderApi.GetAnonymousShareLink(selectedEntity as Folder)); } else { return(_fileApi.GetAnonymousShareLink(selectedEntity as File)); } }
public void UpdateLocalEntity(DiskEntity entity) { if (entity.GetType().Equals(typeof(File))) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { string oldName = (entity as File).Path.Split('~').Last(); string finalDestination = (entity as File).Path.Replace(oldName, entity.Name); store.MoveFile((entity as File).Path, finalDestination); GetLocalEntities(); } } }
public async void ShareEntity(DiskEntity selectedEntity, string recipientEmail, string permissionString) { PermissionRight permission = (PermissionRight)Enum.Parse(typeof(PermissionRight), permissionString); if (selectedEntity.GetType().Equals(typeof(Folder))) { var result = await _folderApi.ShareFolder(selectedEntity as Folder, recipientEmail, permission, _user.Token); } else { var result = await _fileApi.ShareFile(selectedEntity as File, recipientEmail, permission, _user.Token); } }
public void DeleteLocalEntity(DiskEntity selectedLocalEntity) { if (selectedLocalEntity.GetType().Equals(typeof(File))) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { store.DeleteFile((selectedLocalEntity as File).Path); } } else { // No folders in local storage, I'm lazy } LocalEntities.Remove(selectedLocalEntity); }
public async void GetSharedUsers(DiskEntity selectedEntity) { if (selectedEntity.GetType().Equals(typeof(Folder))) { List <Permission> whyCantIDoItInOnlyOneStep = await _folderApi.GetSharedUsers(selectedEntity as Folder, _user.Token); Permissions.Clear(); foreach (var permission in whyCantIDoItInOnlyOneStep) { Permissions.Add(permission); } } else { List <Permission> whyCantIDoItInOnlyOneStep = await _fileApi.GetSharedUsers(selectedEntity as File, _user.Token); Permissions = new ObservableCollection <Permission>(whyCantIDoItInOnlyOneStep); } }
public async void UpdateEntity(DiskEntity entity) { DiskEntity newEntity = null; if (entity.GetType().Equals(typeof(Folder))) { newEntity = await _folderApi.UpdateFolder(entity as Folder, _user.Token); } else { newEntity = await _fileApi.UpdateFile(entity as File, _user.Token); } if (newEntity != null) { newEntity = DetermineIcon(newEntity); int index = Entities.IndexOf(Entities.Where(e => e.Id.Equals(entity.Id)).FirstOrDefault()); Entities.RemoveAt(index); Entities.Insert(index, newEntity); } }