PoemPhotoShareView.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 PoemPhotoData _curPhotoData;
  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_graBg.onClick.Add(OnBtnBackClick);
  33. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  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. _curPhotoData = this.viewData as PoemPhotoData;
  44. _ui.m_c1.selectedIndex = _curPhotoData.SourceType;
  45. if (_curPhotoData.SourceType == (int)PictureSourceType.PersonalAlbum)
  46. {
  47. _ui.m_loaBg.texture = _curPhotoData.Ntexture;
  48. _ui.m_loaBg.SetSize(_ui.m_loaBg.width, _ui.m_loaBg.texture.height * _ui.m_loaBg.width / _ui.m_loaBg.texture.width);
  49. }
  50. else if (_curPhotoData.SourceType == (int)PictureSourceType.WanShuiQianShan)
  51. {
  52. // UI_ComPostcard item = UI_ComPostcard.Proxy(_ui.m_comPostcard);
  53. TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(_curPhotoData.TravelLocationId);
  54. _ui.m_comPostcard.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
  55. _ui.m_comPostcard.m_txtLocationName.text = loactionCfg.name;
  56. _ui.m_comPostcard.m_txtTime.text = TimeUtil.FormattingTime2(_curPhotoData.CreationTime);
  57. if (_curPhotoData.TravelSuitId > 0)
  58. {
  59. TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(_curPhotoData.TravelSuitId);
  60. _ui.m_comPostcard.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.reourcesArr[_curPhotoData.SuitResIndex]);
  61. _ui.m_comPostcard.m_comTravel.m_loaRole.SetXY(loactionCfg.positionsArr[_curPhotoData.PositionIndex][0], loactionCfg.positionsArr[_curPhotoData.PositionIndex][1]);
  62. }
  63. // UI_ComPostcard.ProxyEnd();
  64. }
  65. }
  66. protected override void OnHide()
  67. {
  68. base.OnHide();
  69. }
  70. protected override void RemoveEventListener()
  71. {
  72. base.RemoveEventListener();
  73. }
  74. private void OnBtnBackClick()
  75. {
  76. ViewManager.GoBackFrom(typeof(PoemPhotoShareView).FullName);
  77. }
  78. private void OnBtnSaveClick()
  79. {
  80. byte[] bytes = _curPhotoData.Bytes;
  81. string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
  82. PhotographDataManager.Instance.SavePicturoToLocal(bytes, fileName);
  83. }
  84. private void OnBtnShareClick()
  85. {
  86. }
  87. }
  88. }