public PasteViewModel(ClipboardItem clipboardItem, IRoom room, IMessageBus bus) { if (clipboardItem.IsImage) { _imageSource = clipboardItem.LocalPath; } else { _imageSource = DependencyProperty.UnsetValue; } Caption = "Upload this " + (clipboardItem.IsImage ? "image" : "file") + "?"; LocalPath = clipboardItem.LocalPath; ShowLocalPath = !clipboardItem.IsImage; ContentType = clipboardItem.ContentType; Size = clipboardItem.Size; PasteCommand = new ReactiveCommand(); Subscribe(bus.Listen<FileUploadedMessage>().Where(msg => msg.CorrelationId == _currentCorrelation) .SubscribeUI(_ => IsFinished = true)); Subscribe(bus.Listen<FileUploadProgressChangedMessage>().Where(msg => msg.CorrelationId == _currentCorrelation) .SubscribeUI( msg => { ProgressCurrent = msg.Progress.Current; ProgressTotal = msg.Progress.Total; Debug.WriteLine("Current, total" + ProgressCurrent + ", " + ProgressTotal); })); Subscribe(bus.Listen<CorrelatedExceptionMessage>().Where(msg => msg.CorrelationId == _currentCorrelation) .SubscribeUI(msg => { IsErrored = true; IsUploading = false; LastException = msg.Exception; })); ProgressCurrent = 0; ProgressTotal = 100; Subscribe(bus.RegisterMessageSource( PasteCommand.Do(_ => { IsUploading = true; IsErrored = false; }) .Select(_ => new RequestUploadFileMessage(room.Id, clipboardItem.LocalPath, clipboardItem.ContentType)) .Do(msg => _currentCorrelation = msg.CorrelationId))); CancelCommand = new ReactiveCommand(); Subscribe(CancelCommand.Subscribe(_ => IsFinished = true)); }
public void AddPasteFile(IRoom room, ClipboardItem clipboardItem) { var view = _pasteViewFactory.Create(room, clipboardItem); var paragraph = new Paragraph(); paragraph.Inlines.Add(view.Element); Blocks.Add(paragraph); view.Closing.Subscribe(_ => { Blocks.Remove(paragraph); _pasteViewFactory.Release(view); }); }
public void AddPasteFile(IRoom room, ClipboardItem path) { throw new System.NotImplementedException(); }