|
|
@@ -0,0 +1,106 @@
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Media;
|
|
|
+using System.Windows.Media.Media3D;
|
|
|
+
|
|
|
+namespace FurnaceNewWorld.Controls;
|
|
|
+
|
|
|
+/// <summary>
|
|
|
+/// Interaction logic for BuzzerLight.xaml
|
|
|
+/// </summary>
|
|
|
+public partial class BuzzerLight : UserControl
|
|
|
+{
|
|
|
+ public BuzzerLight()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ this.Red.Width = DisableWidth;
|
|
|
+ this.Yellow.Width = DisableWidth;
|
|
|
+ this.Green.Width = DisableWidth;
|
|
|
+ this.Blue.Width = DisableWidth;
|
|
|
+
|
|
|
+ this.Red.Height = DisableHeight;
|
|
|
+ this.Yellow.Height = DisableHeight;
|
|
|
+ this.Green.Height = DisableHeight;
|
|
|
+ this.Blue.Height = DisableHeight;
|
|
|
+
|
|
|
+ this.Red.Background = (SolidColorBrush)App.Current.FindResource("LightEmergencyColor");
|
|
|
+ this.Yellow.Background = (SolidColorBrush)App.Current.FindResource("LightWarningColor");
|
|
|
+ this.Green.Background = (SolidColorBrush)App.Current.FindResource("LightNormalColor");
|
|
|
+ this.Blue.Background = (SolidColorBrush)App.Current.FindResource("NiceLightBlue");
|
|
|
+ }
|
|
|
+
|
|
|
+ private const float DisableWidth = 40;
|
|
|
+ private const float DisableHeight = 14;
|
|
|
+
|
|
|
+ private const float EnableWidth = 48;
|
|
|
+ private const float EnableHeight = 20;
|
|
|
+
|
|
|
+ public BuzzerLightEnum LightType
|
|
|
+ {
|
|
|
+ get { return (BuzzerLightEnum)GetValue(LightTypeProperty); }
|
|
|
+ set { SetValue(LightTypeProperty, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static readonly DependencyProperty LightTypeProperty =
|
|
|
+ DependencyProperty.Register(nameof(LightType), typeof(BuzzerLightEnum), typeof(BuzzerLight), new PropertyMetadata(LightEnumChangedCallback));
|
|
|
+
|
|
|
+ private static void LightEnumChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (d is not BuzzerLight light)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (e.NewValue is not BuzzerLightEnum lightEnum)
|
|
|
+ return;
|
|
|
+
|
|
|
+ light.Red.Width = DisableWidth;
|
|
|
+ light.Yellow.Width = DisableWidth;
|
|
|
+ light.Green.Width = DisableWidth;
|
|
|
+ light.Blue.Width = DisableWidth;
|
|
|
+
|
|
|
+ light.Red.Height = DisableHeight;
|
|
|
+ light.Yellow.Height = DisableHeight;
|
|
|
+ light.Green.Height = DisableHeight;
|
|
|
+ light.Blue.Height = DisableHeight;
|
|
|
+
|
|
|
+ light.Red.Background = (SolidColorBrush)App.Current.FindResource("LightEmergencyColor");
|
|
|
+ light.Yellow.Background = (SolidColorBrush)App.Current.FindResource("LightWarningColor");
|
|
|
+ light.Green.Background = (SolidColorBrush)App.Current.FindResource("LightNormalColor");
|
|
|
+ light.Blue.Background = (SolidColorBrush)App.Current.FindResource("NiceLightBlue");
|
|
|
+
|
|
|
+ Border? border = lightEnum switch
|
|
|
+ {
|
|
|
+ BuzzerLightEnum.Red => light.Red,
|
|
|
+ BuzzerLightEnum.Yellow => light.Yellow,
|
|
|
+ BuzzerLightEnum.Green => light.Green,
|
|
|
+ BuzzerLightEnum.Blue => light.Blue,
|
|
|
+ _ => null
|
|
|
+ };
|
|
|
+
|
|
|
+ if (border is null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ border.Width=EnableWidth;
|
|
|
+ border.Height=EnableHeight;
|
|
|
+ border.IsEnabled = true;
|
|
|
+
|
|
|
+ border.Background = lightEnum switch
|
|
|
+ {
|
|
|
+ BuzzerLightEnum.Red => (SolidColorBrush)App.Current.FindResource("EmergencyColor"),
|
|
|
+ BuzzerLightEnum.Yellow => (SolidColorBrush)App.Current.FindResource("WarningColor"),
|
|
|
+ BuzzerLightEnum.Green => (SolidColorBrush)App.Current.FindResource("NormalColor"),
|
|
|
+ BuzzerLightEnum.Blue => (SolidColorBrush)App.Current.FindResource("NiceBlue"),
|
|
|
+ _ => null
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+public enum BuzzerLightEnum
|
|
|
+{
|
|
|
+ Undefined,
|
|
|
+ Red,
|
|
|
+ Yellow,
|
|
|
+ Green,
|
|
|
+ Blue,
|
|
|
+}
|