public override List<SearchResult> Search(ChapterInfo chapterInfo)
        {
            using (WebClient wc = new WebClient())
              {
            string url = "https://www.tagchimp.com/ape/lookup.php?token=10615158044869B9D96D50D&type=search&title={0}&totalChapters={1}&videoKind=Movie";
            url = string.Format(url, Uri.EscapeUriString(chapterInfo.Title), chapterInfo.Chapters.Count);
              //Uri.EscapeUriString
            //TODO: update to use streaming rather than downloading complete.
            string result = wc.DownloadString(new Uri(url));

            //remove invalid chars from result
            result = new string(result.ToCharArray().Where(c => IsLegalXmlChar((int)c)).ToArray());
            //result = result.Replace("&", "&amp;"); //tagChimp fixed, no longer needed, it's back
            //result = result.Replace("'", "&apos;"); //tagChimp fixed, no longer needed
            searchXml = XDocument.Parse(result);
            var titles = from m in searchXml.Descendants("movie")
                     select new SearchResult
                     {
                       Id = (string)m.Element("tagChimpID"),
                       Name = (string)m.Descendants("movieTitle").First()
                     };
            OnSearchComplete();
            return titles.ToList();
              }
        }
        public override void PopulateNames(string hash, ChapterInfo chapterInfo)
        {
            try
            {
                string url = "{0}/chapters/disc-{1}";
                url = string.Format(url, Settings.Default.DatabaseSite, hash);

                string xml = GetXml(url);

                XDocument doc = XDocument.Parse(xml);
                var chapters = ChapterInfo.Load(doc.Root);
                chapterInfo.Title = chapters.Title;

                for (int i = 0; i < chapterInfo.Chapters.Count; i++)
                {
                    chapterInfo.Chapters[i] = new ChapterEntry()
                    {
                        Name = chapters.Chapters[i].Name,
                        Time = chapterInfo.Chapters[i].Time
                    };
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
示例#3
0
        public override List<ChapterInfo> GetStreams(string location)
        {
            int titleSetNum = 1;

              if (location.StartsWith("VTS_"))
              {
            titleSetNum = int.Parse(Path.GetFileNameWithoutExtension(location)
             .ToUpper()
             .Replace("VTS_", string.Empty)
             .Replace("_0.IFO", string.Empty));
              }

              ChapterInfo pgc = new ChapterInfo();
              pgc.SourceType = "DVD";
              pgc.SourceName = location;
              pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
              pgc.Extractor = Application.ProductName + " " + Application.ProductVersion;
              pgc.Title = Path.GetFileNameWithoutExtension(location);
              OnStreamDetected(pgc);

              TimeSpan duration;
              double fps;
              pgc.Chapters = GetChapters(location, titleSetNum, out duration, out fps);
              pgc.Duration = duration;
              pgc.FramesPerSecond = fps;
              OnChaptersLoaded(pgc);

              OnExtractionComplete();
              return Enumerable.Repeat(pgc, 1).ToList();
        }
示例#4
0
 public MediaInfo()
 {
     Chapters     = new ChapterInfo[] { };
     Artists      = Array.Empty <string>();
     AlbumArtists = EmptyStringArray;
     Studios      = Array.Empty <string>();
     Genres       = Array.Empty <string>();
     People       = new BaseItemPerson[] { };
     ProviderIds  = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
 }
示例#5
0
        private void ConvertToMultiMp3(ChapterInfo splitChapters)
        {
            var chapterCount = 0;

            AaxFile.ConvertToMultiMp3(splitChapters, newSplitCallback =>
            {
                createOutputFileStream(++chapterCount, splitChapters, newSplitCallback);
                newSplitCallback.LameConfig.ID3.Track = chapterCount.ToString();
            });
        }
示例#6
0
        /// <summary>
        /// Adds the chapters.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="standardError">The standard error.</param>
        private void AddChapters(FFProbeResult result, string standardError)
        {
            var lines = standardError.Split('\n').Select(l => l.TrimStart());

            var chapters = new List <ChapterInfo> {
            };

            ChapterInfo lastChapter = null;

            foreach (var line in lines)
            {
                if (line.StartsWith("Chapter", StringComparison.OrdinalIgnoreCase))
                {
                    // Example:
                    // Chapter #0.2: start 400.534, end 4565.435
                    const string srch  = "start ";
                    var          start = line.IndexOf(srch, StringComparison.OrdinalIgnoreCase);

                    if (start == -1)
                    {
                        continue;
                    }

                    var subString = line.Substring(start + srch.Length);
                    subString = subString.Substring(0, subString.IndexOf(','));

                    double seconds;

                    if (double.TryParse(subString, out seconds))
                    {
                        lastChapter = new ChapterInfo
                        {
                            StartPositionTicks = TimeSpan.FromSeconds(seconds).Ticks
                        };

                        chapters.Add(lastChapter);
                    }
                }

                else if (line.StartsWith("title", StringComparison.OrdinalIgnoreCase))
                {
                    if (lastChapter != null && string.IsNullOrEmpty(lastChapter.Name))
                    {
                        var index = line.IndexOf(':');

                        if (index != -1)
                        {
                            lastChapter.Name = line.Substring(index + 1).Trim().TrimEnd('\r');
                        }
                    }
                }
            }

            result.Chapters = chapters;
        }
示例#7
0
        public static string GenerateQpFile(ChapterInfo chapterInfo, Timecode timecode)
        {
            StringBuilder qpFile = new StringBuilder();

            foreach (var chapter in chapterInfo.Chapters)
            {
                qpFile.AppendLine($"{timecode.GetFrameNumberFromTimeSpan(chapter.Time)} I");
            }

            return(qpFile.ToString());
        }
示例#8
0
        public void SetChapterInfoAndType(ChapterInfo chapterInfo)
        {
            _chapterInfo = chapterInfo;

            chapterBGRawImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, CHAPTER_BG_WIDTH);
            chapterBGRawImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, CHAPTER_BG_HEIGHT);

            Bounds bounds = RectTransformUtility.CalculateRelativeRectTransformBounds(transform);

            rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bounds.size.x);
            rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, bounds.size.y);
        }
        public override List<ChapterInfo> GetStreams(string location)
        {
            ChapterInfo pgc = new ChapterInfo();
              pgc.Chapters = new List<ChapterEntry>();
              pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
              pgc.SourceName = location;
              pgc.Title = Path.GetFileNameWithoutExtension(location);
              pgc.SourceType = "Blu-Ray";
              pgc.Extractor = Application.ProductName + " " + Application.ProductVersion;

              FileInfo fileInfo = new FileInfo(location);

              OnStreamDetected(pgc);
              TSPlaylistFile mpls = new TSPlaylistFile(fileInfo);
              //Dictionary<string, TSStreamClipFile> clips = new Dictionary<string,TSStreamClipFile>();
              mpls.Scan();
              foreach (double d in mpls.Chapters)
              {
            pgc.Chapters.Add(new ChapterEntry()
              {
            Name = string.Empty,
            Time = new TimeSpan((long)(d * (double)TimeSpan.TicksPerSecond))
              });
              }

              pgc.Duration = new TimeSpan((long)(mpls.TotalLength * (double)TimeSpan.TicksPerSecond));

              foreach (TSStreamClip clip in mpls.StreamClips)
              {
              try
              {
              clip.StreamClipFile.Scan();
                foreach (TSStream stream in clip.StreamClipFile.Streams.Values)
                {
                  if (stream.IsVideoStream)
                  {
                    pgc.FramesPerSecond = (double)((TSVideoStream)stream).FrameRateEnumerator /
                    (double)((TSVideoStream)stream).FrameRateDenominator;
                    break;
                  }
                }
                if (pgc.FramesPerSecond != 0) break;
              }
              catch (Exception ex)
              {
              Trace.WriteLine(ex);
              }
              }

              OnChaptersLoaded(pgc);
              OnExtractionComplete();
              return new List<ChapterInfo>() { pgc };
        }
