Esempio n. 1
0
    /// <summary>
    /// 写单页control xml结果
    /// </summary>
    /// <param name="pageNum"></param>
    public void WriteResult(int pageNum)
    {
        string xmlpath = PPTGlobal.PPTPath + pageNum + "/control_" + pageNum + ".xml";

        Debug.Log(xmlpath);
        if (File.Exists(xmlpath))
        {
            Debug.Log("存在旧文件:" + xmlpath.Replace(".xml", "_" + PublicTools.getTime() + ".xml"));
            File.Move(xmlpath, xmlpath.Replace(".xml", "_" + PublicTools.getTime() + ".xml"));
        }

        PPTResourcePool.slideObjs[pageNum].BroadcastMessage("DoSort", SendMessageOptions.DontRequireReceiver);

        SlideDoc     tmpDoc     = PublicTools.DeepCopy(PPTResourcePool.slideDoc);
        List <Slide> tempslides = new List <Slide>();

        foreach (Slide tempSlide in tmpDoc.slides)
        {
            if (tempSlide.pageNum == pageNum)
            {
                tempslides.Add(PublicTools.DeepCopy(tempSlide));
                break;
            }
        }
        tmpDoc.slides = tempslides;

        PublicTools.SaveObject(xmlpath, tmpDoc);
        clearXml(xmlpath);


        //document.Save(xmlpath);
    }
    /// <summary>
    /// 清理xml中不需要元素属性(和上一元素属性值相等的属性)
    /// </summary>
    /// <param name="xmlPath"></param>
    public void clearXml(string xmlPath)
    {
        if (!File.Exists(xmlPath))
        {
            return;
        }
        XmlDocument xd = new XmlDocument();

        xd.Load(xmlPath);
        XmlElement lastElement = null;
        XmlElement tempElement = null;

        string[] filter = new string[] { "nl", "pl", "isnew", "isClear" };
        foreach (XmlElement ele in xd.SelectNodes("//DL"))
        {
            if (lastElement != null)
            {
                tempElement = PublicTools.DeepCopy(ele);
                RemoveTargetAttr(lastElement, ele, filter);
                lastElement = tempElement;
            }
            else
            {
                lastElement = ele;
            }
        }
        xd.Save(xmlPath);
    }
Esempio n. 3
0
    public void PreAssets()
    {
        DebugLog.DebugLogInfo("preasset---------------------------------");

        PublicClass.DataManagerStatus = DataIntState.StreamCopying;

        string source_path = string.Empty;

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        source_path = PublicClass.fileLocalStreamingPath.Replace("file://", "");
#elif UNITY_IOS
        source_path = PublicClass.fileLocalStreamingPath;
#elif UNITY_ANDROID
        source_path = PublicClass.fileLocalStreamingPath;
#endif
        string target_path = PublicClass.filePath;
        try
        {
            Vesal_DirFiles.DelectDirFiles(target_path, new List <string> {
                "PPT", "temp"
            });
            DebugLog.DebugLogInfo("delete files ok---------------------------------");
            UnityEngine.Debug.Log(source_path);
            UnityEngine.Debug.Log(copy_list.Count);
            PublicClass.InitDirFiles();

            stream_copy_list = PublicTools.DeepCopy <List <string> >(copy_list);
            for (int i = 0; i < stream_copy_list.Count; i++)
            {
                stream_copy_list[i] = source_path + stream_copy_list[i];
            }
            if (copy_list.Count > 0)
            {
                string source = stream_copy_list[stream_copy_count];
                string target = target_path + copy_list[stream_copy_count];
                StartCoroutine(Vesal_DirFiles.Vesal_FileCopy(source, target, count_stream_copy));
            }
            else
            {
                DebugLog.DebugLogInfo("stream copy 异常--------------------------------");

                PublicClass.DataManagerStatus = DataIntState.FetchDb;
            }
        }
        catch (Exception e)
        {
            UnityEngine.Debug.Log("current count :" + stream_copy_count);
            UnityEngine.Debug.Log(e.Message);
            UnityEngine.Debug.Log(e.StackTrace);
            PublicClass.DataManagerStatus = DataIntState.FetchDb;
        }
    }
Esempio n. 4
0
    /// <summary>
    /// 录制文件导出协程
    /// </summary>
    /// <returns></returns>
    public IEnumerator exportRecord()
    {
        saveWaitPanelText.text    = "正在导出录制文件";
        exportButton.interactable = false;
        yield return(null);

        try
        {
            List <Slide> tempslides = new List <Slide>();
            SlideDoc     tmpDoc     = PublicTools.DeepCopy(PPTResourcePool.slideDoc);
            string       xmlpath;
            foreach (Slide tempSlide in tmpDoc.slides)
            {
                int tempPageNum = tempSlide.pageNum;
                xmlpath = PPTGlobal.PPTPath + tempPageNum + "/control_" + tempPageNum + ".xml";
                if (File.Exists(xmlpath))
                {
                    try
                    {
                        SlideDoc tempPageDoc = PublicTools.Deserialize <SlideDoc>(xmlpath);
                        tempslides.Add(tempPageDoc.slides[0]);
                    }
                    catch
                    {
                        Debug.Log("格式转换失败" + xmlpath);
                    }
                }
                else
                {
                    //如果此页没有录制,默认保存PPT导出记录
                    tempslides.Add(tempSlide);
                }
            }
            xmlpath = PPTGlobal.PPTPath + "control.xml";
            if (File.Exists(xmlpath))
            {
                File.Delete(xmlpath);
            }
            tmpDoc.slides = tempslides;
            PublicTools.SaveObject(xmlpath, tmpDoc);

            string sourcePath = PPTGlobal.PPTPath.Replace("\\", "/");
            if (sourcePath.EndsWith("/"))
            {
                sourcePath = sourcePath.Substring(0, sourcePath.Length - 1);
            }
            string DirectName = sourcePath.Substring(sourcePath.LastIndexOf("/") + 1);
            Debug.Log(@"EXPORT:" + PPTGlobal.PPTPath);
            if (!Directory.Exists(exportPath))
            {
                Vesal_DirFiles.CreateDir(exportPath);
            }
            Vesal_DirFiles.ZipDirectory(PPTGlobal.PPTPath.Substring(0, PPTGlobal.PPTPath.Length - 1), @"" + exportPath + DirectName + ".vsl");
            //Debug.LogError("压缩文件");
            Debug.Log(@"EXPORT:" + exportPath + DirectName + ".vsl");
            //打开文件夹

            OpenWeiKePlayer(exportPath, DirectName);
            //打开播放器加载资源
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
            Debug.Log(e.StackTrace);
        }
        yield return(null);

        exportButton.interactable = true;
        saveWaitPanelText.text    = "导出完成!";
        //saveWaitPanel.SetActive(false);
        //quitCanvas.SetActive(false);
    }