GongChengLieBiaoItem.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class GongChengLieBiaoItem : MonoBehaviour
  7. {
  8. public GongChengLieBiaoData _currentData;
  9. private Text _indexText;
  10. private Text _nameText;
  11. private Text _stateText;
  12. private Button _button;
  13. private Image _highLightImg;
  14. public void Init()
  15. {
  16. _indexText = this.transform.Find("index").GetComponent<Text>();
  17. _nameText = this.transform.Find("type").GetComponent<Text>();
  18. _stateText = this.transform.Find("state").GetComponent<Text>();
  19. _highLightImg = this.transform.Find("highLight").GetComponent<Image>();
  20. _button = this.GetComponent<Button>();
  21. _button.onClick.AddListener(ItemClick);
  22. }
  23. public void ItemClick()
  24. {
  25. switch (_currentData.type)
  26. {
  27. case GongChengType.shuiWei:
  28. case GongChengType.shuiYa:
  29. case GongChengType.weiYi:
  30. // if (GCJKLayer._Instance.currentSelectItem != null)
  31. // {
  32. // GCJKLayer._Instance.currentSelectItem.SetHighLight(false);
  33. // }
  34. // GCJKLayer._Instance.currentSelectItem = this;
  35. //SetHighLight(true);
  36. GCJKLayer._Instance.OpenDeviceTrendPanel(_currentData.name,_currentData.type,_currentData.gid,_currentData.sid);
  37. break;
  38. }
  39. }
  40. private void OnDestroy()
  41. {
  42. // if (GCJKLayer._Instance.currentSelectItem != null && GCJKLayer._Instance.currentSelectItem == this)
  43. // {
  44. // GCJKLayer._Instance.currentSelectItem = null;
  45. // }
  46. }
  47. public void SetHighLight(bool show)
  48. {
  49. _highLightImg.enabled = show;
  50. }
  51. public void SetData(GongChengLieBiaoData data)
  52. {
  53. _currentData = data;
  54. _indexText.text = $"{_currentData.index:00}";
  55. _nameText.text = $"{_currentData.name}";
  56. switch (_currentData.state)
  57. {
  58. case GongChengState.normal:
  59. _stateText.text = $"<color=#15DCFC>正常</color>";
  60. break;
  61. case GongChengState.runing:
  62. _stateText.text = $"<color=#15DCFC>运行</color>";
  63. break;
  64. case GongChengState.fix:
  65. _stateText.text = $"<color=#FFBC1D>养护</color>";
  66. break;
  67. case GongChengState.warning:
  68. _stateText.text = $"<color=#EF491C>告警</color>";
  69. break;
  70. }
  71. }
  72. }