PoemPhotoShareView.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 PoemPhotoShareView : BaseWindow
  9. {
  10. private UI_PoemPhotoShareUI _ui;
  11. private List<PoemPhotoData> _photoInfos;
  12. private int _curIndex = 0;
  13. private int _sourceType = 0;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_PoemPhotoShareUI.PACKAGE_NAME;
  27. _ui = UI_PoemPhotoShareUI.Create();
  28. this.viewCom = _ui.target;
  29. isfullScreen = true;
  30. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  31. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  32. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  33. _ui.m_btnShare.onClick.Add(OnBtnShareClick);
  34. }
  35. protected override void AddEventListener()
  36. {
  37. base.AddEventListener();
  38. }
  39. protected override void OnShown()
  40. {
  41. base.OnShown();
  42. _curIndex = (int)(this.viewData as object[])[0];
  43. _sourceType = (int)(this.viewData as object[])[1];
  44. if (_sourceType == (int)PictureSourceType.PersonalAlbum)
  45. {
  46. _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
  47. }
  48. else
  49. {
  50. _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;
  51. }
  52. _ui.m_loaBg.texture = PoemPhotoDataManager.Instance.BytesToTexture2D(_photoInfos[_curIndex].Bytes);
  53. }
  54. protected override void OnHide()
  55. {
  56. base.OnHide();
  57. }
  58. protected override void RemoveEventListener()
  59. {
  60. base.RemoveEventListener();
  61. }
  62. private void OnBtnBackClick()
  63. {
  64. ViewManager.GoBackFrom(typeof(PoemPhotoShareView).FullName);
  65. }
  66. private void OnBtnSaveClick()
  67. {
  68. byte[] bytes = _photoInfos[_curIndex].Bytes;
  69. string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
  70. PhotographDataManager.Instance.SavePicturoToLocal(bytes, fileName);
  71. }
  72. private void OnBtnShareClick()
  73. {
  74. }
  75. }
  76. }