You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
77 lines
2.4 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using AX.NetworkSystem;
|
||
|
using AX.MessageSystem;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class CoursewareBaseControl : PreparePageControl {
|
||
|
|
||
|
public override void changePagePanel(bool flag)
|
||
|
{
|
||
|
foreach (Transform child in transform)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
if (flag)
|
||
|
{
|
||
|
startPage = currentPage;
|
||
|
endPage = currentPage + 7;
|
||
|
if (endPage > pageCount)
|
||
|
{
|
||
|
endPage = pageCount;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
endPage = currentPage;
|
||
|
startPage = currentPage - 7;
|
||
|
}
|
||
|
for (int startPage = this.startPage; startPage <= endPage; startPage++)
|
||
|
{
|
||
|
GameObject item = Instantiate(itemPrefab) as GameObject;
|
||
|
item.transform.parent = transform;
|
||
|
//item.transform.localScale = new Vector3(1, 1, 1);
|
||
|
item.name = "Item";
|
||
|
item.GetComponent<Toggle>().group = GetComponent<ToggleGroup>();
|
||
|
item.GetComponent<CoursewareBaseMessage>().setPage(startPage);
|
||
|
if (startPage == currentPage)
|
||
|
{
|
||
|
item.GetComponent<Toggle>().isOn = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//换页请求返回后刷新页码
|
||
|
public override void pageChanged(IMessage message)
|
||
|
{
|
||
|
PagingReplyInfo<CoursewareInfo> pair = (PagingReplyInfo<CoursewareInfo>)(message.Data);
|
||
|
currentPage = pair.CurrentPage;
|
||
|
numberEachPage = pair.NumberPerPage;
|
||
|
pageCount = pair.PageCount;
|
||
|
if (currentPage < startPage)
|
||
|
{
|
||
|
changePagePanel(false);//向前刷新
|
||
|
}
|
||
|
else if (currentPage > endPage)
|
||
|
{
|
||
|
changePagePanel(true);//向后刷新
|
||
|
}
|
||
|
else //只改变选中页码
|
||
|
{
|
||
|
foreach (Transform child in transform)
|
||
|
{
|
||
|
if (child.GetComponent<CoursewareBaseMessage>().page == currentPage)
|
||
|
{
|
||
|
child.GetComponent<Toggle>().isOn = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override void getPageDataRequest()
|
||
|
{
|
||
|
NetworkManager.Default.SendRequestAsync("GET_PAGING_COURSEWAREBASE_REQUEST",
|
||
|
new CoursewarePagingRequestInfo { CurrentPage = currentPage, NumberPerPage = numberEachPage,
|
||
|
CreatorID = MySelf.mySelf.ID, Pattern = (int)ExamInfoHelpClass.applicationMode });
|
||
|
}
|
||
|
}
|