using Avalonia.Media; using Avalonia.Threading; using AvaloniaApplication1.ViewModels; using DaireApplication.DataBase; using DaireApplication.Views; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace DaireApplication.Loops { public class InteractiveUILoop { public static async void Flashing(MainWindow _mainWindow) { while (true) { // Flashing Pre Heater on if (_mainWindow.isFlashPreHeating) { Dispatcher.UIThread.Post(() => { if (_mainWindow.PreHeatingBtn.Foreground == Brushes.Transparent) { _mainWindow.PreHeatingBtn.Foreground = Brushes.White; } else { _mainWindow.PreHeatingBtn.Foreground = Brushes.Transparent; } }); } // Flashing Pre Heater off if (!_mainWindow.isFlashPreHeating) { Dispatcher.UIThread.Post(() => { _mainWindow.PreHeatingBtn.Foreground = Brushes.White; }); } // Flashing Mixer on if (_mainWindow.startMixerMotorFlashing == 1) { Dispatcher.UIThread.Post(() => { if (_mainWindow.ContentArea.Content is Settings result) { var motorLable = result.MixerSP.Children[1] as Avalonia.Controls.Label; var motorRectangel = result.MixerSP.Children[2] as Avalonia.Controls.Shapes.Rectangle; if (motorLable.Foreground.ToString() == "#ff231f20") { motorLable.Foreground = Brushes.Transparent ; motorRectangel.Fill = Brushes.Transparent; } else { motorLable.Foreground = Brush.Parse("#ff231f20"); motorRectangel.Fill = Brush.Parse(_mainWindow.PassiveColor); } } }); } // Flashing Fountain on (only when not in pedal auto mode) if (_mainWindow.startFountainMotorFlashing == 1 && !_mainWindow.isPedalAutoMode) { Dispatcher.UIThread.Post(() => { if (_mainWindow.ContentArea.Content is Settings result) { var fountainLable = result.FountainSP.Children[1] as Avalonia.Controls.Label; var fountainRectangel = result.FountainSP.Children[2] as Avalonia.Controls.Shapes.Rectangle; if (fountainLable.Foreground.ToString() == "#ff231f20") { fountainLable.Foreground = Brushes.Transparent; fountainRectangel.Fill = Brushes.Transparent; } else { fountainLable.Foreground = Brush.Parse("#ff231f20"); fountainRectangel.Fill = Brush.Parse(_mainWindow.PassiveColor); } } }); } Thread.Sleep(250); } } } }