public AltitudeAngelService( IMessagesService messagesService, IMissionPlanner missionPlanner, FlightDataService flightDataService, AltitudeAngelClient.Create aaClientFactory ) { _messagesService = messagesService; _missionPlanner = missionPlanner; _flightDataService = flightDataService; IsSignedIn = new ObservableProperty <bool>(false); WeatherReport = new ObservableProperty <WeatherInfo>(); SentTelemetry = new ObservableProperty <Unit>(); CreateClient(aaClientFactory); IObservable <Models.FlightData> armedAndSignedIn = _flightDataService .FlightArmed .Join(IsSignedIn, i => _flightDataService.FlightDisarmed, i => IsSignedIn.Where(s => !IsSignedIn), (flight, signedIn) => flight); IObservable <Models.FlightData> disarmedAndSignedIn = _flightDataService .FlightDisarmed .Join(IsSignedIn, i => _flightDataService.FlightArmed, i => IsSignedIn.Where(s => !IsSignedIn), (flight, signedIn) => flight); _disposer.Add( armedAndSignedIn.SubscribeAsync(ArmedAndSignedIn)); _disposer.Add( disarmedAndSignedIn.Subscribe(DisarmedAndSignedIn)); _disposer.Add(_missionPlanner.FlightDataMap .MapChanged .Throttle(TimeSpan.FromSeconds(1)) .SubscribeAsync(i => UpdateMapData(_missionPlanner.FlightDataMap))); TryConnect(); }
public void OnceOperator_UsingWhereOperator_CalledOnce() { int index = 0; ObservableProperty <int> property = new ObservableProperty <int>(); property.Where(i => i >= 2).Once().Subscribe(i => index = i); for (int i = 0; i < 5; i++) { property.Value = i; } Assert.AreEqual(2, index); }
public void WhereOperator_CallsCorrectly() { int index = 0; ObservableProperty <int> property = new ObservableProperty <int>(); property.Where(i => i == 10).Subscribe(i => index = i); for (int i = 0; i < 35; i++) { property.Value = i; } Assert.AreEqual(10, index); }
public LogsViewModel(ILogsViewService logsViewService, ILogFileImportService logFileImportService, Dispatcher dispatcher) { LogsViewService = logsViewService; _logEvents = CreateProperty <IList <LogEvent> >(nameof(LogEvents)); _selectedLogEvent = CreateProperty <LogEvent>(nameof(SelectedLogEvent)); logsViewService.LogEvents .Subscribe(value => { _logEvents.Value = value; // We need UI to refresh selection RaisePropertyChanged(nameof(SelectedLogEvent)); }); logsViewService .SelectedLogEventProperty .Subscribe(_selectedLogEvent); _selectedLogEvent .Where(logEvent => logEvent != null) .Subscribe(logEvent => logsViewService.SelectedLogEvent = logEvent); OpenFileCommand = Command.Create((string[] files) => { foreach (var file in files) { logFileImportService.Import(file); } }); SetScrollHandleCommand = Command.Create((IScrollInfo param) => { logsViewService.SetScrollhandle(param); }); }