public DetectViewModel(IFaceServiceClient client, IDialogService dialogService)
        {
            var fileSelector  = new ObservableFileSelector();
            var imageSelector = new ImageSelector(fileSelector.SelectFilesCommand);

            detector = new Detector(client);


            SelectFilesCommand = fileSelector.SelectFilesCommand;

            var selectFilesObs = SelectFilesCommand.Publish();

            DetectCommand = ReactiveCommand.CreateFromTask(DetectFaces, imageSelector.Images.Any());

            imagesHelper = imageSelector.Images
                           .Select(list => list.Select(data => new DetectionViewModel(data.Image, data.Source)).ToList())
                           .ToProperty(this, model => model.Images);

            DetectCommand.Subscribe(detections => SetDetections(detections));
            DetectCommand.ThrownExceptions.Subscribe(async exception => await dialogService.ShowException(exception));

            loadingHelper = DetectCommand.IsExecuting.ToProperty(this, model => model.IsBusy);

            selectFilesObs.Connect();
        }
        public IdentifyViewModel(IFaceServiceClient client, IDialogService dialogService)
        {
            this.client = client;
            var fileSelector  = new ObservableFileSelector();
            var imageSelector = new ImageSelector(fileSelector.SelectFilesCommand);

            detector = new Detector(client);

            SelectFilesCommand = fileSelector.SelectFilesCommand;

            var filesObs = SelectFilesCommand.Publish();

            IdentifyCommand = ReactiveCommand.CreateFromTask(IdentifyFaces, imageSelector.Images.Any());

            imagesObs = imageSelector.Images
                        .Select(list => list.Select(data => new IdentificationViewModel(data.Image, data.Source)).ToList())
                        .ToProperty(this, model => model.Identifications);

            IdentifyCommand.Subscribe(SetIdentifications);
            IdentifyCommand.ThrownExceptions.Subscribe(async exception => await dialogService.ShowException(exception));

            isBusyObs = IdentifyCommand.IsExecuting.ToProperty(this, model => model.IsBusy);

            filesObs.Connect();
        }
Beispiel #3
0
        public GroupViewModel(IFaceServiceClient client, IDialogService dialogService)
        {
            this.client = client;
            var fileSelector  = new ObservableFileSelector();
            var imageSelector = new ImageSelector(fileSelector.SelectFilesCommand);

            faceDetector = new Detector(client);

            SelectFilesCommand = fileSelector.SelectFilesCommand;

            var selectFilesObs = SelectFilesCommand.Publish();

            GroupCommand = ReactiveCommand.CreateFromTask(GroupImages, imageSelector.Images.Any());
            GroupCommand.ThrownExceptions.Subscribe(async exception => await dialogService.ShowException(exception));

            imagesHelper = imageSelector.Images.ToProperty(this, model => model.Images);
            groupsHelper = GroupCommand.ToProperty(this, model => model.Groups);

            loadingHelper = GroupCommand.IsExecuting.ToProperty(this, model => model.IsBusy);

            selectFilesObs.Connect();
        }