天津23维预案
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.
 
 
 
 
 
 

123 lines
4.1 KiB

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using AX.NetworkSystem;
using AX.MessageSystem;
using System.IO;
using System.Collections.Generic;
using System.Xml;
public class CourseItemControl : MonoBehaviour
{
private Button DownloadBtn;
private GameObject CircleProcessBar;
private Button DelectBtn;
void Start ()
{
DownloadBtn = this.gameObject.transform.Find("Download").Find("XiaZaiBtn").GetComponent<Button>();
DelectBtn= this.gameObject.transform.Find("Delete").GetComponent<Button>();
CircleProcessBar = this.gameObject.transform.Find("Download").Find("CircleProcessBar").gameObject;
DownloadBtn.onClick.AddListener(Download);
DelectBtn.onClick.AddListener(DeleteItem);
}
public void DeleteItem()
{
GameObject TipWindow = Instantiate(Resources.Load<GameObject>("UIPrefab/TipWindow"));
TipWindow.GetComponent<TipWindowManager>().SetWindow(
"是否删除灾情?", new UnityEngine.Events.UnityAction(OKDeleteButton), new UnityEngine.Events.UnityAction(NoDeleteButton));
}
public void OKDeleteButton()
{
string PathXMl = Application.dataPath + @"/ExtendFolder/xml/CourseXML.xml";
if (File.Exists(PathXMl))
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(PathXMl);
XmlNode root = xmlDoc.SelectSingleNode("CourseNameList");
XmlNodeList nodeList = root.ChildNodes;
foreach (XmlElement elem in nodeList)
{
if (elem.Name == "CourseName")
{
foreach (XmlElement elems in elem)
{
if (elems.InnerText == this.gameObject.name)
{
elems.RemoveAll();
elem.RemoveChild(elems);
break;
}
}
break;
}
}
xmlDoc.Save(PathXMl);
}
string Pathfolder = Application.dataPath + @"/ExtendFolder/xml/SaveCoursewares/" + this.gameObject.name+"/";
//删除图片资源文件
string picXmlPath = Pathfolder + "PicData.xml";
string picPath = Application.dataPath + @"/Resources/PictureFilePath/";
List<string> timerNameList = new List<string>();
if (File.Exists(picXmlPath))
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(picXmlPath);
XmlNode root = xmlDoc.SelectSingleNode("AttributeList");
XmlNodeList nodelist = root.ChildNodes;
foreach (XmlElement node in nodelist)
{
if (node.Name.Equals("PicAttribute"))
{
timerNameList.Add(node.GetAttribute("timerName"));
}
}
}
foreach (string timerName in timerNameList)
{
if (File.Exists(picPath + timerName))
{
File.Delete(picPath + timerName);
}
}
if (Directory.Exists(Pathfolder))
{
Directory.Delete(Pathfolder, true);
}
Destroy(this.gameObject);
}
public void NoDeleteButton()
{
}
public void Download()
{
//DownloadBtn.gameObject.SetActive(false);
//CircleProcessBar.gameObject.SetActive(true);
//CoursewareInfo course = GetComponent<ExaminationPrepareMessage>().Courseware;
//List<string> fileList = new List<string>();
//var strs = course.FilePath.Split(new char[] { ';'}, System.StringSplitOptions.RemoveEmptyEntries);
//for(int i = 0; i < strs.Length; i++)
//{
// var filename = "Coursewares/" + course.ID + "/" + strs[i];
// fileList.Add(filename);
//}
//var files = fileList.ToArray();
//if (files.Length > 0)
//{
// CircleProcessBar.GetComponent<FileTransTipWinManager>().SetFileTrans("下载课件", files, TransferType.Download);
//}
}
}