PointValueDI.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 IntelligentControlForsx.Service.WindturbineInfo;
  11. namespace IntelligentControlForsx.MyControls.windturbine
  12. {
  13. public partial class PointValueDI : UserControl
  14. {
  15. public PointValueDI()
  16. {
  17. InitializeComponent();
  18. }
  19. private string nameString;
  20. public string NameString
  21. {
  22. set
  23. {
  24. nameString = value;
  25. lblName.Text = value;
  26. }
  27. get { return nameString; }
  28. }
  29. private string statusString;
  30. public string StatusString
  31. {
  32. set
  33. {
  34. statusString = value;
  35. int pointValue=0;
  36. if (Int32.TryParse(value, out pointValue))
  37. {
  38. if (pointValue == 0)
  39. lblStatus.BackColor = Color.Lime;
  40. else
  41. lblStatus.BackColor = Color.Red;
  42. }
  43. else
  44. {
  45. lblStatus.BackColor = Color.Red;
  46. }
  47. }
  48. get { return statusString; }
  49. }
  50. public void BindData(UniformCodeInfo data)
  51. {
  52. lblName.Text = data.Name;
  53. double pointValue = 0;
  54. if (data.Name == "" ||String.IsNullOrEmpty(data.PointValue))
  55. {
  56. lblStatus.BackColor = Color.FromArgb(10,25,47);
  57. }
  58. else
  59. {
  60. if (Double.TryParse(data.PointValue, out pointValue))
  61. {
  62. if (pointValue > 0)
  63. lblStatus.BackColor = Color.Red;
  64. else
  65. lblStatus.BackColor = Color.Lime;
  66. }
  67. else
  68. {
  69. lblStatus.BackColor = Color.Red;
  70. }
  71. }
  72. }
  73. }
  74. }