WindturbineIcon.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. using WisdomClient.data;
  11. namespace IntelligentControlForsx.MyControls
  12. {
  13. public partial class WindturbineIcon : UserControl
  14. {
  15. private string windturbineId;
  16. public WindturbineIcon()
  17. {
  18. InitializeComponent();
  19. SetStyle(ControlStyles.UserPaint, true);
  20. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  21. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲  
  22. this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  23. this.UpdateStyles();
  24. wpfWindturbine1.MyClick += WPF_Click;
  25. }
  26. [Browsable(true), Category("DATA")]
  27. public string WindturbineId
  28. {
  29. get
  30. {
  31. return windturbineId;
  32. }
  33. set
  34. {
  35. windturbineId = value;
  36. UpdateLblTitle(windturbineId);
  37. }
  38. }
  39. private void UpdateLblTitle(String windturbineId)
  40. {
  41. if (String.IsNullOrWhiteSpace(windturbineId))
  42. return;
  43. String[] arr = windturbineId.Split('_');
  44. if (arr != null && arr.Length == 2)
  45. {
  46. int num = 0;
  47. if (int.TryParse(arr[1], out num))
  48. {
  49. label1.Text = num.ToString();
  50. }
  51. }
  52. }
  53. public int Status
  54. {
  55. get
  56. {
  57. return this.wpfWindturbine1.WState;
  58. }
  59. set
  60. {
  61. this.wpfWindturbine1.WState = value;
  62. }
  63. }
  64. public event EventHandler MyClick;
  65. void WPF_Click(object sender, EventArgs e)
  66. {
  67. MyClick(this, e);
  68. }
  69. }
  70. }