PoemPhotoPreView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  28. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  29. _ui.m_list.SetVirtual();
  30. _ui.m_list.itemRenderer = RenderListItem;
  31. _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
  32. _ui.m_btnRight.onClick.Add(OnBtnRightClick);
  33. _ui.m_btnLock.onClick.Add(OnBtnLockClick);
  34. _ui.m_btnUp.onClick.Add(OnBtnUpClick);
  35. _ui.m_btnShare.onClick.Add(OnBtnShareClick);
  36. }
  37. protected override void AddEventListener()
  38. {
  39. base.AddEventListener();
  40. }
  41. protected override void OnShown()
  42. {
  43. base.OnShown();
  44. _curIndex = (int)this.viewData;
  45. _ui.m_list.numItems = 0;
  46. _ui.m_list.ScrollToView(_curIndex);
  47. }
  48. protected override void OnHide()
  49. {
  50. base.OnHide();
  51. }
  52. protected override void RemoveEventListener()
  53. {
  54. base.RemoveEventListener();
  55. }
  56. private void OnBtnBackClick()
  57. {
  58. ViewManager.GoBackFrom(typeof(PoemPhotoPreView).FullName);
  59. }
  60. private void UpdateView()
  61. {
  62. _ui.m_btnLeft.enabled = _curIndex > 0;
  63. _ui.m_btnRight.enabled = _curIndex < _ui.m_list.numItems - 1;
  64. }
  65. private void RenderListItem(int index, GObject obj)
  66. {
  67. UI_ListPhotoPreviewItem item = UI_ListPhotoPreviewItem.Proxy(obj);
  68. UI_ListPhotoPreviewItem.ProxyEnd();
  69. }
  70. private void OnBtnLeftClick()
  71. {
  72. _curIndex--;
  73. _curIndex = Mathf.Max(0, _curIndex);
  74. UpdateView();
  75. }
  76. private void OnBtnRightClick()
  77. {
  78. _curIndex++;
  79. _curIndex = Mathf.Min(_ui.m_list.numItems - 1, _curIndex);
  80. UpdateView();
  81. }
  82. private void OnBtnLockClick()
  83. {
  84. }
  85. private void OnBtnUpClick()
  86. {
  87. }
  88. private void OnBtnShareClick()
  89. {
  90. ViewManager.Show<PoemPhotoShareView>(_curIndex, new object[] { typeof(PoemPhotoPreView).FullName, _curIndex });
  91. }
  92. }
  93. }