示例#1
0
文件: Entry.cs 项目: giovanism/GMD
        public DisplayEntry(Entry entry)
        {
            Dict entryDict = new ManageDicts().Dicts.Where(p => p.DictID == entry.DictId).FirstOrDefault();

            if (entryDict != null)
            {
                DictId         = entryDict.DictID;
                BookName       = entryDict.BookName;
                WordStr        = entry.WordStr;
                wordDataOffset = entry.wordDataOffset;
                wordDataSize   = entry.wordDataSize;

                string dictPath = entryDict.dictPath;

                using (FileStream fileStream = new FileStream(dictPath, FileMode.Open, FileAccess.Read))
                {
                    byte[] buffer     = new byte[entry.wordDataSize]; // create buffer
                    int    seekOffset = checked ((int)UInt64.Parse(entry.wordDataOffset));
                    int    length     = checked ((int)entry.wordDataSize);

                    fileStream.Seek(seekOffset, SeekOrigin.Begin);
                    fileStream.Read(buffer, 0, length);

                    string charString = DataConversion.GetString(buffer);

                    Definition = new List <Paragraph>();
                    Paragraph[] paragraphs = DataConversion.FormatDefinition(charString, entryDict.sameTypeSequence);

                    foreach (Paragraph paragraph in paragraphs)
                    {
                        Definition.Add(paragraph);
                    }
                }
            }
        }