zhao
2021-06-24 02ca96debc6056275d58e55d97f7885a195542d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
 
namespace HH.WMS.Utils.ExcelLibrary.BinaryDrawingFormat
{
    public partial class EscherRecord
    {
        public UInt16 Prop;
        public UInt16 Type;
        public UInt32 Size;
        public byte[] Data;
 
        public EscherRecord() { }
 
        public EscherRecord(EscherRecord record)
        {
            Prop = record.Prop;
            Type = record.Type;
            Size = record.Size;
            Data = record.Data;
        }
 
        /// <summary>
        /// Instance
        /// </summary>
        public UInt16 Instance
        {
            get { return (UInt16)(Prop >> 4); }
            set { Prop = (UInt16)(Version | (value << 4)); }
        }
 
        /// <summary>
        /// Version
        /// </summary>
        public byte Version
        {
            get { return (byte)(Prop & 0xF); }
            set { Prop = (UInt16)(Prop | (value & 0xF)); }
        }
 
 
        public virtual void Decode()
        {
        }
 
        public virtual void Encode()
        {
        }
 
        public static EscherRecord ReadBase(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            EscherRecord record = new EscherRecord();
            record.Prop = reader.ReadUInt16();
            record.Type = reader.ReadUInt16();
            record.Size = reader.ReadUInt32();
            record.Data = reader.ReadBytes((int)record.Size);
            return record;
        }
 
        //ushort inst = 0;
        public void Write(BinaryWriter writer)
        {
            if (this is MsofbtContainer)
            {
                Version = 0xF;
            }
            else
            {
                //Instance = inst++;
            }
            writer.Write(this.Prop);
            writer.Write(this.Type);
            writer.Write(this.Size);
            if (this.Size > 0)
            {
                writer.Write(this.Data);
            }
        }
    }
}