protected NodeViewModel(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, FolderViewModel parent, ObservableCollection <IBaseNode> parentCollection = null, ObservableCollection <IBaseNode> childCollection = null) : base(megaSdk) { this.AccessLevel = new AccessLevelViewModel(); this.Parent = parent; this.ParentContainerType = parent != null ? Parent.Type : ContainerType.FileLink; this.ParentCollection = parentCollection; this.ChildCollection = childCollection; this.CopyOrMoveCommand = new RelayCommand(CopyOrMove); this.DownloadCommand = new RelayCommand(Download); this.GetLinkCommand = new RelayCommandAsync <bool, bool>(GetLinkAsync); this.ImportCommand = new RelayCommand(Import); this.PreviewCommand = new RelayCommand(Preview); this.RemoveCommand = new RelayCommand(Remove); this.RemoveLinkCommand = new RelayCommandAsync <bool>(RemoveLinkAsync); this.RenameCommand = new RelayCommand(Rename); this.RestoreCommand = new RelayCommand(Restore); this.OpenInformationPanelCommand = new RelayCommand(OpenInformationPanel); Update(megaNode); SetDefaultValues(); Transfer = new TransferObjectModel(megaSdk, this, MTransferType.TYPE_DOWNLOAD, LocalDownloadPath); OfflineTransfer = new TransferObjectModel(megaSdk, this, MTransferType.TYPE_DOWNLOAD, OfflinePath); }
private async void PhotoTaskOnCompleted(object sender, PhotoResult photoResult) { if (photoResult == null || photoResult.TaskResult != TaskResult.OK) { return; } try { string fileName = Path.GetFileName(photoResult.OriginalFileName); if (fileName != null) { string newFilePath = Path.Combine(AppService.GetUploadDirectoryPath(), fileName); using (var fs = new FileStream(newFilePath, FileMode.Create)) { await photoResult.ChosenPhoto.CopyToAsync(fs); await fs.FlushAsync(); fs.Close(); } var uploadTransfer = new TransferObjectModel(MegaSdk, CurrentRootNode, MTransferType.TYPE_UPLOAD, newFilePath); TransfersService.MegaTransfers.Add(uploadTransfer); uploadTransfer.StartTransfer(); } NoFolderUpAction = true; } catch (Exception) { new CustomMessageDialog( AppMessages.PhotoUploadError_Title, AppMessages.PhotoUploadError, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); } }