public AnnotationToolViewModel(AgentAnnotationViewModel agentAnnotations) { AgentAnnotations = agentAnnotations; _isEditingSub = AgentAnnotations.WhenAnyValue(p => p.IsEditing, p => p).Where(p => !p).Subscribe(_ => ClearAllActive()); _activeToolSub = this.WhenAnyValue(p => p.RectActive, p => p.EllipseActive, p => p.FreeDrawActive, p => p.LineActive, (a, b, c, d) => { return(!a && !b && !c && !d); }).Where(p => p).Subscribe(_ => { Type = null; }); _undoCommand = new ReactiveCommand( agentAnnotations.WhenAny(p => p.ContainsAnnotationsForCurrentPage, p => p.Value).Select(p => p)); _undoCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); agentAnnotations.UndoAnnotation(); }); _rectCommand = new ReactiveCommand(); _rectCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); RectActive = true; Type = AnnotationType.Rectangle; }); _ellipseCommand = new ReactiveCommand(); _ellipseCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); EllipseActive = true; Type = AnnotationType.Ellipse; }); _lineCommand = new ReactiveCommand(); _lineCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); LineActive = true; Type = AnnotationType.Line; }); _freeDrawCommand = new ReactiveCommand(); _freeDrawCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); FreeDrawActive = true; Type = AnnotationType.AdHoc; }); }
private void PopulateCurrentMove(PointF pt, AgentAnnotationViewModel vm) { var point = ToAnnotationPoint(pt); var type = vm.AnnotationTools.Type.Value; currentBuilder = vm.CreateBuilder(type); currentBuilder.OnNextPoint(point); var annotation = vm.CreateAnnotationViewModel(currentBuilder.Annotation); vm.AddInProgressAnnotation(annotation); }
public AnnotationToolViewModel(AgentAnnotationViewModel agentAnnotations) { AgentAnnotations = agentAnnotations; _isEditingSub = AgentAnnotations.WhenAnyValue(p => p.IsEditing, p => p).Where(p => !p).Subscribe(_ => ClearAllActive()); _activeToolSub = this.WhenAnyValue(p => p.RectActive, p => p.EllipseActive, p => p.FreeDrawActive, p => p.LineActive, (a, b, c, d) => { return !a && !b && !c && !d; }).Where(p => p).Subscribe(_ => { Type = null; }); _undoCommand = new ReactiveCommand( agentAnnotations.WhenAny(p => p.ContainsAnnotationsForCurrentPage, p => p.Value).Select(p => p)); _undoCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); agentAnnotations.UndoAnnotation(); }); _rectCommand = new ReactiveCommand(); _rectCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); RectActive = true; Type = AnnotationType.Rectangle; }); _ellipseCommand = new ReactiveCommand(); _ellipseCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); EllipseActive = true; Type = AnnotationType.Ellipse; }); _lineCommand = new ReactiveCommand(); _lineCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); LineActive = true; Type = AnnotationType.Line; }); _freeDrawCommand = new ReactiveCommand(); _freeDrawCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => { ClearAllActive(); FreeDrawActive = true; Type = AnnotationType.AdHoc; }); }
private void WrapUpMove(AgentAnnotationViewModel vm) { SetNeedsDisplay(); vm.AnnotationTools.Type = null; vm.AnnotationTools.ClearAllActive(); vm.IsEditing = false; }