PoemPhotoShareView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System.Collections.Generic;
  2. using cfg.GfgCfg;
  3. using ET;
  4. using FairyGUI;
  5. using UI.Poem;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class PoemPhotoShareView : BaseWindow
  10. {
  11. private UI_PoemPhotoShareUI _ui;
  12. private PoemPhotoData _curPhotoData;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_PoemPhotoShareUI.PACKAGE_NAME;
  26. _ui = UI_PoemPhotoShareUI.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. isReturnView = true;
  30. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  31. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  32. _ui.m_mask.onClick.Add(OnBtnBackClick);
  33. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  34. _ui.m_btnShare.onClick.Add(OnBtnShareClick);
  35. _ui.m_btnShare.visible = false;
  36. }
  37. protected override void AddEventListener()
  38. {
  39. base.AddEventListener();
  40. }
  41. protected override void OnShown()
  42. {
  43. base.OnShown();
  44. _curPhotoData = this.viewData as PoemPhotoData;
  45. _ui.m_c1.selectedIndex = _curPhotoData.SourceType;
  46. if (_curPhotoData.SourceType == (int)PictureSourceType.PersonalAlbum)
  47. {
  48. _ui.m_loaBg.texture = _curPhotoData.Ntexture;
  49. _ui.m_loaBg.SetSize(_ui.m_loaBg.width, _ui.m_loaBg.texture.height * _ui.m_loaBg.width / _ui.m_loaBg.texture.width);
  50. }
  51. else if (_curPhotoData.SourceType == (int)PictureSourceType.WanShuiQianShan)
  52. {
  53. // UI_ComPostcard item = UI_ComPostcard.Proxy(_ui.m_comPostcard);
  54. TravelLoactionCfg loactionCfg = CommonDataManager.Tables.TblTravelLoactionCfg.GetOrDefault(_curPhotoData.TravelLocationId);
  55. _ui.m_comPostcard.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.Res);
  56. _ui.m_comPostcard.m_txtLocationName.text = loactionCfg.Name;
  57. _ui.m_comPostcard.m_txtTime.text = TimeUtil.FormattingTimeTo_yyyMMdd1(_curPhotoData.CreationTime);
  58. _ui.m_comPostcard.m_comTravel.m_loaRole.url = "";
  59. if (_curPhotoData.TravelSuitId > 0)
  60. {
  61. TravelSuitCfg travelSuitCfg = CommonDataManager.Tables.TblTravelSuitCfg.GetOrDefault(_curPhotoData.TravelSuitId);
  62. _ui.m_comPostcard.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.Reources[_curPhotoData.SuitResIndex]);
  63. _ui.m_comPostcard.m_comTravel.m_loaRole.SetXY(loactionCfg.Positions[_curPhotoData.PositionIndex].Key, loactionCfg.Positions[_curPhotoData.PositionIndex].Val);
  64. }
  65. // UI_ComPostcard.ProxyEnd();
  66. }
  67. }
  68. protected override void OnHide()
  69. {
  70. base.OnHide();
  71. }
  72. protected override void RemoveEventListener()
  73. {
  74. base.RemoveEventListener();
  75. }
  76. private void OnBtnBackClick()
  77. {
  78. ViewManager.GoBackFrom(typeof(PoemPhotoShareView).FullName);
  79. }
  80. private void OnBtnSaveClick()
  81. {
  82. byte[] bytes = _curPhotoData.Bytes;
  83. string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
  84. PhotographUtil.Instance.SavePicturoToLocal(bytes, fileName);
  85. }
  86. private void OnBtnShareClick()
  87. {
  88. }
  89. }
  90. }