WindturbineInfoControl.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace IntelligentControlForsx.MyControls.zm.map
  11. {
  12. public partial class WindturbineInfoControl : UserControl
  13. {
  14. public WindturbineInfoControl()
  15. {
  16. InitializeComponent();
  17. SetStyle(ControlStyles.UserPaint, true);
  18. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.  
  19. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲  
  20. this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  21. this.UpdateStyles();
  22. wpfWindturbine1.MyClick += WPF_Click;
  23. }
  24. private string windturbineName;
  25. public string WindturbineName
  26. {
  27. set
  28. {
  29. lblWindturbineId.Text = value;
  30. windturbineName = value;
  31. }
  32. get { return windturbineName; }
  33. }
  34. private string windturbineId = "";
  35. [Category("Xproperty"), Description("风机编号,格式符合将自动设置WindturbineName")]
  36. public string WindturbineId
  37. {
  38. get { return windturbineId; }
  39. set
  40. {
  41. windturbineId = value;
  42. if (windturbineId.IndexOf("_") > 0 && windturbineId.IndexOf("_") < windturbineId.Length)
  43. {
  44. string tmp = windturbineId.Substring(windturbineId.IndexOf("_") + 1);
  45. WindturbineName = tmp + "号";
  46. }
  47. }
  48. }
  49. private double power;
  50. public double Power
  51. {
  52. set
  53. {
  54. lblPower.Text = value.ToString("f2") + "kw";
  55. power = value;
  56. }
  57. get { return power; }
  58. }
  59. private double windSpeed;
  60. public double WindSpeed
  61. {
  62. set
  63. {
  64. lblWindSpeed.Text = value.ToString("f2") + "m/s";
  65. windSpeed = value;
  66. }
  67. get { return windSpeed; }
  68. }
  69. private int status;
  70. public int Status
  71. {
  72. set
  73. {
  74. status = value;
  75. wpfWindturbine1.WState = value;
  76. }
  77. get { return status; }
  78. }
  79. public void BindData(double power, double windSpeed, int status)
  80. {
  81. Power = power;
  82. WindSpeed = windSpeed;
  83. Status = status;
  84. }
  85. public event EventHandler MyClick;
  86. void WPF_Click(object sender, EventArgs e)
  87. {
  88. MyClick(this, e);
  89. }
  90. }
  91. }