PoemPhotoView.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Poem;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class PoemPhotoView : BaseWindow
  9. {
  10. private UI_PoemPhotoUI _ui;
  11. private List<int> _listDelete = new List<int>();
  12. private bool _deleting = false;//是否删除状态
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_PoemPhotoUI.PACKAGE_NAME;
  26. _ui = UI_PoemPhotoUI.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  30. _ui.m_list.SetVirtual();
  31. _ui.m_list.itemRenderer = RenderListItem;
  32. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  33. _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
  34. _ui.m_c1.onChanged.Add(OnBtnTabChange);
  35. }
  36. protected override void AddEventListener()
  37. {
  38. base.AddEventListener();
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. }
  44. protected override void OnHide()
  45. {
  46. base.OnHide();
  47. _listDelete.Clear();
  48. }
  49. protected override void RemoveEventListener()
  50. {
  51. base.RemoveEventListener();
  52. }
  53. private void OnBtnBackClick()
  54. {
  55. ViewManager.GoBackFrom(typeof(PoemPhotoView).FullName);
  56. }
  57. private void OnBtnDeleteClick()
  58. {
  59. }
  60. private void OnBtnTabChange()
  61. {
  62. _deleting = false;
  63. if (_ui.m_c1.selectedIndex == 0)
  64. {
  65. _ui.m_list.numItems = 0;
  66. }
  67. else
  68. {
  69. _ui.m_list.numItems = 0;
  70. }
  71. }
  72. private void RenderListItem(int index, GObject obj)
  73. {
  74. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  75. int id = 0;
  76. item.m_c1.selectedIndex = _deleting ? 1 : 0;
  77. item.m_c2.selectedIndex = !_deleting || _listDelete.IndexOf(id) < 0 ? 0 : 1;
  78. if (item.m_btnLock.data == null)
  79. {
  80. item.m_btnLock.onClick.Add(OnBtnLockClick);
  81. }
  82. item.m_btnLock.data = id;
  83. if (item.m_btnUp.data == null)
  84. {
  85. item.m_btnUp.onClick.Add(OnBtnUpClick);
  86. }
  87. item.m_btnUp.data = id;
  88. if (item.m_loaIcon.data == null)
  89. {
  90. item.m_loaIcon.onClick.Add(OnLoaIconClick);
  91. }
  92. item.m_loaIcon.data = id;
  93. item.target.data = index;
  94. UI_ListPhotoItem.ProxyEnd();
  95. }
  96. private void OnLoaIconClick(EventContext context)
  97. {
  98. GObject obj = context.sender as GObject;
  99. if (!_deleting)
  100. {
  101. int index = (int)obj.parent.data;
  102. ViewManager.Show<PoemPhotoPreView>(index, new object[] { typeof(PoemView).FullName, this.viewData });
  103. }
  104. else
  105. {
  106. int id = (int)obj.data;
  107. UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
  108. item.m_c2.selectedIndex = item.m_c2.selectedIndex == 0 ? 1 : 0;
  109. if (item.m_c2.selectedIndex == 1)
  110. {
  111. _listDelete.Add(id);
  112. }
  113. else
  114. {
  115. _listDelete.Remove(id);
  116. }
  117. UI_ListPhotoItem.ProxyEnd();
  118. }
  119. }
  120. private void OnBtnLockClick(EventContext context)
  121. {
  122. GObject item = context.sender as GObject;
  123. }
  124. private void OnBtnUpClick(EventContext context)
  125. {
  126. GObject item = context.sender as GObject;
  127. }
  128. }
  129. }