终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

104 righe
3.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace BPASmartClient.CustomResource.UserControls
  17. {
  18. /// <summary>
  19. /// FluorescentLamp.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class FluorescentLamp : UserControl
  22. {
  23. public FluorescentLamp()
  24. {
  25. InitializeComponent();
  26. this.Loaded += (e, s) => { Refresh(); };
  27. }
  28. private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  29. {
  30. (d as FluorescentLamp)?.Refresh();
  31. }
  32. private void ColorCalc(Color color1, Color color2)
  33. {
  34. GradientStopCollection gradientStop = new GradientStopCollection();
  35. gradientStop.Add(new GradientStop(color1, 0));
  36. gradientStop.Add(new GradientStop(Color.FromRgb(25, 23, 23), 1));
  37. gradientStop.Add(new GradientStop(color2, 0.639));
  38. gradientStop.Add(new GradientStop(color1, 0.358));
  39. this.ell1.Fill = new RadialGradientBrush(gradientStop);
  40. this.ell2.Fill = new SolidColorBrush(Color.FromArgb(170, color1.R, color1.G, color1.B));
  41. //gradientStop.Add(new GradientStop(Color.FromRgb(255, 224, 151), 0));
  42. //gradientStop.Add(new GradientStop(Color.FromRgb(25, 23, 23), 1));
  43. //gradientStop.Add(new GradientStop(Color.FromRgb(143, 104, 0), 0.639));
  44. //gradientStop.Add(new GradientStop(Color.FromRgb(255, 224, 151), 0.358));
  45. //this.ell1.Fill = new RadialGradientBrush(gradientStop);
  46. //this.ell2.Fill = new SolidColorBrush(Color.FromRgb(255, 224, 151));
  47. }
  48. private void Refresh()
  49. {
  50. switch (Status)
  51. {
  52. case FluorescentColor.Green:
  53. ColorCalc(Color.FromRgb(186, 255, 187), Color.FromRgb(31, 183, 0));
  54. break;
  55. case FluorescentColor.Yellow:
  56. ColorCalc(Color.FromRgb(255, 224, 151), Color.FromRgb(143, 104, 0));
  57. break;
  58. case FluorescentColor.Red:
  59. ColorCalc(Color.FromRgb(255, 163, 170), Color.FromRgb(188, 0, 0));
  60. break;
  61. case FluorescentColor.Blue:
  62. ColorCalc(Color.FromRgb(0, 121, 255), Color.FromRgb(0, 57, 119));
  63. break;
  64. case FluorescentColor.Gray:
  65. ColorCalc(Color.FromRgb(154, 152, 152), Color.FromRgb(91, 89, 89));
  66. break;
  67. case FluorescentColor.Aqua:
  68. ColorCalc(Color.FromRgb(186, 255, 251), Color.FromRgb(0, 172, 183));
  69. break;
  70. default:
  71. break;
  72. }
  73. }
  74. public FluorescentColor Status
  75. {
  76. get { return (FluorescentColor)GetValue(StatusProperty); }
  77. set { SetValue(StatusProperty, value); }
  78. }
  79. public static readonly DependencyProperty StatusProperty =
  80. DependencyProperty.Register("Status", typeof(FluorescentColor), typeof(FluorescentLamp),
  81. new PropertyMetadata(FluorescentColor.Gray, new PropertyChangedCallback(OnPropertyChanged)));
  82. }
  83. public enum FluorescentColor
  84. {
  85. Green,
  86. Yellow,
  87. Red,
  88. Blue,
  89. Gray,
  90. Aqua
  91. }
  92. }