123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Poem;
- using UnityEngine;
- namespace GFGGame
- {
- public class PoemPhotoView : BaseWindow
- {
- private UI_PoemPhotoUI _ui;
- private List<int> _listDelete = new List<int>();
- private bool _deleting = false;//是否删除状态
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_PoemPhotoUI.PACKAGE_NAME;
- _ui = UI_PoemPhotoUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
- _ui.m_list.SetVirtual();
- _ui.m_list.itemRenderer = RenderListItem;
- _ui.m_btnback.onClick.Add(OnBtnBackClick);
- _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
- _ui.m_c1.onChanged.Add(OnBtnTabChange);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- }
- protected override void OnHide()
- {
- base.OnHide();
- _listDelete.Clear();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void OnBtnBackClick()
- {
- ViewManager.GoBackFrom(typeof(PoemPhotoView).FullName);
- }
- private void OnBtnDeleteClick()
- {
- }
- private void OnBtnTabChange()
- {
- _deleting = false;
- if (_ui.m_c1.selectedIndex == 0)
- {
- _ui.m_list.numItems = 0;
- }
- else
- {
- _ui.m_list.numItems = 0;
- }
- }
- private void RenderListItem(int index, GObject obj)
- {
- UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
- int id = 0;
- item.m_c1.selectedIndex = _deleting ? 1 : 0;
- item.m_c2.selectedIndex = !_deleting || _listDelete.IndexOf(id) < 0 ? 0 : 1;
- if (item.m_btnLock.data == null)
- {
- item.m_btnLock.onClick.Add(OnBtnLockClick);
- }
- item.m_btnLock.data = id;
- if (item.m_btnUp.data == null)
- {
- item.m_btnUp.onClick.Add(OnBtnUpClick);
- }
- item.m_btnUp.data = id;
- if (item.m_loaIcon.data == null)
- {
- item.m_loaIcon.onClick.Add(OnLoaIconClick);
- }
- item.m_loaIcon.data = id;
- item.target.data = index;
- UI_ListPhotoItem.ProxyEnd();
- }
- private void OnLoaIconClick(EventContext context)
- {
- GObject obj = context.sender as GObject;
- if (!_deleting)
- {
- int index = (int)obj.parent.data;
- ViewManager.Show<PoemPhotoPreView>(index, new object[] { typeof(PoemView).FullName, this.viewData });
- }
- else
- {
- int id = (int)obj.data;
- UI_ListPhotoItem item = UI_ListPhotoItem.Proxy(obj);
- item.m_c2.selectedIndex = item.m_c2.selectedIndex == 0 ? 1 : 0;
- if (item.m_c2.selectedIndex == 1)
- {
- _listDelete.Add(id);
- }
- else
- {
- _listDelete.Remove(id);
- }
- UI_ListPhotoItem.ProxyEnd();
- }
- }
- private void OnBtnLockClick(EventContext context)
- {
- GObject item = context.sender as GObject;
- }
- private void OnBtnUpClick(EventContext context)
- {
- GObject item = context.sender as GObject;
- }
- }
- }
|