PoemPhotoPreView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using ET;
  2. using FairyGUI;
  3. using UI.Poem;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class PoemPhotoPreView : BaseWindow
  8. {
  9. private UI_PoemPhotoPreviewUI _ui;
  10. private int _curIndex = 0;
  11. public override void Dispose()
  12. {
  13. if (_ui != null)
  14. {
  15. _ui.Dispose();
  16. _ui = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void OnInit()
  21. {
  22. base.OnInit();
  23. packageName = UI_PoemPhotoPreviewUI.PACKAGE_NAME;
  24. _ui = UI_PoemPhotoPreviewUI.Create();
  25. this.viewCom = _ui.target;
  26. isfullScreen = true;
  27. _ui.m_grhBg.onClick.Add(OnBtnBackClick);
  28. _ui.m_list.SetVirtual();
  29. _ui.m_list.itemRenderer = RenderListItem;
  30. _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
  31. _ui.m_btnRight.onClick.Add(OnBtnRightClick);
  32. _ui.m_btnLock.target.onClick.Add(OnBtnLockClick);
  33. _ui.m_btnUp.target.onClick.Add(OnBtnUpClick);
  34. _ui.m_btnShare.onClick.Add(OnBtnShareClick);
  35. }
  36. protected override void AddEventListener()
  37. {
  38. base.AddEventListener();
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _curIndex = (int)this.viewData;
  44. _ui.m_list.numItems = 0;
  45. _ui.m_list.ScrollToView(_curIndex);
  46. }
  47. protected override void OnHide()
  48. {
  49. base.OnHide();
  50. }
  51. protected override void RemoveEventListener()
  52. {
  53. base.RemoveEventListener();
  54. }
  55. private void OnBtnBackClick()
  56. {
  57. ViewManager.GoBackFrom(typeof(PoemPhotoPreView).FullName);
  58. }
  59. private void UpdateView()
  60. {
  61. _ui.m_btnLeft.enabled = _curIndex > 0;
  62. _ui.m_btnRight.enabled = _curIndex < _ui.m_list.numItems - 1;
  63. }
  64. private void RenderListItem(int index, GObject obj)
  65. {
  66. UI_ListPhotoPreviewItem item = UI_ListPhotoPreviewItem.Proxy(obj);
  67. UI_ListPhotoPreviewItem.ProxyEnd();
  68. }
  69. private void OnBtnLeftClick()
  70. {
  71. _curIndex--;
  72. _curIndex = Mathf.Max(0, _curIndex);
  73. UpdateView();
  74. }
  75. private void OnBtnRightClick()
  76. {
  77. _curIndex++;
  78. _curIndex = Mathf.Min(_ui.m_list.numItems - 1, _curIndex);
  79. UpdateView();
  80. }
  81. private void OnBtnLockClick()
  82. {
  83. }
  84. private void OnBtnUpClick()
  85. {
  86. }
  87. private void OnBtnShareClick()
  88. {
  89. ViewManager.Show<PoemPhotoShareView>(_curIndex, new object[] { typeof(PoemPhotoPreView).FullName, _curIndex });
  90. }
  91. }
  92. }