|
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace BPASmartClient.CustomResource.UserControls
- {
- /// <summary>
- /// FluorescentLamp.xaml 的交互逻辑
- /// </summary>
- public partial class FluorescentLamp : UserControl
- {
- public FluorescentLamp()
- {
- InitializeComponent();
- this.Loaded += (e, s) => { Refresh(); };
- }
-
- private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- (d as FluorescentLamp)?.Refresh();
- }
-
- private void ColorCalc(Color color1, Color color2)
- {
- GradientStopCollection gradientStop = new GradientStopCollection();
- gradientStop.Add(new GradientStop(color1, 0));
- gradientStop.Add(new GradientStop(Color.FromRgb(25, 23, 23), 1));
- gradientStop.Add(new GradientStop(color2, 0.639));
- gradientStop.Add(new GradientStop(color1, 0.358));
- this.ell1.Fill = new RadialGradientBrush(gradientStop);
- this.ell2.Fill = new SolidColorBrush(Color.FromArgb(170, color1.R, color1.G, color1.B));
-
- //gradientStop.Add(new GradientStop(Color.FromRgb(255, 224, 151), 0));
- //gradientStop.Add(new GradientStop(Color.FromRgb(25, 23, 23), 1));
- //gradientStop.Add(new GradientStop(Color.FromRgb(143, 104, 0), 0.639));
- //gradientStop.Add(new GradientStop(Color.FromRgb(255, 224, 151), 0.358));
- //this.ell1.Fill = new RadialGradientBrush(gradientStop);
- //this.ell2.Fill = new SolidColorBrush(Color.FromRgb(255, 224, 151));
- }
-
- private void Refresh()
- {
- switch (Status)
- {
- case FluorescentColor.Green:
- ColorCalc(Color.FromRgb(186, 255, 187), Color.FromRgb(31, 183, 0));
- break;
- case FluorescentColor.Yellow:
- ColorCalc(Color.FromRgb(255, 224, 151), Color.FromRgb(143, 104, 0));
- break;
- case FluorescentColor.Red:
- ColorCalc(Color.FromRgb(255, 163, 170), Color.FromRgb(188, 0, 0));
- break;
- case FluorescentColor.Blue:
- ColorCalc(Color.FromRgb(0, 121, 255), Color.FromRgb(0, 57, 119));
- break;
- case FluorescentColor.Gray:
- ColorCalc(Color.FromRgb(154, 152, 152), Color.FromRgb(91, 89, 89));
- break;
- case FluorescentColor.Aqua:
- ColorCalc(Color.FromRgb(186, 255, 251), Color.FromRgb(0, 172, 183));
- break;
- default:
- break;
- }
- }
-
-
- public FluorescentColor Status
- {
- get { return (FluorescentColor)GetValue(StatusProperty); }
- set { SetValue(StatusProperty, value); }
- }
- public static readonly DependencyProperty StatusProperty =
- DependencyProperty.Register("Status", typeof(FluorescentColor), typeof(FluorescentLamp),
- new PropertyMetadata(FluorescentColor.Gray, new PropertyChangedCallback(OnPropertyChanged)));
-
-
-
- }
-
- public enum FluorescentColor
- {
- Green,
- Yellow,
- Red,
- Blue,
- Gray,
- Aqua
- }
- }
|