Ejemplo n.º 1
0
        public bool Load(RSFileReader br, bool fullRead)
        {
            if (!br.ReadHeader(p_FileHeader))
            {
                return(false);
            }

            Clear();
            byte tag;

            while ((tag = br.ReadByte()) != 0)
            {
                switch (tag)
                {
                case 10:
                    string key   = br.ReadString();
                    string value = br.ReadString();
                    Properties.Add(key, value);
                    if (key.Equals("TotalWork"))
                    {
                        long la;
                        if (long.TryParse(value, out la))
                        {
                            WorkTime.SetTotalWorkTime(la);
                        }
                    }
                    break;

                case 100:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedText rt = new MNReferencedText();
                    rt.Load(br);
                    Texts.Add(rt);
                    break;

                case 101:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedImage ri = new MNReferencedImage();
                    ri.Load(br);
                    Images.Add(ri);
                    break;

                case 102:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedSound rs = new MNReferencedSound();
                    rs.Load(br);
                    Sounds.Add(rs);
                    break;

                case 103:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedAudioText ra = new MNReferencedAudioText();
                    ra.Load(br);
                    AudioTexts.Add(ra);
                    break;

                case 104:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedStyle rsa = new MNReferencedStyle();
                    rsa.Load(br);
                    Styles.Add(rsa);
                    break;

                default:
                    LoadMessage = string.Format("Unknown tag {0} at position {1} in the file.", tag, br.Position);
                    return(false);
                }
            }

            Modified = false;
            return(true);
        }
Ejemplo n.º 2
0
        public void Load(RSFileReader br)
        {
            if (!br.ReadHeader(p_fileHeader))
            {
                throw new Exception("Invalid header for book file");
            }

            Version = 1;
            byte b;

            while ((b = br.ReadByte()) != 0)
            {
                switch (b)
                {
                case 5:
                    sizeOfInt = br.ReadByte();
                    break;

                case 10:
                    BookTitle = br.ReadString();
                    break;

                case 11:
                    BookCode = br.ReadString();
                    break;

                case 12:
                    BookAuthor = br.ReadString();
                    break;

                case 13:
                    BookPublisher = br.ReadString();
                    break;

                case 14:
                    BookCopyright = br.ReadString();
                    break;

                case 15:
                    BookCollection = br.ReadString();
                    break;

                case 16:
                    BookColor = br.ReadColor();
                    break;

                case 17:
                    StartPage = br.ReadString();
                    break;

                case 18:
                    BookImageRef = new MNReferencedImage();
                    BookImageRef.Load(br);
                    break;

                case 19:
                    Evaluation = (MNEvaluationType)br.ReadInt32();
                    break;

                case 20:
                    LastTimeSave = br.ReadString();
                    break;

                case 21:
                    WorkTime.SetTotalWorkTime(br.ReadInt64());
                    break;

                case 22:
                    BookPriority = br.ReadInt32();
                    break;

                case 23:
                    HomePage = br.ReadString();
                    break;

                case 24:
                    Version = br.ReadInt32();
                    break;

                case 25:
                    DefaultFontSize = br.ReadInt32();
                    break;

                case 26:
                    DefaultFontName = MNFontName.IntToString(br.ReadInt32());
                    break;

                case 27:
                    DefaultFontName = br.ReadString();
                    break;
                }
            }
        }