using UnityEngine; using System.Collections.Generic; using UnityEngine.UI; using AX.MessageSystem; using System.Text.RegularExpressions; using System; using AX.NetworkSystem; public class ExaminationPaperDetail : MonoBehaviour { // Use this for initialization public ExaminationPaperObject paper; public InputField paperName; public static List questionId = new List(); public Text questionCount; void Start() { MessageDispatcher.AddListener("REFRESH_PAPER_UI", refreshUI); } void OnDestroy() { MessageDispatcher.RemoveListener("REFRESH_PAPER_UI", refreshUI); } // Update is called once per frame void Update() { } public void submitExaminationPaper() { string detail = ""; var paperNameStr = paperName.text.Trim(); if (string.IsNullOrEmpty(paperNameStr)) { detail += "试卷名称不能为空,"; } if (questionId.Count == 0) { detail += "未选择试题,"; } if (detail != "") { detail = detail.Substring(0, detail.Length - 1); var obj = GameObject.Find("MessageBox").GetComponent().showMessage(ShowMessageType.warning, "信息提示", detail); transform.GetComponentInChildren().TipWin = obj; return; } paper.Name = paperNameStr; paper.Questions = questionsToString(); paper.CreatorName = MySelf.mySelf.Name; paper.CreatorID = MySelf.mySelf.ID; paper.Pattern = (int)ExamInfoHelpClass.applicationMode; NetworkManager.Default.SendRequestAsync("PAPER_SAVE_REQUEST", paper); gameObject.SetActive(false); } private void refreshUI(IMessage message) { questionCount.text = questionId.Count.ToString(); } public void showDetail(ExaminationPaperObject paper) { this.paper = paper; paperName.text = paper.Name; setQuestions(paper.Questions); questionCount.text = questionId.Count.ToString(); } private void setQuestions(string question) { if (!string.IsNullOrEmpty(question)) { var questionStr = question.Split(','); questionId = new List(questionStr); } else { questionId.Clear(); } } private string questionsToString() { string questionsStr = ""; if (questionId.Count > 0) { foreach (string question in questionId) { questionsStr += question + ","; } questionsStr = questionsStr.Substring(0, questionsStr.Length - 1); } return questionsStr; } }