public UserAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting) { Meeting = meeting; AnnotationsModel = sharedDataService.AnnotationsModel; SurfaceSize = new AnnotationSurfaceSize(); var activeToolObs = Meeting.WhenAnyValue(vm => vm.ActiveTool) .Where(t => t != null); var pageChangedObs = activeToolObs .Select(t => t.WhenAnyValue(v => v.CurrentPageNumber, p => new ToolIdAndPageNumber { ToolId = t.ToolId, PageNumber = p }) ) .Switch(); // Only listen to the most recent sequence of property changes (active tool) // Every time the tool changes, select the tool id and current page number var toolChangedObs = activeToolObs .Select(t => new ToolIdAndPageNumber { ToolId = t.ToolId, PageNumber = t.CurrentPageNumber }); // Merge them together - tool changes and current page of the tool _collectionRefreshSub = toolChangedObs .Merge(pageChangedObs) .Subscribe(t => this.RaisePropertyChanged("Annotations")); // whenever the suface size's width or height changes, re-bind the annotations // on the agent's side, this will send stuff over the wire. need to figure out how to solve this. _sizeChangedSub = this.SurfaceSize .WhenAnyValue(p => p.Width, p => p.Height, (w, h) => true) .Subscribe(p => this.RaisePropertyChanged("Annotations")); }
private AnnotationViewModel(Annotation annotation, AnnotationSurfaceSize surfaceSize) { Annotation = annotation; _surfaceSize = surfaceSize; }
public static AnnotationViewModel Create(Annotation annotation, AnnotationSurfaceSize surfaceSize) { return(new AnnotationViewModel(annotation, surfaceSize)); }