/// <summary> /// Gets the baby status of the monitor of the baby on the given index. /// </summary> /// <param name="index">The index in the baby monitoring list.</param> /// <returns>Returns the status of the baby. Returns <see cref="BabyStatus.None"/> if not found.</returns> public BabyStatus MonitorBaby(int index) { // Check if baby monitor is in range, return BabyStatus.None if not. if (index >= BabyMonitors.Count || index < 0) { return(BabyStatus.None); } // Get and return the baby's status LastBabyStatus = BabyMonitors[index].MonitorBaby(); return(LastBabyStatus); }
private void SetBabyStatus() { // Set cancelation token _ctsBabyStatus = new CancellationTokenSource(); // Update the baby's status while (!_ctsBabyStatus.IsCancellationRequested) { // Get status BabyStatus status = _caretaker.MonitorBaby(0); string message; switch (status) { case BabyStatus.Crying: message = "De baby huilt."; if (_newCry) { NotifyNewCry(); } _newCry = false; break; case BabyStatus.Quiet: message = "De baby is stil."; _newCry = true; break; default: message = "De status is onbekend."; break; } // Display status Dispatcher.Invoke(() => { lblWaiting.Content = $"Baby Status van '{_caretaker.GetBabyName(0).Split(new string[] { "-babyphone" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault()}': {message}"; }); Thread.Sleep(250); } }