PoemPhotoShareView.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. _ui = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_PoemPhotoShareUI.PACKAGE_NAME;
  25. _ui = UI_PoemPhotoShareUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  29. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  30. _ui.m_graBg.onClick.Add(OnBtnBackClick);
  31. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  32. _ui.m_btnShare.onClick.Add(OnBtnShareClick);
  33. _ui.m_btnShare.visible = false;
  34. }
  35. protected override void AddEventListener()
  36. {
  37. base.AddEventListener();
  38. }
  39. protected override void OnShown()
  40. {
  41. base.OnShown();
  42. _curPhotoData = this.viewData as PoemPhotoData;
  43. _ui.m_c1.selectedIndex = _curPhotoData.SourceType;
  44. if (_curPhotoData.SourceType == (int)PictureSourceType.PersonalAlbum)
  45. {
  46. _ui.m_loaBg.texture = _curPhotoData.Ntexture;
  47. _ui.m_loaBg.SetSize(_ui.m_loaBg.width, _ui.m_loaBg.texture.height * _ui.m_loaBg.width / _ui.m_loaBg.texture.width);
  48. }
  49. else if (_curPhotoData.SourceType == (int)PictureSourceType.WanShuiQianShan)
  50. {
  51. // UI_ComPostcard item = UI_ComPostcard.Proxy(_ui.m_comPostcard);
  52. TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(_curPhotoData.TravelLocationId);
  53. _ui.m_comPostcard.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
  54. _ui.m_comPostcard.m_txtLocationName.text = loactionCfg.name;
  55. _ui.m_comPostcard.m_txtTime.text = TimeUtil.FormattingTime2(_curPhotoData.CreationTime);
  56. _ui.m_comPostcard.m_comTravel.m_loaRole.url = "";
  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. }