//------------------------------------------------------------------------------// // Methods // //------------------------------------------------------------------------------// private void _SetColor(Color brushColor,FB12 Motor) { PolyConveyor.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { ColorAnimation animation; animation = new ColorAnimation(); SolidColorBrush oldBrush; try { oldBrush = PolyConveyor.Fill as SolidColorBrush; animation.From = oldBrush.Color; } catch { animation.From = Colors.White; } animation.To = brushColor; animation.Duration = new Duration(TimeSpan.FromSeconds(1)); if (PolyConveyor.Fill != null) { PolyConveyor.Fill.BeginAnimation(SolidColorBrush.ColorProperty, animation); } else { PolyConveyor.Fill = new SolidColorBrush(Colors.White); PolyConveyor.Fill.BeginAnimation(SolidColorBrush.ColorProperty, animation); } })); RectLeft.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { ColorAnimation animation; animation = new ColorAnimation(); SolidColorBrush oldBrush; try { oldBrush = PolyConveyor.Fill as SolidColorBrush; animation.From = oldBrush.Color; } catch { animation.From = Colors.White; } animation.To = brushColor; animation.Duration = new Duration(TimeSpan.FromSeconds(1)); if (RectLeft.Fill != null) { RectLeft.Fill.BeginAnimation(SolidColorBrush.ColorProperty, animation); } else { RectLeft.Fill = new SolidColorBrush(Colors.White); RectLeft.Fill.BeginAnimation(SolidColorBrush.ColorProperty, animation); } })); RectRight.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { ColorAnimation animation; animation = new ColorAnimation(); SolidColorBrush oldBrush; try { oldBrush = PolyConveyor.Fill as SolidColorBrush; animation.From = oldBrush.Color; } catch { animation.From = Colors.White; } animation.To = brushColor; animation.Duration = new Duration(TimeSpan.FromSeconds(1)); if (RectRight.Fill != null) { RectRight.Fill.BeginAnimation(SolidColorBrush.ColorProperty, animation); } else { RectRight.Fill = new SolidColorBrush(Colors.White); RectRight.Fill.BeginAnimation(SolidColorBrush.ColorProperty, animation); } })); }
public void SetMotorColor(int StateCode, int MotorNumber) { FB12 Motor = new FB12(); _SetColorMotor(Motor.SetColor(StateCode), MotorNumber); if (MotorNumber == 1) { StatusMotor1 = Motor.Status_Motor; FaultMotor1 = Motor.Fault_Motor; } else if (MotorNumber == 2) { StatusMotor2 = Motor.Status_Motor; FaultMotor2 = Motor.Fault_Motor; } else if (MotorNumber == 3) { StatusMotor3 = Motor.Status_Motor; FaultMotor3 = Motor.Fault_Motor; } else if (MotorNumber == 4) { StatusMotor4 = Motor.Status_Motor; FaultMotor4 = Motor.Fault_Motor; } }