public MainWindow() { curentProfil = new Profil(); InitializeComponent(); this.DataContext = this; PaintingMachine = new PaintingMachine(defaultMachineIP, defaultMachinePort, defaultMachineConfiguration); PaintingMachine.PropertyChanged += PaintingMachine_PropertyChanged; }
private void PaintingMachine_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { PaintingMachine paintingMachine = sender as PaintingMachine; if (e.PropertyName == nameof(PaintingMachine.Connected)) { if (paintingMachine.Connected) { Dispatcher.Invoke(() => ImgConnexionStatus.Source = new BitmapImage(new Uri("Images/connectArrow.png", UriKind.Relative))); } else { Dispatcher.Invoke(() => ImgConnexionStatus.Source = new BitmapImage(new Uri("Images/disconnectArrow.png", UriKind.Relative))); } } }
private void PaintingMachine_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { PaintingMachine paintingMachine = sender as PaintingMachine; if (e.PropertyName == nameof(PaintingMachine.CurrentState)) { switch (paintingMachine.CurrentState) { case PaintingMachine.MachineStates.Stoped: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-stop.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.BucketComing: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-moving.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.BucketLockedAndWaiting: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-waiting.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.PaintAFilling: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-blue.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.PaintBFilling: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-green.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.PaintCFilling: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-yellow.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.PaintDFilling: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-orange.png", UriKind.Relative)); break; case PaintingMachine.MachineStates.WorkDone: MachineStatus.Source = new BitmapImage(new Uri("Images/conveyor-waiting.png", UriKind.Relative)); break; default: break; } } }