示例#10
0
        public static IEnumerable <ChapterInfo> ParseXml(XmlDocument doc)
        {
            var root = doc.DocumentElement;

            if (root == null)
            {
                throw new ArgumentException("Empty Xml file");
            }
            if (root.Name != "Chapters")
            {
                throw new Exception($"Invalid Xml file.\nroot node Name: {root.Name}");
            }

            // Get Entrance for each chapter
            foreach (XmlNode editionEntry in root.ChildNodes)
            {
                if (editionEntry.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                if (editionEntry.Name != "EditionEntry")
                {
                    throw new Exception($"Invalid Xml file.\nEntry Name: {editionEntry.Name}");
                }
                var buff = new ChapterInfo {
                    SourceType = "XML", Tag = doc, TagType = doc.GetType()
                };
                var index = 0;

                // Get all the child nodes in current chapter
                foreach (XmlNode editionEntryChildNode in ((XmlElement)editionEntry).ChildNodes)
                {
                    if (editionEntryChildNode.Name != "ChapterAtom")
                    {
                        continue;
                    }
                    buff.Chapters.AddRange(ParseChapterAtom(editionEntryChildNode, ++index));
                }

                // remove redundancy chapter node.
                for (var i = 0; i < buff.Chapters.Count - 1; i++)
                {
                    if (buff.Chapters[i].Time == buff.Chapters[i + 1].Time)
                    {
                        buff.Chapters.Remove(buff.Chapters[i--]);
                    }
                }

                // buff.Chapters = buff.Chapters.Distinct().ToList();
                yield return(buff);
            }
        }
示例#11
0
    public void ChapterReward(config_chapter_item itemConfig)
    {
        for (int i = 0; i < chapters.Count; i++)
        {
            ChapterInfo chapter = chapters[i];

            if (chapter.id == itemConfig.id)
            {
                chapter.reward = true;

                List <TIVInfo> rewards = itemConfig.GetRewardList();

                for (int j = 0; j < rewards.Count; j++)
                {
                    TIVInfo    reward     = rewards[j];
                    WealthInfo wealthInfo = PlayerModel.Instance.GetWealth(reward.id);
                    wealthInfo.count += (int)reward.value;
                    PromptModel.Instance.Pop("+" + reward.value, true, reward.id);
                }
                PlayerModel.Instance.SaveWealths();

                SaveChapter();
                if (StarRewardEvent != null)
                {
                    StarRewardEvent(itemConfig);
                }
                return;
            }
        }
        ChapterInfo chapterNew = new ChapterInfo();

        chapterNew.id     = itemConfig.id;
        chapterNew.reward = true;
        chapters.Add(chapterNew);

        List <TIVInfo> rewardsNew = itemConfig.GetRewardList();

        for (int j = 0; j < rewardsNew.Count; j++)
        {
            TIVInfo    reward     = rewardsNew[j];
            WealthInfo wealthInfo = PlayerModel.Instance.GetWealth(reward.id);
            wealthInfo.count += (int)reward.value;
            PromptModel.Instance.Pop("+" + reward.value, true, reward.id);
        }
        PlayerModel.Instance.SaveWealths();

        SaveChapter();
        if (StarRewardEvent != null)
        {
            StarRewardEvent(itemConfig);
        }
    }
示例#12
0
    public ChapterInfo GetChapterInfo(int id)
    {
        for (int i = 0; i < chapters.Count; i++)
        {
            ChapterInfo chapter = chapters[i];

            if (chapter.id == id)
            {
                return(chapter);
            }
        }
        return(null);
    }
示例#13
0
        public static string GenerateQpFile(ChapterInfo chapterInfo, double fps)
        {
            StringBuilder qpFile = new StringBuilder();

            foreach (var chapter in chapterInfo.Chapters)
            {
                long miliSec = (long)chapter.Time.TotalMilliseconds;
                int  frameNo = (int)(miliSec / 1000.0 * fps + 0.5);
                qpFile.AppendLine($"{frameNo} I");
            }

            return(qpFile.ToString());
        }
        /// <summary>
        /// Construct a structure by copying informatio from the given ChapterInfo
        /// </summary>
        /// <param name="chapter">Structure to copy information from</param>
        public ChapterInfo(ChapterInfo chapter)
        {
            StartTime = chapter.StartTime; EndTime = chapter.EndTime; StartOffset = chapter.StartOffset; EndOffset = chapter.EndOffset; Title = chapter.Title; Subtitle = chapter.Subtitle; Url = chapter.Url; UniqueID = chapter.UniqueID;

            if (chapter.Url != null)
            {
                Url = new UrlInfo(chapter.Url);
            }
            if (chapter.Picture != null)
            {
                Picture = new PictureInfo(chapter.Picture);
            }
        }
示例#15
0
        private void GetChapter(string Url)
        {
            ChapterInfo Nrs     = biqudu.GetContent(Url);
            string      Content = "获取失败。。。";

            if (Nrs != null)
            {
                zj.Content = Nrs.Name;
                Content    = Nrs.Content;
            }
            nr.Inlines.Clear();
            nr.Inlines.Add(new Run(Content));
        }
示例#16
0
        public static IEnumerable <ChapterInfo> GetStreams(string location)
        {
            var        doc = XDocument.Load(location);
            XNamespace ns  = "http://www.dvdforum.org/2005/HDDVDVideo/Playlist";

            foreach (var ts in doc.Element(ns + "Playlist").Elements(ns + "TitleSet"))
            {
                var timeBase = GetFps((string)ts.Attribute("timeBase")) ?? 60; //required
                var tickBase = GetFps((string)ts.Attribute("tickBase")) ?? 24; //optional
                foreach (var title in ts.Elements(ns + "Title").Where(t => t.Element(ns + "ChapterList") != null))
                {
                    var pgc = new ChapterInfo
                    {
                        SourceName      = title.Element(ns + "PrimaryAudioVideoClip")?.Attribute("src")?.Value ?? "",
                        SourceType      = "HD-DVD",
                        FramesPerSecond = 24M,
                        Chapters        = new List <Chapter>()
                    };
                    var tickBaseDivisor = (int?)title.Attribute("tickBaseDivisor") ?? 1; //optional
                    pgc.Duration = GetTimeSpan((string)title.Attribute("titleDuration"), timeBase, tickBase, tickBaseDivisor);
                    var titleName = Path.GetFileNameWithoutExtension(location);
                    if (title.Attribute("id") != null)
                    {
                        titleName = title.Attribute("id")?.Value ?? "";                                       //optional
                    }
                    if (title.Attribute("displayName") != null)
                    {
                        titleName = title.Attribute("displayName")?.Value ?? "";                                         //optional
                    }
                    pgc.Title = titleName;
                    foreach (var chapter in title.Element(ns + "ChapterList").Elements(ns + "Chapter"))
                    {
                        var chapterName = string.Empty;
                        if (chapter.Attribute("id") != null)
                        {
                            chapterName = chapter.Attribute("id")?.Value ?? "";                                  //optional
                        }
                        if (chapter.Attribute("displayName") != null)
                        {
                            chapterName = chapter.Attribute("displayName")?.Value ?? "";                                           //optional
                        }
                        pgc.Chapters.Add(new Chapter
                        {
                            Name = chapterName,
                            Time = GetTimeSpan((string)chapter.Attribute("titleTimeBegin"), timeBase, tickBase, tickBaseDivisor) //required
                        });
                    }
                    yield return(pgc);
                }
            }
        }
示例#17
0
        public override List <ChapterInfo> GetStreams(string location)
        {
            List <ChapterInfo> pgcs = new List <ChapterInfo>();
            XDocument          doc  = XDocument.Load(location);
            XNamespace         ns   = "http://www.dvdforum.org/2005/HDDVDVideo/Playlist";

            foreach (XElement ts in doc.Element(ns + "Playlist").Elements(ns + "TitleSet"))
            {
                float timeBase = GetFps((string)ts.Attribute("timeBase"));
                float tickBase = GetFps((string)ts.Attribute("tickBase"));
                foreach (XElement title in ts.Elements(ns + "Title").Where(t => t.Element(ns + "ChapterList") != null))
                {
                    ChapterInfo         pgc      = new ChapterInfo();
                    List <ChapterEntry> chapters = new List <ChapterEntry>();
                    pgc.SourceName      = location;
                    pgc.SourceHash      = ChapterExtractor.ComputeMD5Sum(location);
                    pgc.SourceType      = "HD-DVD";
                    pgc.FramesPerSecond = 24D;
                    pgc.Extractor       = Application.ProductName + " " + Application.ProductVersion;
                    OnStreamDetected(pgc);

                    int tickBaseDivisor = (int?)title.Attribute("tickBaseDivisor") ?? 1;
                    pgc.Duration = GetTimeSpan((string)title.Attribute("titleDuration"), timeBase, tickBase, tickBaseDivisor);
                    string titleName = Path.GetFileNameWithoutExtension(location);
                    if (title.Attribute("id") != null)
                    {
                        titleName = (string)title.Attribute("id");
                    }
                    if (title.Attribute("displayName") != null)
                    {
                        titleName = (string)title.Attribute("displayName");
                    }
                    pgc.Title = titleName;
                    foreach (XElement chapter in title.Element(ns + "ChapterList").Elements(ns + "Chapter"))
                    {
                        chapters.Add(new ChapterEntry()
                        {
                            Name = (string)chapter.Attribute("displayName"),
                            Time = GetTimeSpan((string)chapter.Attribute("titleTimeBegin"), timeBase, tickBase, tickBaseDivisor)
                        });
                    }
                    pgc.Chapters = chapters;
                    OnChaptersLoaded(pgc);
                    //pgc.ChangeFps(24D / 1.001D);
                    pgcs.Add(pgc);
                }
            }
            pgcs = pgcs.OrderByDescending(p => p.Duration).ToList();
            OnExtractionComplete();
            return(pgcs);
        }
示例#18
0
        private async void FrmDownload_Load(object sender, EventArgs e)
        {
            BookInfoData bid = new BookInfoData();


            if (bid.GetBookInfos().Where(t => book.Equals(t)).FirstOrDefault() != null)
            {
                this.Close();
            }
            else
            {
                ChapterInfoData cif = new ChapterInfoData(book);

                groupBox1.Text = "正在初始化.....";
                HttpClient client = new HttpClient();
                string     html   = await client.GetStringAsync(book.URL);

                Match macth = Regex.Match(html, "<script>window.location.href='(.*)';</script>");
                if (macth.Length > 0 && macth.Groups.Count > 1)
                {
                    html = await client.GetStringAsync(macth.Groups[1].Value);
                }

                Elements           elements     = NSoupClient.Parse(html).Select("#list a[href]");
                List <ChapterInfo> chapterInfos = new List <ChapterInfo>();
                foreach (var item in elements)
                {
                    ChapterInfo chapterInfo = new ChapterInfo();
                    chapterInfo.ID       = Kit.GetGuid();
                    chapterInfo.Title    = item.Html().Replace(" ", "");
                    chapterInfo.Url      = "http://www.xs.la" + item.Attr("href");
                    chapterInfo.Metadata = item.Html();
                    chapterInfo.AddTime  = DateTime.Now;
                    chapterInfos.Add(chapterInfo);
                }
                cif.Save(chapterInfos);

                groupBox1.Text = "初始化完成";
            }

            BookInfoData bif = new BookInfoData();


            if (bif.GetBookInfos(t => book.Equals(t)).Count <= 0)
            {
                book.AddTime = DateTime.Now;
                bif.Add(book);
            }

            Download();
        }
示例#19
0
        private async void Download()
        {
            groupBox1.Text = "开始下载";
            ChapterInfoData cif = new ChapterInfoData(book);

            List <ChapterInfo> chapterInfos = cif.GetChapterInfos();

            progressBar1.Maximum = chapterInfos.Count;

            HttpClient client = new HttpClient();

            for (int i = 0; i < chapterInfos.Count; i++)
            {
download:
                {
                    try
                    {
                        ChapterInfo item = chapterInfos[i];
                        string      html = await client.GetStringAsync(item.Url);

                        Match macth = Regex.Match(html, "<script>window.location.href='(.*)';</script>");
                        if (macth.Length > 0 && macth.Groups.Count > 1)
                        {
                            html = await client.GetStringAsync(macth.Groups[1].Value);
                        }
                        groupBox1.Text = item.Title;
                        item.Content   = NSoupClient.Parse(html).Select("div[id=content]").Html()
                                         .Replace(" ", "")
                                         .Replace("&nbsp;", " ")
                                         .Replace("<br>", "\r\n")
                                         .Replace("<br/>", "\r\n")
                                         .Replace("<scripttype=\"text/javascript\"src=\"/js/chaptererror.js\"></script>", "");
                        progressBar1.Value++;
                    }
                    catch (HttpRequestException httpRequestException)
                    {
                        Log.Info(httpRequestException.Message);
                        if (MessageBox.Show("下载遇到问题,是否重试", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            goto download;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            cif.Save(chapterInfos);
            this.Close();
        }
示例#20
0
    void UpdateChapterList()
    {
        bool bHaveUngotAward = GameManager.gameManager.PlayerDataPool.JuQingCopySceneData.IsHaveUngotAward();

        if (bHaveUngotAward)
        {
            if (Hongdian != null)
            {
                Hongdian.SetActive(true);
            }
        }
        else
        {
            if (Hongdian != null)
            {
                Hongdian.SetActive(false);
            }
        }

        for (int i = 0; i < ChapterListGrid.transform.childCount; i++)
        {
            GameObject.Destroy(ChapterListGrid.transform.GetChild(i).gameObject);
        }

        m_ChapterInfo.Clear();

        var chapterDic = TableManager.GetStoryCopySceneChapter();

        foreach (var list in chapterDic)
        {
            var table = list.Value[0];
            if (table != null)
            {
                ChapterInfo tabCap = new ChapterInfo(table.Id, table.ChapterName);
                m_ChapterInfo.Add(tabCap);

                GameObject item = Utils.BindObjToParent(ChapterItem, ChapterListGrid.gameObject, table.Id.ToString());
                {
                    if (item != null)
                    {
                        JuQingChapterItem juQingChapterItem = item.GetComponent <JuQingChapterItem>();
                        if (juQingChapterItem != null)
                        {
                            juQingChapterItem.ChapterNameLabel.text = table.ChapterName;
                        }
                    }
                }
            }
        }
        ChapterListGrid.repositionNow = true;
    }
示例#21
0
        public static IEnumerable <ChapterInfo> ToChapterInfo(this Chapters chapters)
        {
            var index = 0;

            foreach (var entry in chapters.EditionEntry)
            {
                var info = new ChapterInfo();
                foreach (var atom in entry.ChapterAtom)
                {
                    info.Chapters.AddRange(ToChapter(atom, ++index));
                }
                yield return(info);
            }
        }
示例#22
0
        public void CS_WriteChapters()
        {
            // Note : if you target ID3v2 chapters, it is highly advised to use Settings.ID3v2_tagSubVersion = 3
            // as most readers only support ID3v2.3 chapters
            Track theFile = new Track(audioFilePath);

            theFile.Chapters = new System.Collections.Generic.List <ChapterInfo>();

            ChapterInfo ch = new ChapterInfo();

            ch.StartTime   = 123;
            ch.StartOffset = 456;
            ch.EndTime     = 789;
            ch.EndOffset   = 101112;
            ch.UniqueID    = "";
            ch.Title       = "aaa";
            ch.Subtitle    = "bbb";
            ch.Url         = new ChapterInfo.UrlInfo("ccc", "ddd");
            theFile.Chapters.Add(ch);

            ch             = new ChapterInfo();
            ch.StartTime   = 1230;
            ch.StartOffset = 4560;
            ch.EndTime     = 7890;
            ch.EndOffset   = 1011120;
            ch.UniqueID    = "002";
            ch.Title       = "aaa0";
            ch.Subtitle    = "bbb0";
            ch.Url         = new ChapterInfo.UrlInfo("ccc", "ddd0");
            // Add a picture to the 2nd chapter
            ch.Picture = new PictureInfo(Commons.ImageFormat.Jpeg, PictureInfo.PIC_TYPE.Generic);
            byte[] data = System.IO.File.ReadAllBytes(imagePath);
            ch.Picture.PictureData = data;

            theFile.Chapters.Add(ch);

            // Persists the chapters
            theFile.Save();

            // Reads the file again from sratch
            theFile = new Track(audioFilePath);
            IList <PictureInfo> pics = theFile.EmbeddedPictures; // Hack to load chapter pictures

            // Display chapters
            foreach (ChapterInfo chap in theFile.Chapters)
            {
                System.Console.WriteLine(chap.Title + "(" + chap.StartTime + ")");
            }
        }
示例#23
0
    private void ResetImageIslands(int chapter, DungeonType.ENUM dungeonType)
    {
        int  num  = 0;
        bool flag = false;

        for (int i = 0; i < this.listData.get_Count(); i++)
        {
            ChapterInfo chapterInfo = this.listData.get_Item(i);
            for (int j = 0; j < chapterInfo.dungeons.get_Count(); j++)
            {
                DungeonInfo dungeonInfo = chapterInfo.dungeons.get_Item(j);
                if (!dungeonInfo.clearance)
                {
                    num  = i;
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                break;
            }
        }
        for (int k = 0; k < this.listIsland.get_Count(); k++)
        {
            Object.Destroy(this.listIsland.get_Item(k));
        }
        this.listIsland.Clear();
        for (int l = 0; l <= num; l++)
        {
            ChapterInfo           chapterInfo2          = this.listData.get_Item(l);
            ZhuXianZhangJiePeiZhi zhuXianZhangJiePeiZhi = DataReader <ZhuXianZhangJiePeiZhi> .Get(chapterInfo2.chapterId);

            if (zhuXianZhangJiePeiZhi.mainSenceIcon != 0)
            {
                GameObject gameObject = new GameObject(chapterInfo2.chapterId.ToString());
                gameObject.get_transform().set_parent(this.Islands);
                this.listIsland.Add(gameObject);
                Image image = gameObject.AddComponent <Image>();
                ResourceManager.SetSprite(image, ResourceManager.GetIconSprite(DataReader <Icon> .Get(zhuXianZhangJiePeiZhi.mainSenceIcon).icon));
                RectTransform component = gameObject.GetComponent <RectTransform>();
                component.set_localPosition(new Vector2((float)zhuXianZhangJiePeiZhi.mainSenceIconPoint.get_Item(0), (float)zhuXianZhangJiePeiZhi.mainSenceIconPoint.get_Item(1)));
                component.set_localScale(Vector3.get_one());
                image.SetNativeSize();
                ButtonCustom buttonCustom = gameObject.AddComponent <ButtonCustom>();
                buttonCustom.onClickCustom = new ButtonCustom.VoidDelegateObj(this.OnClickIslandItem);
            }
        }
    }
示例#24
0
 private void SetupDicDungeonInfo(List <ChapterInfo> chapter)
 {
     for (int i = 0; i < chapter.get_Count(); i++)
     {
         ChapterInfo chapterInfo = chapter.get_Item(i);
         for (int j = 0; j < chapterInfo.dungeons.get_Count(); j++)
         {
             DungeonInfo dungeonInfo = chapterInfo.dungeons.get_Item(j);
             if (!this.dicDungeonInfo.ContainsKey(dungeonInfo.dungeonId))
             {
                 this.dicDungeonInfo.Add(dungeonInfo.dungeonId, dungeonInfo);
             }
         }
     }
 }
示例#25
0
        /// <summary>
        /// Gets the chapter info dto.
        /// </summary>
        /// <param name="chapterInfo">The chapter info.</param>
        /// <param name="item">The item.</param>
        /// <returns>ChapterInfoDto.</returns>
        private ChapterInfoDto GetChapterInfoDto(ChapterInfo chapterInfo, BaseItem item)
        {
            var dto = new ChapterInfoDto
            {
                Name = chapterInfo.Name,
                StartPositionTicks = chapterInfo.StartPositionTicks
            };

            if (!string.IsNullOrEmpty(chapterInfo.ImagePath))
            {
                dto.ImageTag = GetImageCacheTag(item, ImageType.Chapter, chapterInfo.ImagePath);
            }

            return(dto);
        }
示例#26
0
    private void ShowStar()
    {
        StarInfo starInfo = MapModel.Instance.starInfo;

        starButton.GetComponentInChildren <Text>().text = starInfo.crtStar + "/" + starInfo.openMapFullStar;
        starTipAnim.Stop();

        List <config_chapter_item> datas = ResModel.Instance.config_chapter.data;
        int totalChapterCount            = datas.Count;
        int i;

        for (i = 0; i < totalChapterCount; i++)
        {
            config_chapter_item config_chapter = datas[i];
            List <int>          mapIds         = config_chapter.GetMapIds();

            if (mapIds.Count > 0)
            {
                int allStars = 0;
                int fullStar = 0;
                int j;
                for (j = 0; j < mapIds.Count; j++)
                {
                    config_map_item config_map = (config_map_item)ResModel.Instance.config_map.GetItem(mapIds[j]);

                    MapInfo mapInfo = MapModel.Instance.GetMapInfo(config_map.id);

                    if (mapInfo != null)
                    {
                        allStars += mapInfo.star;
                    }

                    fullStar += 3;
                }

                if (allStars >= fullStar)
                {
                    ChapterInfo chapter = MapModel.Instance.GetChapterInfo(config_chapter.id);

                    if (chapter == null || chapter.reward == false)
                    {
                        starTipAnim.Play();
                        return;
                    }
                }
            }
        }
    }
示例#27
0
        private void EpisodeChapters(Collection <ChapterInfo> chapters, XmlNode itemNode, XmlNamespaceManager namespaceMgr)
        {
            XmlNode chaptersNode = itemNode.SelectSingleNode("./psc:chapters", namespaceMgr);

            if (chaptersNode == null)
            {
                return;
            }

            foreach (XmlNode chapterNode in chaptersNode.SelectNodes("./psc:chapter", namespaceMgr))
            {
                var chapter = new ChapterInfo();
                chapter.Name = chapterNode.Attributes["title"].Value;
                var start = this.ParseChapterStart(chapterNode.Attributes["start"].Value);

                if (start == null)
                {
                    continue;
                }

                chapter.Start = start.Value;

                var hrefAttr = chapterNode.Attributes["href"];

                if (hrefAttr != null && !string.IsNullOrEmpty(hrefAttr.Value))
                {
                    chapter.Link = new Uri(hrefAttr.Value);
                }

                var imageAttr = chapterNode.Attributes["image"];

                if (imageAttr != null)
                {
                    Uri    imageUrl  = new Uri(imageAttr.Value);
                    byte[] imageData = this.CachedWebClient.DownloadData(imageUrl, CacheHTTPHours, UserAgent);

                    using (MemoryStream imageStream = new MemoryStream(imageData))
                    {
                        using (Bitmap streamBitmap = new Bitmap(imageStream))
                        {
                            chapter.Image = new Bitmap(streamBitmap);
                        }
                    }
                }

                chapters.Add(chapter);
            }
        }
示例#28
0
 public string GetImageCacheTag(BaseItem item, ChapterInfo chapter)
 {
     try
     {
         return(GetImageCacheTag(item, new ItemImageInfo
         {
             Path = chapter.ImagePath,
             Type = ImageType.Chapter,
             DateModified = chapter.ImageDateModified
         }));
     }
     catch
     {
         return(null);
     }
 }
 void Read()
 {
     Hashtable tb = new Hashtable();
     ParseData(table, tb);
     foreach (DictionaryEntry t in tb)
     {
         ChapterInfo info = new ChapterInfo();
         int key = new int();
         Hashtable value = (Hashtable)t.Value;
         info.chapter = ParseTableValueToInt(value["ID"]);
         info.name = ParseTableValueToString(value["Name"]);
         info.imageName = ParseTableValueToString(value["ImageName"]);
         key = info.chapter;
         mChapterDictionary.Add(key, info);
     }
 }
示例#30
0
        public static bool GetChapterFromMPLS(TaskDetail task)
        {
            if (!task.InputFile.EndsWith(".m2ts"))
            {
                Logger.Warn($"{ task.InputFile }不是蓝光原盘文件。");
                return(false);
            }

            FileInfo inputFile = new FileInfo(task.InputFile);
            string   folder    = inputFile.DirectoryName;

            if (!folder.EndsWith(@"\BDMV\STREAM"))
            {
                Logger.Warn($"{ task.InputFile }不在BDMV文件夹结构内。");
                return(false);
            }
            folder  = folder.Remove(folder.Length - 6);
            folder += "PLAYLIST";
            DirectoryInfo playlist = new DirectoryInfo(folder);

            if (!playlist.Exists)
            {
                Logger.Warn($"{ task.InputFile }没有上级的PLAYLIST文件夹");
                return(false);
            }

            FileInfo[] allPlaylists = playlist.GetFiles();
            MPLSParser parser       = new MPLSParser();

            foreach (FileInfo mplsFile in allPlaylists)
            {
                IChapterData allChapters = parser.Parse(mplsFile.FullName);
                for (int i = 0; i < allChapters.Count; i++)
                {
                    ChapterInfo chapter = allChapters[i];
                    if (chapter.SourceName + ".m2ts" == inputFile.Name)
                    {
                        //save chapter file
                        string chapterFileName = Path.ChangeExtension(task.InputFile, ".txt");
                        allChapters.Save(ChapterTypeEnum.OGM, chapterFileName, i);
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#31
0
        private ChapterInfo GetChapterInfo(MediaChapter chapter)
        {
            var info = new ChapterInfo();

            if (chapter.tags != null)
            {
                string name;
                if (chapter.tags.TryGetValue("title", out name))
                {
                    info.Name = name;
                }
            }

            info.StartPositionTicks = chapter.start / 100;

            return(info);
        }
示例#32
0
    void Read()
    {
        Hashtable tb = new Hashtable();

        ParseData(table, tb);
        foreach (DictionaryEntry t in tb)
        {
            ChapterInfo info  = new ChapterInfo();
            int         key   = new int();
            Hashtable   value = (Hashtable)t.Value;
            info.chapter   = ParseTableValueToInt(value["ID"]);
            info.name      = ParseTableValueToString(value["Name"]);
            info.imageName = ParseTableValueToString(value["ImageName"]);
            key            = info.chapter;
            mChapterDictionary.Add(key, info);
        }
    }
示例#33
0
        public Mp4Data(string path)
        {
            var file = MP4File.Open(path);

            if (file.Chapters == null)
            {
                return;
            }
            Chapter = new ChapterInfo();
            var index = 0;

            foreach (var chapterClip in file.Chapters)
            {
                Chapter.Chapters.Add(new Chapter(chapterClip.Title, Chapter.Duration, ++index));
                Chapter.Duration += chapterClip.Duration;
            }
        }
示例#34
0
    public bool IsFinish(int instanceID)
    {
        if (instanceID <= 0)
        {
            return(false);
        }
        FuBenJiChuPeiZhi fuBenJiChuPeiZhi = DataReader <FuBenJiChuPeiZhi> .Get(instanceID);

        if (fuBenJiChuPeiZhi == null)
        {
            return(false);
        }
        List <ChapterInfo> dataByInstanceType = this.GetDataByInstanceType(fuBenJiChuPeiZhi.type);

        if (dataByInstanceType == null)
        {
            return(false);
        }
        ZhuXianPeiZhi zhuXianPeiZhi = DataReader <ZhuXianPeiZhi> .Get(instanceID);

        if (zhuXianPeiZhi == null)
        {
            return(false);
        }
        ZhuXianZhangJiePeiZhi zhuXianZhangJiePeiZhi = DataReader <ZhuXianZhangJiePeiZhi> .Get(zhuXianPeiZhi.chapterId);

        if (zhuXianZhangJiePeiZhi == null)
        {
            return(false);
        }
        if (zhuXianZhangJiePeiZhi.chapterOrder - 1 < 0 || zhuXianZhangJiePeiZhi.chapterOrder - 1 >= dataByInstanceType.get_Count())
        {
            return(false);
        }
        ChapterInfo chapterInfo = dataByInstanceType.get_Item(zhuXianZhangJiePeiZhi.chapterOrder - 1);

        for (int i = 0; i < chapterInfo.dungeons.get_Count(); i++)
        {
            if (instanceID == chapterInfo.dungeons.get_Item(i).dungeonId)
            {
                return(chapterInfo.dungeons.get_Item(i).clearance);
            }
        }
        return(false);
    }
        public override List<SearchResult> Search(ChapterInfo chapterInfo)
        {
            string url = "{0}/chapters/search?title={1}&chapterCount={2}";
            url = string.Format(url, Settings.Default.DatabaseSite, Uri.EscapeUriString(chapterInfo.Title), chapterInfo.Chapters.Count);

            string xml = GetXml(url);

            var searchXml = XDocument.Parse(xml);
            searchResults = searchXml.Root.Elements(ChapterInfo.CgNs + "chapterInfo").Select(x => ChapterInfo.Load(x)).ToList();

            var titles = searchResults.Select(m => new SearchResult()
                            {
                                Id = (m.ChapterSetId ?? 0).ToString(),
                                Name = m.Title
                            });
            OnSearchComplete();
            return titles.ToList();
        }
示例#36
0
        private void createOutputFileStream(int currentChapter, ChapterInfo splitChapters, NewSplitCallback newSplitCallback)
        {
            var fileName = multipartFileNameCallback(new()
            {
                OutputFileName = OutputFileName,
                PartsPosition  = currentChapter,
                PartsTotal     = splitChapters.Count,
                Title          = newSplitCallback?.Chapter?.Title
            });

            fileName = FileUtility.GetValidFilename(fileName);

            multiPartFilePaths.Add(fileName);

            FileUtility.SaferDelete(fileName);

            newSplitCallback.OutputFile = File.Open(fileName, FileMode.OpenOrCreate);
        }
        public override List<ChapterInfo> GetStreams(string location)
        {
            List<ChapterInfo> pgcs = new List<ChapterInfo>();
              XDocument doc = XDocument.Load(location);
              XNamespace ns = "http://www.dvdforum.org/2005/HDDVDVideo/Playlist";
              foreach (XElement ts in doc.Element(ns + "Playlist").Elements(ns + "TitleSet"))
              {
            float timeBase = GetFps((string)ts.Attribute("timeBase"));
            float tickBase = GetFps((string)ts.Attribute("tickBase"));
            foreach (XElement title in ts.Elements(ns + "Title").Where(t => t.Element(ns + "ChapterList") != null))
            {
              ChapterInfo pgc = new ChapterInfo();
              List<ChapterEntry> chapters = new List<ChapterEntry>();
              pgc.SourceName = location;
              pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
              pgc.SourceType = "HD-DVD";
              pgc.FramesPerSecond = 24D;
              pgc.Extractor = Application.ProductName + " " + Application.ProductVersion;
              OnStreamDetected(pgc);

              int tickBaseDivisor = (int?)title.Attribute("tickBaseDivisor") ?? 1;
              pgc.Duration = GetTimeSpan((string)title.Attribute("titleDuration"), timeBase, tickBase, tickBaseDivisor);
              string titleName = Path.GetFileNameWithoutExtension(location);
              if (title.Attribute("id") != null) titleName = (string)title.Attribute("id");
              if (title.Attribute("displayName") != null) titleName = (string)title.Attribute("displayName");
              pgc.Title = titleName;
              foreach (XElement chapter in title.Element(ns + "ChapterList").Elements(ns + "Chapter"))
              {
            chapters.Add(new ChapterEntry()
            {
              Name = (string)chapter.Attribute("displayName"),
              Time = GetTimeSpan((string)chapter.Attribute("titleTimeBegin"), timeBase, tickBase, tickBaseDivisor)
            });
              }
              pgc.Chapters = chapters;
              OnChaptersLoaded(pgc);
              //pgc.ChangeFps(24D / 1.001D);
              pgcs.Add(pgc);
            }
              }
              pgcs = pgcs.OrderByDescending(p => p.Duration).ToList();
              OnExtractionComplete();
              return pgcs;
        }
        public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
        {
            var chapters = searchResults.Where(r => r.ChapterSetId == int.Parse(result.Id)).First();

            if (chapterInfo.Chapters.Count > 0)
            {
                for (int i = 0; i < chapterInfo.Chapters.Count; i++)
                {
                    chapterInfo.Chapters[i] = new ChapterEntry()
                    {
                        Name = chapters.Chapters[i].Name,
                        Time = chapterInfo.Chapters[i].Time
                    };
                }
            }
            else
            {
                chapterInfo.Chapters = chapters.Chapters;
            }
        }
        //static XDocument searchXhtml = new XDocument();
        public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
        {
            XDocument xdoc = XDocument.Load(string.Format("http://www.e-home.no/metaservices/XML/GetDVDInfo.aspx?Extended=True&DVDID={0}", result.Id));
              XElement title = xdoc.Descendants("title").Where(t => t.Elements("chapter").Count() > 0)
            .OrderByDescending(t => t.Elements("chapter").Count()).FirstOrDefault();
              if (title == null) return;

              for (int i = 0; i < chapterInfo.Chapters.Count; i++)
              {
            XElement chapter = title.Elements("chapter").Where(c => (int)c.Element("chapterNum") == i+1)
              .FirstOrDefault();
            if (chapter != null)
              chapterInfo.Chapters[i] = new Chapter()
              {
            Time = chapterInfo.Chapters[i].Time,
            Name = includeDurations ? (string)chapter.Element("chapterTitle") :
            ((string)chapter.Element("chapterTitle")).RemoveDuration()
              };
              }
        }
示例#40
0
    private void Awake()
    {
        StartCoroutine(FadeIn());
        PlayerData.instance.CheckInstance();

        chapterInfo = GameObject.FindObjectOfType<ChapterInfo>();

        for (int c = 0; c < 8; c++)
        {
            List<Button> stageButtonList = new List<Button>();
            for (int s = 1; s <= 3 + (c > 3 ? 1 : 0); s++)
            {
                stageButtonList.Add(GameObject.Find("C" + c.ToString() + "S" + s.ToString()).GetComponent<Button>());
            }
            stageButtons[c] = stageButtonList.ToArray();
        }

        ButtonSet();
        GameObject.FindObjectOfType<SceneFader>().transform.SetParent(Camera.main.transform, true);
        GameObject.FindObjectOfType<SceneFader>().transform.localPosition = new Vector3(0, 0, 10);

        GameObject.Find("World2").SetActive(false);
    }
示例#41
0
        public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
        {
            var chapters = searchResults.Where(r => r.ChapterSetId == int.Parse(result.Id)).First();

            if (chapterInfo.Chapters.Count > 0)
            {
                for (int i = 0; i < chapterInfo.Chapters.Count; i++)
                {
                    if (i < chapters.Chapters.Count)
                    {
                        chapterInfo.Chapters[i] = new ChapterEntry()
                        {
                            Name = chapters.Chapters[i].Name,
                            Time = chapterInfo.Chapters[i].Time
                        };
                    }
                    else Trace.WriteLine("Chapter was ignored because it doesn't fit in current chapter set.");
                }
            }
            else
            {
                chapterInfo.Chapters = chapters.Chapters;
            }
        }
示例#42
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "XML files (*.xml)|*.xml";
            DialogResult dr = ofd.ShowDialog(this);
            if (dr == DialogResult.OK)
            {
                // Now we need to verify the xml data.
                Stream file = ofd.OpenFile();
                ChapterInfo[] chapters = ParseXMLChapterInfo(file);
                file.Close();

                if (chapters.Length == 0)
                {
                    // If the file is not valid...
                    // Display error message.
                    MessageBox.Show(this, "There were no valid chapter found in the selected file.");
                    return;
                }
                else
                {
                    // If the file is good...
                    // Are there any chapters currently in the window?
                    if (chapterCount != 0)
                    {
                        // Yes, ask user if they would like to save.
                        string result = PromptDialog.Show(
                            "Data Exists",
                            "Data is already populated in the table. What would you like to do?",
                            new string[] { "Discard", "Save", "Merge", "Cancel" });
                        if (result == "Cancel")
                        {
                            return;
                        }
                        if (result == "Save")
                        {
                            if (SaveCurrentChapters() == false)
                                return;
                            ClearAllChapters();
                        }
                        if (result == "Merge")
                        {
                            MergeDialog dlg = new MergeDialog(chapters[0].Title != "", chapters[0].StartTime != "" || chapters[0].Duration != "", chapters[0].UID != "");
                            DialogResult res = dlg.ShowDialog();
                            if (res == DialogResult.Cancel)
                            {
                                return;
                            }
                            else
                            {
                                // Get the current chapter info data.
                                ChapterInfo[] currentChapters = GetCurrentChapters();
                                int numChapters = Math.Max(currentChapters.Length, chapters.Length);
                                ChapterInfo[] newChapters = new ChapterInfo[numChapters];

                                // Find out what needs to be merged...
                                for (int i = 0; i < numChapters; i++)
                                {
                                    if (i < currentChapters.Length)
                                    {
                                        newChapters[i] = new ChapterInfo(currentChapters[i].Title, currentChapters[i].StartTime, currentChapters[i].Duration, currentChapters[i].UID);
                                    }
                                    else
                                    {
                                        newChapters[i] = new ChapterInfo(chapters[i].Title, chapters[i].StartTime, chapters[i].Duration, chapters[i].UID);
                                    }

                                    if (i < chapters.Length)
                                    {
                                        if (dlg.UseTimeStamps == true)
                                        {
                                            newChapters[i].StartTime = chapters[i].StartTime;
                                            newChapters[i].Duration = chapters[i].Duration;
                                        }
                                        if (dlg.UseTitles == true)
                                        {
                                            newChapters[i].Title = chapters[i].Title;
                                        }
                                        if (dlg.UseUIDs == true)
                                        {
                                            newChapters[i].UID = chapters[i].UID;
                                        }
                                    }
                                }

                                ClearAllChapters();
                                AddChapters(newChapters);
                                return;
                            }
                        }
                        if (result == "Discard")
                        {
                            // Clear all chapters from the window.
                            ClearAllChapters();
                        }
                    }

                    // Load the chapters from the new file into the display window.
                    AddChapters(chapters);
                }
            }
        }
示例#43
0
        private ChapterInfo[] ParseXMLChapterInfo(Stream xmlFile)
        {
            try
            {
                ArrayList chapterList = new ArrayList();
                XmlDocument configXml = new XmlDocument();

                configXml.Load(xmlFile);
                XmlNodeList editionUIDList = configXml.DocumentElement.GetElementsByTagName("EditionUID");
                if( editionUIDList != null )
                {
                    EditionUID = editionUIDList[0].InnerText;
                }

                XmlNodeList objectsXml = configXml.DocumentElement.GetElementsByTagName("ChapterAtom");
                foreach (XmlNode node in objectsXml)
                {
                    XmlNodeReader reader = new XmlNodeReader(node);
                    reader.Read();

                    string title = "";
                    string startTime = "";
                    string endTime = "";
                    string uid = "";
                    string duration = "";

                    if (node["ChapterDisplay"] != null)
                    {
                        if (node["ChapterDisplay"]["ChapterString"] != null)
                        {
                            title = node["ChapterDisplay"]["ChapterString"].InnerText;
                            title = title.Replace("&quot;", "\"");
                            title = title.Replace("&lt;", "<");
                            title = title.Replace("&gt;", ">");
                            title = title.Replace("&amp;", "&");
                        }
                    }

                    if (node["ChapterTimeStart"] != null)
                    {
                        startTime = node["ChapterTimeStart"].InnerText;
                    }
                    if (node["ChapterTimeEnd"] != null)
                    {
                        endTime = node["ChapterTimeEnd"].InnerText;
                    }

                    if( node["ChapterUID"] != null )
                        uid = node["ChapterUID"].InnerText;

                    if (startTime != "" || endTime != "")
                    {
                        if (startTime == "")
                        {
                            if (chapterList.Count != 0)
                            {
                                ChapterInfo lastChapter = (ChapterInfo)chapterList[chapterList.Count - 1];
                                TimeSpan lastStart = TimeSpan.Parse(lastChapter.StartTime);
                                TimeSpan lastDuration = TimeSpan.Parse(lastChapter.Duration);
                                TimeSpan lastEnd = lastStart + lastDuration;
                                TimeSpan ts = TimeSpan.Parse(endTime);
                                duration = (ts - lastEnd).ToString();
                            }
                            else
                            {
                                duration = endTime;
                            }
                        }
                        ChapterInfo chInfo = new ChapterInfo(title, startTime, duration, uid);
                        chapterList.Add(chInfo);
                    }
                }

                return (ChapterInfo[])chapterList.ToArray(typeof(ChapterInfo));
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                goto EXIT_ERROR;
            }

            EXIT_ERROR:
            return new ChapterInfo[0]{};
        }
示例#44
0
        public override List<ChapterInfo> GetStreams(string location)
        {
            ChapterInfo pgc = new ChapterInfo();
              List<ChapterEntry> chapters = new List<ChapterEntry>();
              pgc.SourceName = location;
              pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
              pgc.SourceType = "Blu-Ray";
              pgc.Extractor = Application.ProductName + " " + Application.ProductVersion;
              pgc.Title = Path.GetFileNameWithoutExtension(location);

              FileInfo fileInfo = new FileInfo(location);
              byte[] data = File.ReadAllBytes(location);

              string fileType = ASCIIEncoding.ASCII.GetString(data, 0, 8);

              if ((fileType != "MPLS0100" && fileType != "MPLS0200")
            /*|| data[45] != 1*/)
              {
            throw new Exception(string.Format(
            "Playlist {0} has an unknown file type {1}.",
            fileInfo.Name, fileType));
              }

              Debug.WriteLine(string.Format("\tFileType: {0}", fileType));

              List<Clip> chapterClips = GetClips(data);
              pgc.Duration = new TimeSpan((long)(chapterClips.Sum(c => c.Length) * (double)TimeSpan.TicksPerSecond));
              OnStreamDetected(pgc);

              int chaptersIndex =
              ((int)data[12] << 24) +
              ((int)data[13] << 16) +
              ((int)data[14] << 8) +
              ((int)data[15]);

              int chaptersLength =
              ((int)data[chaptersIndex] << 24) +
              ((int)data[chaptersIndex + 1] << 16) +
              ((int)data[chaptersIndex + 2] << 8) +
              ((int)data[chaptersIndex + 3]);

              byte[] chapterData = new byte[chaptersLength];
              Array.Copy(data, chaptersIndex + 4, chapterData, 0, chaptersLength);

              int chapterCount = ((int)chapterData[0] << 8) + chapterData[1];
              int chapterOffset = 2;
              for (int chapterIndex = 0; chapterIndex < chapterCount; chapterIndex++)
              {
            if (chapterData[chapterOffset + 1] == 1)
            {
              int streamFileIndex =
              ((int)chapterData[chapterOffset + 2] << 8) +
              chapterData[chapterOffset + 3];

              Clip streamClip = chapterClips[streamFileIndex];

              long chapterTime =
              ((long)chapterData[chapterOffset + 4] << 24) +
              ((long)chapterData[chapterOffset + 5] << 16) +
              ((long)chapterData[chapterOffset + 6] << 8) +
              ((long)chapterData[chapterOffset + 7]);

              double chapterSeconds = (double)chapterTime / 45000D;
              double relativeSeconds = chapterSeconds - streamClip.TimeIn + streamClip.RelativeTimeIn;
              chapters.Add(new ChapterEntry()
              {
            Name = string.Empty,
            Time = new TimeSpan((long)(relativeSeconds * (double)TimeSpan.TicksPerSecond))
              });
            }
            chapterOffset += 14;
              }
              pgc.Chapters = chapters;

              //TODO: get real FPS
              pgc.FramesPerSecond = Settings.Default.DefaultFps;

              OnChaptersLoaded(pgc);
              OnExtractionComplete();
              return new List<ChapterInfo>() { pgc };
        }
        public override StoryInfo RequestInfo(string storyUrl)
        {
            var html = NetworkHelper.GetHtml(storyUrl);

            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            var nameNode = storyUrl.Substring(storyUrl.LastIndexOf("/") + 1);
            nameNode = nameNode.Substring(0, nameNode.LastIndexOf(".htm")).Replace("_", " ");

            StoryInfo info = new StoryInfo()
            {
                Url = storyUrl,
                Name = nameNode
            };

            var volumns = htmlDoc.DocumentNode.SelectNodes("//table[@class=\"snif\"]//tr[position()>2]/td[position()=2]/a");
            if (volumns != null)
            {
                foreach (HtmlNode item in volumns)
                {
                    ChapterInfo chap = new ChapterInfo()
                    {
                        Name = item.InnerText.Trim(),
                        Url = item.Attributes["href"].Value,
                        ChapId = ExtractID(item.InnerText.Trim())
                    };
                    info.Chapters.Add(chap);
                }
            }
            info.Chapters = info.Chapters.OrderBy(p => p.ChapId).ToList();
            return info;
        }
示例#46
0
 public ChapterItem(ChapterInfo a_chapterInfo)
 {
     ChapterInfo = a_chapterInfo;
     Initialize();
 }
示例#47
0
        /// <summary>
        /// Handles data from a drag and drop operation. It is
        /// expected that this will be chapter information from
        /// Barnes & Noble.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string data = (string)e.Data.GetData(typeof(string));
            ChapterInfo[] chapters = ParseDragDropData(data);
            this.Activate();

            if (chapters != null && chapters.Length == 0)
            {
                // If the file is not valid...
                // Display error message
                MessageBox.Show(this, "There were no valid chapter found.");
                return;
            }
            else
            {
                // If the file is good...
                // Are there any chapters currently in the window?
                if (chapterCount != 0)
                {
                    // Yes, ask user if they would like to save.
                    string result = PromptDialog.Show(
                            "Data Exists",
                            "Data is already populated in the table. What would you like to do?",
                            new string[] { "Discard", "Save", "Merge", "Cancel" });
                    if (result == "Cancel")
                    {
                        return;
                    }
                    if (result == "Save")
                    {
                        if (SaveCurrentChapters() == false)
                            return;
                        ClearAllChapters();
                    }
                    if (result == "Merge")
                    {
                        MergeDialog dlg = new MergeDialog(chapters[0].Title != "", chapters[0].StartTime!="" || chapters[0].Duration != "", chapters[0].UID != "");
                        DialogResult res = dlg.ShowDialog();
                        if (res == DialogResult.Cancel)
                        {
                            return;
                        }
                        else
                        {
                            // Get the current chapter info data.
                            ChapterInfo[] currentChapters = GetCurrentChapters();
                            int numChapters = Math.Max(currentChapters.Length, chapters.Length);
                            ChapterInfo[] newChapters = new ChapterInfo[numChapters];

                            // Find out what needs to be merged...
                            for (int i = 0; i < numChapters; i++)
                            {
                                if (i < currentChapters.Length)
                                {
                                    newChapters[i] = new ChapterInfo(currentChapters[i].Title, currentChapters[i].StartTime, currentChapters[i].Duration, currentChapters[i].UID);
                                }
                                else
                                {
                                    newChapters[i] = new ChapterInfo(chapters[i].Title, chapters[i].StartTime, chapters[i].Duration, chapters[i].UID);
                                }

                                if (i < chapters.Length)
                                {
                                    if (dlg.UseTimeStamps == true)
                                    {
                                        newChapters[i].StartTime = chapters[i].StartTime;
                                        newChapters[i].Duration = chapters[i].Duration;
                                    }
                                    if (dlg.UseTitles == true)
                                    {
                                        newChapters[i].Title = chapters[i].Title;
                                    }
                                    if (dlg.UseUIDs == true)
                                    {
                                        newChapters[i].UID = chapters[i].UID;
                                    }
                                }
                            }

                            ClearAllChapters();
                            AddChapters(newChapters);
                            return;
                        }
                    }
                    if (result == "Discard")
                    {
                        // Clear all chapters from the window.
                        ClearAllChapters();
                    }
                }

                // Load the chapters from the new file into the display window.
                AddChapters(chapters);
            }
        }
        public override StoryInfo RequestInfo(string storyUrl)
        {
            var html = NetworkHelper.GetHtml(storyUrl);

            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            var nameNode = htmlDoc.DocumentNode.SelectSingleNode("//div[@class=\"wpm_pag mng_det\"]/h1[position()=1]").InnerText.Trim();

            StoryInfo info = new StoryInfo()
            {
                Url = storyUrl,
                Name = nameNode
            };

            var volumns = htmlDoc.DocumentNode.SelectNodes("//div[@class=\"wpm_pag mng_det\"]/ul[@class=\"lst\"]/li/a");
            if (volumns != null)
            {
                foreach (HtmlNode item in volumns)
                {
                    ChapterInfo chap = new ChapterInfo()
                    {
                        Name = item.Attributes["title"].Value.Trim(),
                        Url = item.Attributes["href"].Value,
                        ChapId = ExtractID(item.Attributes["title"].Value.Trim())
                    };
                    info.Chapters.Add(chap);
                }
            }
            info.Chapters = info.Chapters.OrderBy(p => p.ChapId).ToList();
            return info;
        }
        public override StoryInfo RequestInfo(string storyUrl)
        {
            var html = NetworkHelper.GetHtml(storyUrl);

            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            var nameNode = htmlDoc.DocumentNode.SelectSingleNode("//h2[@id=\"series_title\"]").FirstChild.InnerText.Trim();

            StoryInfo info = new StoryInfo()
            {
                Url = storyUrl,
                Name = nameNode
            };

            var volumns = htmlDoc.DocumentNode.SelectNodes("//div[@id=\"newlist\"]/ul/li/a");
            if (volumns != null)
            {
                foreach (HtmlNode item in volumns)
                {
                    ChapterInfo chap = new ChapterInfo()
                    {
                        Name = item.Descendants("span").First().InnerText.Trim(),
                        Url = item.Attributes["href"].Value
                    };
                    chap.ChapId = ExtractID(chap.Name);
                    info.Chapters.Add(chap);
                }
            }
            info.Chapters = info.Chapters.OrderBy(p => p.ChapId).ToList();
            return info;
        }
    /// <summary>
    ///  修改章描述
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ModifyChapter_Click(object sender, EventArgs e)
    {
        //章NO在前台控件中绑定
        string chapterNO = this.DropDownList4.Text;
        string cdsp=this.TextBox3.Text;
        string chapterdscrip = cdsp.Replace(" ", "");
        //new一个QuestionsManagement对象
        QuestionsManagement editchapter = new QuestionsManagement();
        if ("-1" != chapterNO && "" != chapterNO)
        {
            //根据章NO获得章ID
            int i = editchapter.GetChapterIDBYChapterNO(chapterNO, courseName);
            //根据章NO获得章名
            string check = DropDownList4.SelectedItem.Text;
            //输入框中章名和数据库中章名不同
            if (check != chapterdscrip)
            {
                //new一个ChapterInfo并初始化
                ChapterInfo chapter = new ChapterInfo();
                chapter.IChapterId = i;
                //输入框中章名不为空
                if ("" == chapterdscrip)
                    chapter.StrDescription = check;
                else
                    chapter.StrDescription = chapterdscrip;
                //编辑章
                editchapter.EditChapter(chapter);

                try
                {
                    Directory.Move(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList4.SelectedItem.Text, Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + chapterdscrip);
                }
                catch { }

                /*添加知识点*/
                ProcessKnowledge(CHAPTER, i);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                           "<script>alert('修改章成功!')</script>");

            }
            //输入框中章名和数据库中章名相同
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                       "<script>alert('修改内容与原有内容一致,无需修改!')</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                       "<script>alert('请选择要删去的章!')</script>");
        }
        //刷新viewtree
        TreeView1.Nodes.Clear();
        this.TreeDataBind();
        TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
        TreeView1.ExpandDepth = 1;//控件显示时所展开的层数
        this.DropDownList4.Text = null;
        this.TextBox3.Text = null;

        DropDownList2.Items.Clear();
        DropDownList4.Items.Clear();
        DropDownList5.Items.Clear();
        DropDownList7.Items.Clear();
        DropDownList8.Items.Clear();
        DropDownList2.DataBind();
        DropDownList4.DataBind();
        DropDownList5.DataBind();
        DropDownList7.DataBind();
        DropDownList8.DataBind();
    }
 public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
 {
     ImportFromSearchXml(chapterInfo.Chapters, searchXml, int.Parse(result.Id));
 }
        public override List<SearchResult> Search(ChapterInfo chapterInfo)
        {
            string result = string.Empty;
              using (WebClient wc = new WebClient())
              {
            //NameValueCollection vars = new NameValueCollection();
            //vars.Add("txtTitle", chapterInfo.Title);
            //vars.Add("btnSearch", "Search");
            //wc.UploadValues(uri, "POST", vars);
            wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
            Uri uri = new Uri("http://www.e-home.no/metaservices/search.aspx");
            result = wc.UploadString(uri, "POST",
              //__VIEWSTATE=%2FwEPDwUKLTM3MTkwMDA5NQ9kFgICAQ9kFgICDQ88KwALAGRkg%2BhH%2F3tiaQDjnQncD1sYDdeni%2BA%3D&txtTitle=batman&btnSearch=Search&__EVENTVALIDATION=%2FwEWAwLXiqPdDAL55JyzBAKln%2FPuCgMJnDvHIVAx2tPEYdjNUbwqrR67
            string.Format("__VIEWSTATE=%2FwEPDwUKLTM3MTkwMDA5NQ9kFgICAQ9kFgICDQ88KwALAGRkg%2BhH%2F3tiaQDjnQncD1sYDdeni%2BA%3D&txtTitle={0}&btnSearch=Search&__EVENTVALIDATION=%2FwEWAwLXiqPdDAL55JyzBAKln%2FPuCgMJnDvHIVAx2tPEYdjNUbwqrR67", HttpUtility.UrlEncode(chapterInfo.Title)));
              }
              //__VIEWSTATE=%2FwEPDwUKLTM3MTkwMDA5NQ9kFgICAQ9kFgICDQ88KwALAGRkg%2BhH%2F3tiaQDjnQncD1sYDdeni%2BA%3D&txtTitle=batman&btnSearch=Search&__EVENTVALIDATION=%2FwEWAwLXiqPdDAL55JyzBAKln%2FPuCgMJnDvHIVAx2tPEYdjNUbwqrR67

              Tidy tidy = new Tidy();
              /* Set the options you want */
              tidy.Options.DocType = DocType.Strict;
              //tidy.Options.DropFontTags = true;
              tidy.Options.LogicalEmphasis = true;
              tidy.Options.Xhtml = true;
              tidy.Options.XmlOut = true;
              tidy.Options.MakeClean = true;
              tidy.Options.TidyMark = false;
              tidy.Options.QuoteNbsp = false;
              tidy.Options.NumEntities = true;
              tidy.Options.CharEncoding = CharEncoding.UTF8;
              tidy.Options.FixBackslash = true;
              tidy.Options.FixComments = true;

              TidyMessageCollection tmc = new TidyMessageCollection();
              using (MemoryStream input = new MemoryStream())
              using (MemoryStream output = new MemoryStream())
              {
            byte[] bytes = Encoding.UTF8.GetBytes(result);
            input.Write(bytes, 0, bytes.Length);
            input.Position = 0;
            tidy.Parse(input, output, tmc);
            result = Encoding.UTF8.GetString(output.ToArray());
            if (tmc.Errors > 0) throw new Exception(
              string.Format("{0} HTML Tidy Error(s)" + Environment.NewLine, tmc.Errors)
              + string.Join(Environment.NewLine,
              tmc.Cast<TidyMessage>()
              .Where(m => m.Level == MessageLevel.Error)
              .Select(m => m.ToString()).ToArray()));
            XNamespace ns = "http://www.w3.org/1999/xhtml";
            //parse titles
            XDocument searchXhtml = XDocument.Parse(result);
            Debug.Write(searchXhtml.Descendants(ns + "tr")
              .Where(tr => (tr.Attribute("id") != null && tr.Attribute("id").Value.Length == 17)).Count());

            var titles = searchXhtml.Descendants(ns + "tr")
              .Where(tr => (tr.Attribute("id") != null && tr.Attribute("id").Value.Length == 17))
              .Select(tr => new SearchResult()
              {
            Id = (string)tr.Attribute("id"),
            Name = (string)tr.Elements(ns + "td").First()
              });
            OnSearchComplete();
            return titles.ToList();
              }
        }
 public override void PopulateNames(string hash, ChapterInfo info)
 {
     throw new NotImplementedException();
 }
示例#54
0
        private ChapterInfo[] GetCurrentChapters()
        {
            ArrayList chapterList = new ArrayList();
            for (int count = 0; count < chapterCount; count++)
            {
                ChapterInfo ci = new ChapterInfo(
                    tableLayoutPanel1.GetControlFromPosition(1, count + 1).Text,
                    tableLayoutPanel1.GetControlFromPosition(2, count + 1).Text,
                    tableLayoutPanel1.GetControlFromPosition(3, count + 1).Text,
                    tableLayoutPanel1.GetControlFromPosition(4, count + 1).Text);
                chapterList.Add(ci);
            }

            return (ChapterInfo[])chapterList.ToArray(typeof(ChapterInfo));
        }
示例#55
0
        public override List<ChapterInfo> GetStreams(string location)
        {
            List<ChapterInfo> pgcs = new List<ChapterInfo>();

              ProcessStartInfo psi = new ProcessStartInfo(@"d:\programs\eac3to\eac3to.exe", location);
              psi.CreateNoWindow = true;
              psi.UseShellExecute = false;
              //psi.RedirectStandardError = true;
              psi.RedirectStandardOutput = true;
              psi.WorkingDirectory = Application.StartupPath;
              Process p = Process.Start(psi);
              string output = p.StandardOutput.ReadToEnd();
              p.WaitForExit();

              foreach (Match m in Regex.Matches(output, @"\d\).+:\d\d"))
              {
            string[] data = m.Value.Split(',');

            string sourceFile = Path.Combine(Path.Combine(Path.Combine(
              location, "BDMV"), "PLAYLIST"), data[0].Split(')')[1].Trim());

            ChapterInfo pgc = new ChapterInfo()
            {
              Duration = TimeSpan.Parse(data[data.Length - 1].Trim()),
              SourceName = data[0].Split(')')[0],
              SourceHash = ChapterExtractor.ComputeMD5Sum(sourceFile)
            };
            OnStreamDetected(pgc);
            pgcs.Add(pgc);
              }
              /*
            1) 00001.mpls, 00002.m2ts, 1:34:15
               - h264/AVC, 1080p24 /1.001 (16:9)
               - AC3, Spanish, multi-channel, 48khz
               - DTS Master Audio, English, multi-channel, 48khz

            2) 00027.mpls, 00036.m2ts, 0:24:19
               - h264/AVC, 1080p24 /1.001 (16:9)
               - AC3, English, stereo, 48khz
               */

              foreach (ChapterInfo pgc in pgcs)
              {
            psi.Arguments = location + " " + pgc.SourceName + ")";
            p = Process.Start(psi);
            output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            if (output.Contains("Chapters"))
            {
              if (File.Exists("chapters.txt")) File.Delete("chapters.txt");
              psi.Arguments = location + " " + pgc.SourceName + ") chapters.txt";
              p = Process.Start(psi);
              output = p.StandardOutput.ReadToEnd();
              p.WaitForExit();
              if (!output.Contains("Creating file \"chapters.txt\"...") && !output.Contains("Done!"))
              {
            throw new Exception("Error creating chapters file.");
              }
              TextExtractor extractor = new TextExtractor();
              pgc.Chapters = extractor.GetStreams("chapters.txt")[0].Chapters;
              OnChaptersLoaded(pgc);
            }
              }

              /*
            M2TS, 1 video track, 2 audio tracks, 6 subtitle tracks, 1:34:15
            1: Chapters, 25 chapters
            2: h264/AVC, 1080p24 /1.001 (16:9)
            3: AC3, Spanish, 5.1 channels, 448kbps, 48khz, dialnorm: -27dB
            4: DTS Master Audio, English, 5.1 channels, 24 bits, 48khz
               (core: DTS, 5.1 channels, 24 bits, 1509kbps, 48khz)
            5: Subtitle (PGS), English
            6: Subtitle (PGS), Spanish
            7: Subtitle (PGS), Spanish
            8: Subtitle (PGS), French
            9: Subtitle (PGS), Chinese
            10: Subtitle (PGS), Korean
               */

              OnExtractionComplete();
              return pgcs;
        }
示例#56
0
        public override void Upload(ChapterInfo chapterInfo)
        {
            try
            {
                string url = "{0}/chapters/";
                url = string.Format(url, Settings.Default.DatabaseSite);

                using (WebClient client = new WebClient())
                {
                    client.Headers["User-Agent"] = Application.ProductName + " " + Application.ProductVersion;
                    client.Headers["ApiKey"] = Settings.Default.DatabaseApiKey;
                    client.UploadString(url, "POST", chapterInfo.ToXElement().ToString());
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
示例#57
0
 private void AddChapters(ChapterInfo[] Chapters)
 {
     tableLayoutPanel1.SuspendLayout();
     foreach (ChapterInfo chInfo in Chapters)
     {
         AddChapter(chInfo);
     }
     tableLayoutPanel1.ResumeLayout();
 }
示例#58
0
        /// <summary>
        /// Adds a chapter to the list
        /// </summary>
        /// <param name="title"></param>
        /// <param name="startTime"></param>
        /// <param name="duration"></param>
        /// <param name="uid"></param>
        private void AddChapter(ChapterInfo chInfo)
        {
            if (chInfo == null)
                chInfo = new ChapterInfo();

            if( chInfo.UID == "" )
            {
                Random random = new Random();
                chInfo.UID = random.Next().ToString();
            }

            chapterCount++;
            if (tableLayoutPanel1.RowCount <= (chapterCount+1))
            {
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));
                tableLayoutPanel1.RowCount++;
            }

            if (chapterCount > 1)
            {
                if( tableLayoutPanel1.GetControlFromPosition(3, chapterCount - 1).Text == "" )
                {
                    if (chInfo.StartTime != "")
                    {
                        Trace.WriteLine(tableLayoutPanel1.GetControlFromPosition(2, chapterCount - 1).Text);
                        TimeSpan tsTest = TimeSpan.Parse("00:00:00.0000");
                        TimeSpan tsStart = TimeSpan.Parse(tableLayoutPanel1.GetControlFromPosition(2, chapterCount - 1).Text);
                        TimeSpan tsNext = TimeSpan.Parse(chInfo.StartTime);
                        tableLayoutPanel1.GetControlFromPosition(3, chapterCount - 1).Text = (tsNext - tsStart).ToString() + ".000000";
                    }
                }
            }

            if (chInfo.StartTime == null || chInfo.StartTime == "")
            {
                if (chapterCount > 1 && tableLayoutPanel1.GetControlFromPosition(3, chapterCount - 1).Text != "")
                {
                    Trace.WriteLine(tableLayoutPanel1.GetControlFromPosition(2, chapterCount - 1).Text);
                    TimeSpan tsStart = TimeSpan.Parse(tableLayoutPanel1.GetControlFromPosition(2, chapterCount - 1).Text);
                    Trace.WriteLine(tableLayoutPanel1.GetControlFromPosition(3, chapterCount - 1).Text);
                    TimeSpan tsDuration = TimeSpan.Parse(tableLayoutPanel1.GetControlFromPosition(3, chapterCount - 1).Text);
                    chInfo.StartTime = (tsStart + tsDuration).ToString() + ".000000";
                }
                else
                {
                    chInfo.StartTime = "00:00:00.000000";
                }
            }

            TextBox[] tbs = new TextBox[1];
            for( int i=0; i<1; i++ )
            {
                tbs[i] = new TextBox();
                tbs[i].Font = new Font(label1.Font.FontFamily, 10, FontStyle.Regular);
                tbs[i].Dock = DockStyle.Fill;
                tbs[i].TextAlign = HorizontalAlignment.Center;
            }

            tbs[0].Text = chInfo.Title;

            TextBox[] tes = new TimeEdit[2];
            for (int i = 0; i < 2; i++)
            {
                tes[i] = new TimeEdit();
                tes[i].Font = new Font(label1.Font.FontFamily, 10, FontStyle.Regular);
                tes[i].Dock = DockStyle.Fill;
                tes[i].TextAlign = HorizontalAlignment.Center;
            }
            tes[1].ReadOnly = true;
            tes[0].Text = chInfo.StartTime;
            tes[1].Text = chInfo.Duration;

            Label[] lbls = new Label[2];
            for( int i=0; i<2; i++ )
            {
                lbls[i] = new Label();
                lbls[i].Font = new Font(label1.Font.FontFamily, 10, FontStyle.Regular);
                lbls[i].Dock = DockStyle.Fill;
                lbls[i].TextAlign = ContentAlignment.MiddleCenter;
            }
            lbls[0].Text = chapterCount.ToString() + ".";
            lbls[1].Text = chInfo.UID;

            tableLayoutPanel1.Controls.Add(lbls[0], 0, chapterCount);
            tableLayoutPanel1.Controls.Add(tbs[0], 1, chapterCount);
            tableLayoutPanel1.Controls.Add(tes[0], 2, chapterCount);
            tableLayoutPanel1.Controls.Add(tes[1], 3, chapterCount);
            tableLayoutPanel1.Controls.Add(lbls[1], 4, chapterCount);
        }
    /// <summary>
    /// 添加章
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddChapter_Click(object sender, EventArgs e)
    {
        //n = 0;

        QuestionsManagement addchapter = new QuestionsManagement();

        //得到章NO
        bool row = addchapter.GetRowChapterNO(this.DropDownList1.Text, courseName);
        string cNO = this.DropDownList1.Text;
        string ds = this.TextBox1.Text;
        string cds = ds.Replace(" ","");
        ChapterInfo chapter = new ChapterInfo();
        chapter.StrChapterNO = cNO;
        chapter.StrDescription = cds;
        //章的描述不为空
        if ("" != cds)
        {
                //章序号不为-1
                if ("-1" != cNO)
                {
                    //要添加的章NO在数据库中不存在
                    if (false == row)
                    {
                        bool repeat1 = addchapter.GetChapterbyDescriptions(cds, courseName);
                        //章表中不存在要添加章的描述
                        if (false == repeat1)
                        {
                            addchapter.AddChapter(chapter, courseName);
                            int i = addchapter.GetChapterIDBYChapterNO(cNO, courseName);
                            //数据库中存在添加的章,则成功添加
                            if (i > 0)
                            {
                                Directory.CreateDirectory(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + cds);
                                File.CreateText(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + cds + @"/StructGraph.txt");
                                File.CreateText(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + cds + @"/Summary.txt");

                                /*添加知识点*/
                                ProcessKnowledge(CHAPTER, i);

                                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                               "<script>alert('添加章成功!')</script>");

                            }
                            //数据库中不存在该章,添加失败
                            else
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                                  "<script>alert('添加章失败!')</script>");
                            }
                        }

                        // 章的表中存在该章的描述
                        else
                        {

                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                                        "<script>alert('该章标题已经存在请重新添加!')</script>");
                        }
                    }
                    //该章NO在章表中已经存在
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                           "<script>alert('该章已经存在无需添加!')</script>");
                    }
                }
                //选择的章NO为空
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                          "<script>alert('请选择章!')</script>");

                }
            }
            //章的标题描述为空
        else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                         "<script>alert('章标题为空,请添加章标题!')</script>");

            }
        //刷新viewtree
            TreeView1.Nodes.Clear();
            this.TreeDataBind();
            TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
            TreeView1.ExpandDepth = 1;//控件显示时所展开的层数
            this.DropDownList1.Text = null;
            this.TextBox1.Text = null;

            DropDownList2.Items.Clear();
            DropDownList4.Items.Clear();
            DropDownList5.Items.Clear();
            DropDownList7.Items.Clear();
            DropDownList8.Items.Clear();
            DropDownList2.DataBind();
            DropDownList4.DataBind();
            DropDownList5.DataBind();
            DropDownList7.DataBind();
            DropDownList8.DataBind();

            KnowledgeCollection.Value = "";
    }
 public override void Upload(ChapterInfo chapterInfo)
 {
     throw new NotImplementedException();
 }