Ejemplo n.º 1
0
        public MainViewModel(IBitmapService bitmapService, IFilePicker filePicker)
        {
            BrowseFile = ReactiveCommand
                         .CreateFromObservable(() => filePicker.Pick("Select an image", new[] { ".png", ".jpg" })
                                               .Where(file => file != null)
                                               .SelectMany(x => Observable.FromAsync(() => ToBytes(x))));
            Rotate = ReactiveCommand.CreateFromTask(() => bitmapService.Create(Source, Angle), BrowseFile.Any());

            source      = BrowseFile.ToProperty(this, x => x.Source);
            destination = Rotate.ToProperty(this, x => x.Destination);
            Angle       = 90f;

            isLoading = Rotate.IsExecuting.ToProperty(this, x => x.IsLoading);
        }
Ejemplo n.º 2
0
        public Section1ViewModel(IBitmapService bitmapService, IFilePicker filePicker, IDialogService dialogService)
        {
            BrowseFile = ReactiveCommand
                         .CreateFromObservable(() => Pick(filePicker));
            Rotate = ReactiveCommand.CreateFromTask(() => bitmapService.Create(Source, Angle), BrowseFile.Any());
            Rotate.ShowExceptions(dialogService);

            source      = BrowseFile.ToProperty(this, x => x.Source);
            destination = Rotate.ToProperty(this, x => x.Destination);
            Angle       = 90f;

            isLoading = Rotate.IsExecuting.ToProperty(this, x => x.IsLoading);

            this.WhenAnyValue(x => x.Url)
            .Subscribe(s => MessageBus.Current.SendMessage(new UrlMessage(s)));
        }