终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

96 lines
3.9 KiB

  1. using BPASmartClient.CustomResource.UserControls.Enum;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace BPASmartClient.CustomResource.UserControls
  19. {
  20. /// <summary>
  21. /// MotorTwo.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class MotorTwo : UserControl
  24. {
  25. public MotorTwo()
  26. {
  27. InitializeComponent();
  28. }
  29. public static DependencyProperty MotorColorsProperty = DependencyProperty.Register("MotorColors", typeof(MotorColor), typeof(MotorTwo), new FrameworkPropertyMetadata(MotorColor.Gray, FrameworkPropertyMetadataOptions.AffectsRender));
  30. public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(bool), typeof(MotorTwo), new PropertyMetadata(false));
  31. public static readonly DependencyProperty PLCAddressValueProperty = DependencyProperty.Register("PLCAddressValue", typeof(string), typeof(MotorTwo), new FrameworkPropertyMetadata("0"));
  32. private ImageSource imageSource;
  33. [Category("HMI")]
  34. public MotorColor MotorColors
  35. {
  36. get
  37. {
  38. return (MotorColor)GetValue(MotorColorsProperty);
  39. }
  40. set
  41. {
  42. SetValue(MotorColorsProperty, value);
  43. }
  44. }
  45. /// <summary>
  46. /// 重绘整个呈现的过程
  47. /// </summary>
  48. /// <param name="drawingContext"></param>
  49. protected override void OnRender(DrawingContext drawingContext)
  50. {
  51. double actualWidth = base.ActualWidth;
  52. double actualHeight = base.ActualHeight;
  53. switch (MotorColors)
  54. {
  55. case MotorColor.Gray:
  56. imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorGray.png"));
  57. drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
  58. break;
  59. case MotorColor.Green:
  60. imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorGreen.png"));
  61. drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
  62. break;
  63. case MotorColor.Red:
  64. imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorRed.png"));
  65. drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
  66. break;
  67. case MotorColor.Yellow:
  68. imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorYellow.png"));
  69. drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
  70. break;
  71. default:
  72. imageSource = new BitmapImage(new Uri("pack://application:,,,/BPASmartClient.CustomResource;component/Image/Motor/MotorGray.png"));
  73. drawingContext.DrawImage(imageSource, new Rect(0.0, 0.0, actualWidth, actualHeight));
  74. break;
  75. }
  76. }
  77. protected override void OnInitialized(EventArgs e)
  78. {
  79. base.OnInitialized(e);
  80. bool flag = LicenseManager.UsageMode == LicenseUsageMode.Designtime;
  81. bool flag2 = Process.GetCurrentProcess().ProcessName == "devenv";
  82. if (!(flag || flag2))
  83. {
  84. }
  85. }
  86. }
  87. }