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