public AgentAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting) : base(sharedDataService, meeting) { _annotations = new ReactiveList<AnnotationViewModel>(); var annotationsChangedObs = _annotations .WhenAnyObservable(p => p.Changed) .Select(p => AreThereAnnotationInTheCurrentPage()); var activeToolObs = Meeting.WhenAnyValue(vm => vm.ActiveTool).Where(t => t != null); var pageChangedObs = activeToolObs .Select(t => t.WhenAnyValue(v => v.CurrentPageNumber, p => AreThereAnnotationInTheCurrentPage())) .Switch(); // Only listen to the most recent sequence of property changes (active tool) var toolChangedObs = activeToolObs.Select(t => AreThereAnnotationInTheCurrentPage()); _containsAnnotationsForCurrentPage = toolChangedObs.Merge(pageChangedObs).Merge(annotationsChangedObs) .ToProperty(this, p => p.ContainsAnnotationsForCurrentPage); AnnotationTools = new AnnotationToolViewModel(this); // when the IsEditing flag changes to false, it means an edit has just completed and we can send // the updates annotations to the client _isEditingSub = this.WhenAnyValue(p => p.IsEditing) .Where(p => !p) .Subscribe(_ => UpdateAnnotationModelAnnotations()); }
public AgentAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting) : base(sharedDataService, meeting) { _annotations = new ReactiveList <AnnotationViewModel>(); var annotationsChangedObs = _annotations .WhenAnyObservable(p => p.Changed) .Select(p => AreThereAnnotationInTheCurrentPage()); var activeToolObs = Meeting.WhenAnyValue(vm => vm.ActiveTool).Where(t => t != null); var pageChangedObs = activeToolObs .Select(t => t.WhenAnyValue(v => v.CurrentPageNumber, p => AreThereAnnotationInTheCurrentPage())) .Switch(); // Only listen to the most recent sequence of property changes (active tool) var toolChangedObs = activeToolObs.Select(t => AreThereAnnotationInTheCurrentPage()); _containsAnnotationsForCurrentPage = toolChangedObs.Merge(pageChangedObs).Merge(annotationsChangedObs) .ToProperty(this, p => p.ContainsAnnotationsForCurrentPage); AnnotationTools = new AnnotationToolViewModel(this); // when the IsEditing flag changes to false, it means an edit has just completed and we can send // the updates annotations to the client _isEditingSub = this.WhenAnyValue(p => p.IsEditing) .Where(p => !p) .Subscribe(_ => UpdateAnnotationModelAnnotations()); }