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")); }
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 ClientAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting) : base(sharedDataService, meeting) { // create the client annotations property, a mapped version of the agent's properties based on the screen sizes. _annotationsChangedSub = _clientAnnotations = AnnotationsModel .WhenAnyValue(v => v.Annotations, v => v.Select(p => CreateAnnotationViewModel(p))) .ToProperty(this, v => v.Annotations); }
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 LifetimeEconomicValueViewModel(ISharedDataService sharedData, IViewModelLocator locator) : base(new Guid("6D2F7E48-8A1E-475C-8297-811D83F46CBE")) { Name = "Lifetime Economic Value"; _person = sharedData.Person; AddToolPages( new Page1(_person, locator.Mode), new Page2(this, locator.Mode)); }
public AnotherSampleToolViewModel(ISharedDataService dataService) : base(new Guid("FC8C62F6-05D9-42FA-8FDA-1CC16D62769D")) { _person = dataService.Person; Name = "Another Sample Tool"; AddToolPages( new Page1(), new Page2(this)); }
public BasicInformationToolViewModel(ISharedDataService dataService, IViewModelLocator locator) : base(new Guid("74EF5D9B-E6D1-4218-8755-C8349157FAAE")) { _person = dataService.Person; Name = "Basic Information"; AddToolPages( new Page1(this, locator.Mode), new Page2(this, locator.Mode), new Page3(this, locator.Mode)); }
public SampleToolViewModel(ISharedDataService dataService) : base(new Guid("46A3FF71-ED2C-431F-86EF-A33B1D490E6D")) { _person = dataService.Person; Name = "Sample Tool"; AddToolPages( new Page1(), new Page2(this), new Page3()); }
public ClientMainService(IClientConnection connection, ISharedDataService data, ISettings settings, IPropertyChangedTransmitter transmitter, IPropertyChangedReceiver receiver, INavigationService navigation) { _connection = connection; _data = data; _settings = settings; _transmitter = transmitter; _receiver = receiver; _navigation = navigation; }
public MeetingViewModel( Meeting meeting, IList<IToolViewModel> tools, VideoConfViewModel videoConf, ISharedDataService sharedData, AppMode appMode) { AppMode = appMode; Id = meeting.Id; _identifierProperty = this.WhenAnyValue(v => v.Id, p => p.ToString().Substring(0, 6).ToUpper()).ToProperty(this, p => p.Identifier); StartTime = meeting.StartTime; Duration = meeting.Duration; Client = new ClientInfoViewModel(meeting.Client); PopulateMeetingStatus(meeting.Status); Tools = tools; VideoConf = videoConf; ActiveTool = tools.FirstOrDefault(); this.WhenAnyValue(p => p.StartTime, p => p.DateTime.ToString("dddd")).ToProperty(this, p => p.DayOfTheWeek, out _dayOfTheWeekProperty); this.WhenAnyValue(p => p.StartTime, p => p.DateTime.ToString("dd")).ToProperty(this, p => p.DayOfTheMonth, out _dayOfTheMonthProperty); this.WhenAnyValue(p => p.StartTime, p => p.DateTime.ToString("MMMM yyyy")).ToProperty(this, p => p.MonthAndYear, out _monthAndYearProperty); this.WhenAnyValue(p => p.StartTime, p => p.Duration, (s, d) => { var start = s.DateTime; var end = s.DateTime.Add(d); var startStr = start.ToString(start.Minute == 0 ? " h " : "h:mm").Trim(); var endStr = start.ToString(end.Minute == 0 ? "h tt" : "h:mm tt"); if (start.ToString("tt") != end.ToString("tt")) { startStr = startStr + " " + start.ToString("tt"); } return string.Format("{0} - {1}", startStr, endStr); }).ToProperty(this, p => p.TimeAndDuration, out _timeAndDurationProperty); }
public MeetingViewModel( Meeting meeting, IList <IToolViewModel> tools, VideoConfViewModel videoConf, ISharedDataService sharedData, AppMode appMode) { AppMode = appMode; Id = meeting.Id; _identifierProperty = this.WhenAnyValue(v => v.Id, p => p.ToString().Substring(0, 6).ToUpper()).ToProperty(this, p => p.Identifier); StartTime = meeting.StartTime; Duration = meeting.Duration; Client = new ClientInfoViewModel(meeting.Client); PopulateMeetingStatus(meeting.Status); Tools = tools; VideoConf = videoConf; ActiveTool = tools.FirstOrDefault(); this.WhenAnyValue(p => p.StartTime, p => p.DateTime.ToString("dddd")).ToProperty(this, p => p.DayOfTheWeek, out _dayOfTheWeekProperty); this.WhenAnyValue(p => p.StartTime, p => p.DateTime.ToString("dd")).ToProperty(this, p => p.DayOfTheMonth, out _dayOfTheMonthProperty); this.WhenAnyValue(p => p.StartTime, p => p.DateTime.ToString("MMMM yyyy")).ToProperty(this, p => p.MonthAndYear, out _monthAndYearProperty); this.WhenAnyValue(p => p.StartTime, p => p.Duration, (s, d) => { var start = s.DateTime; var end = s.DateTime.Add(d); var startStr = start.ToString(start.Minute == 0 ? " h " : "h:mm").Trim(); var endStr = start.ToString(end.Minute == 0 ? "h tt" : "h:mm tt"); if (start.ToString("tt") != end.ToString("tt")) { startStr = startStr + " " + start.ToString("tt"); } return(string.Format("{0} - {1}", startStr, endStr)); }).ToProperty(this, p => p.TimeAndDuration, out _timeAndDurationProperty); }
public AgentMeetingViewModel( IAgentConnection agentConnection, ISharedDataService sharedDataService, INavigationService navigation, IViewModelLocator locator, IPlatformServices platformServices) { _sharedDataService = sharedDataService; _agentConnection = agentConnection; NavigationPane = locator.NavigationPaneViewModel; var startcmd = new ReactiveCommand(this.WhenAnyValue(vm => vm.MeetingStarted, vm => vm.Meeting.VideoConf.VideoInitCompleted, vm => vm.Meeting, (started, video, mtg) => !started && mtg != null)); _startMeetingSub = startcmd.RegisterAsyncTask(async _ => { MeetingStarted = true; Meeting.VideoConf.Config = await _agentConnection.StartMeeting(Meeting.Id); }).Subscribe(); var endcmd = new ReactiveCommand(this.WhenAnyValue(vm => vm.MeetingStarted, vm => vm.Meeting.VideoConf.VideoInitCompleted, (meetingStarted, videoStarted) => meetingStarted && videoStarted)); _endMeetingSub = endcmd.RegisterAsyncAction(_ => navigation.BackCommand.Execute(null)).Subscribe(); StartMeetingCommand = startcmd; EndMeetingCommand = endcmd; _agentConnection.ClientInMeeting.ToProperty(this, t => t.IsClientInMeeting, out _isClientInMeeting); var savePdfCmd = new ReactiveCommand(this.WhenAnyValue(vm => vm.MeetingStarted, vm => vm.Meeting.VideoConf.VideoInitCompleted, (meetingStarted, videoStarted) => meetingStarted && videoStarted)); _pdfSub = savePdfCmd.RegisterAsyncTask(async _ => { await _agentConnection.GenerateIllustration(Meeting.Id, _sharedDataService.Person); }).Subscribe(); _pdfAvailableSub = _agentConnection.PdfAvailable.ObserveOn(RxApp.MainThreadScheduler).Subscribe(async p => { var result = await _agentConnection.GetIllustrationPdfAsync(p); await platformServices.SaveAndLaunchFile(new System.IO.MemoryStream(result), "pdf"); }); SavePdfCommand = savePdfCmd; _titleSub = this.WhenAnyValue( vm => vm.Meeting.Client, (client) => string.Format("Meeting with {0}", client.FullName) ) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => Title = t); MeetingStatus = GetMeetingStatusString(IsClientInMeeting, MeetingStarted); _meetingStatusSub = this.WhenAnyValue( vm => vm.MeetingStarted, vm => vm.IsClientInMeeting, (started, clientIn) => GetMeetingStatusString(clientIn, started)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => MeetingStatus = t); //_titleSub = this.WhenAnyValue( // vm => vm.Meeting.Client, // vm => vm.MeetingStarted, // vm => vm.IsClientInMeeting, // (client, started, clientIn) => // string.Format("Meeting with {0}. Started: {1} Client Joined: {2}", // client.FullName, started, clientIn) // ) // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(t => Title = t); // When the meeting's active tool changes, set the Tool and page number // into the shared state so it'll be propagated. // Get an observable for the currently set tool var activeToolObs = this.WhenAnyValue(vm => vm.Meeting.ActiveTool) .Where(t => t != null); // Every time the tool changes, watch the new tool's CurrentPageNumber // for changes. // // When we get a change, convert that into a ToolIdAndPageNumber, bringing in // the owning tool id. 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) .Log(this, "Current Page Changed", t => string.Format("Tool: {0}, Page: {1}", t.ToolId, t.PageNumber)); // 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 }) .Log(this, "Tool Changed", t => string.Format("Tool: {0}, Page: {1}", t.ToolId, t.PageNumber)); // Merge them together - tool changes and current page of the tool _meetingStateSub = toolChangedObs .Merge(pageChangedObs) .Subscribe(t => sharedDataService.MeetingState.State = t); }
public AgentMeetingViewModel( IAgentConnection agentConnection, ISharedDataService sharedDataService, INavigationService navigation, IViewModelLocator locator, IPlatformServices platformServices) { _sharedDataService = sharedDataService; _agentConnection = agentConnection; NavigationPane = locator.NavigationPaneViewModel; var startcmd = new ReactiveCommand(this.WhenAnyValue(vm => vm.MeetingStarted, vm => vm.Meeting.VideoConf.VideoInitCompleted, vm => vm.Meeting, (started, video, mtg) => !started && mtg != null)); _startMeetingSub = startcmd.RegisterAsyncTask(async _ => { MeetingStarted = true; Meeting.VideoConf.Config = await _agentConnection.StartMeeting(Meeting.Id); }).Subscribe(); var endcmd = new ReactiveCommand(this.WhenAnyValue(vm => vm.MeetingStarted, vm => vm.Meeting.VideoConf.VideoInitCompleted, (meetingStarted, videoStarted) => meetingStarted && videoStarted)); _endMeetingSub = endcmd.RegisterAsyncAction(_ => navigation.BackCommand.Execute(null)).Subscribe(); StartMeetingCommand = startcmd; EndMeetingCommand = endcmd; _agentConnection.ClientInMeeting.ToProperty(this, t => t.IsClientInMeeting, out _isClientInMeeting); var savePdfCmd = new ReactiveCommand(this.WhenAnyValue(vm => vm.MeetingStarted, vm => vm.Meeting.VideoConf.VideoInitCompleted, (meetingStarted, videoStarted) => meetingStarted && videoStarted)); _pdfSub = savePdfCmd.RegisterAsyncTask(async _ => { await _agentConnection.GenerateIllustration(Meeting.Id, _sharedDataService.Person); }).Subscribe(); _pdfAvailableSub = _agentConnection.PdfAvailable.ObserveOn(RxApp.MainThreadScheduler).Subscribe(async p => { var result = await _agentConnection.GetIllustrationPdfAsync(p); await platformServices.SaveAndLaunchFile(new System.IO.MemoryStream(result), "pdf"); }); SavePdfCommand = savePdfCmd; _titleSub = this.WhenAnyValue( vm => vm.Meeting.Client, (client) => string.Format("Meeting with {0}", client.FullName) ) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => Title = t); MeetingStatus = GetMeetingStatusString(IsClientInMeeting, MeetingStarted); _meetingStatusSub = this.WhenAnyValue( vm => vm.MeetingStarted, vm => vm.IsClientInMeeting, (started, clientIn) => GetMeetingStatusString(clientIn, started)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => MeetingStatus = t); //_titleSub = this.WhenAnyValue( // vm => vm.Meeting.Client, // vm => vm.MeetingStarted, // vm => vm.IsClientInMeeting, // (client, started, clientIn) => // string.Format("Meeting with {0}. Started: {1} Client Joined: {2}", // client.FullName, started, clientIn) // ) // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(t => Title = t); // When the meeting's active tool changes, set the Tool and page number // into the shared state so it'll be propagated. // Get an observable for the currently set tool var activeToolObs = this.WhenAnyValue(vm => vm.Meeting.ActiveTool) .Where(t => t != null); // Every time the tool changes, watch the new tool's CurrentPageNumber // for changes. // // When we get a change, convert that into a ToolIdAndPageNumber, bringing in // the owning tool id. 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) .Log(this, "Current Page Changed", t => string.Format("Tool: {0}, Page: {1}", t.ToolId, t.PageNumber)); // 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 }) .Log(this, "Tool Changed", t => string.Format("Tool: {0}, Page: {1}", t.ToolId, t.PageNumber)); // Merge them together - tool changes and current page of the tool _meetingStateSub = toolChangedObs .Merge(pageChangedObs) .Subscribe(t => sharedDataService.MeetingState.State = t); }
public MeetingViewModelFactory(IViewModelLocator locator, ISharedDataService sharedDataService) { _locator = locator; _sharedDataService = sharedDataService; }
public ClientMeetingViewModel( IClientConnection clientConnection, INavigationService navigation, ISharedDataService sharedDataService, IPlatformServices platformServices) { _sharedDataService = sharedDataService; _clientConnection = clientConnection; _navigation = navigation; // Combine the meeting details and IsActive to know when to go back // We should go back when we are the active screen (IsActive == true) // and the Meeting Details are cleared out - will be null. _navSub = _clientConnection.MeetingDetails .CombineLatest(this.WhenAnyValue(vm => vm.IsActive), (det, act) => new { Details = det, IsActive = act }) // combine into anon type .Where(t => t.IsActive && t.Details == null) .Subscribe(c => _navigation.BackCommand.Execute(null)); Title = "Welcome to White Label Insurance"; // Listen for state changes from the shared model // and return the non-null ids var stateObs = sharedDataService.MeetingState .WhenAnyValue(s => s.State) .Where(s => s.HasValue) .Select(s => s.Value); // de-Nullable<T> the value since we're not null // Get the latest non-null meeting var meetingObs = this.ObservableForProperty(vm => vm.Meeting, m => m) .Where(v => v != null); // Get the latest MeetingState and combine it with the current Meeting meetingObs .CombineLatest(stateObs, Tuple.Create) // store the latest in a tuple .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => { // for clarity, extract the tuple var state = t.Item2; var meeting = t.Item1; // Fet the specififed tool instance by id var activeTool = meeting.Tools.First(tool => tool.ToolId == state.ToolId); // Navigate to the current page within the tool activeTool.GoToPage(state.PageNumber); // Finally, set the tool to be the active one for the meeting meeting.ActiveTool = activeTool; } ); var leaveMeetingCommand = new ReactiveCommand(); leaveMeetingCommand.Subscribe(_ => _navigation.BackCommand.Execute(null)); LeaveMeetingCommand = leaveMeetingCommand; _pdfAvailableSub = _clientConnection.PdfAvailable.ObserveOn(RxApp.MainThreadScheduler).Subscribe(async p => { var result = await _clientConnection.GetIllustrationPdfAsync(p); await platformServices.SaveAndLaunchFile(new System.IO.MemoryStream(result), "pdf"); }); }