Пример #1
0
        private void CheckSerializeSimple()
        {
            EscherOptRecord r = new EscherOptRecord();

            r.Options  = (short)0x0033;
            r.RecordId = unchecked ((short)0xF00B);
            EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1);
            EscherRGBProperty  prop2 = new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000009);
            EscherRGBProperty  prop3 = new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 0x08000040);

            r.AddEscherProperty(prop1);
            r.AddEscherProperty(prop2);
            r.AddEscherProperty(prop3);

            byte[] data         = new byte[26];
            int    bytesWritten = r.Serialize(0, data);
            string dataStr      = "[33, 00, " +
                                  "0B, F0, " +
                                  "12, 00, 00, 00, " +
                                  "BF, 00, 01, 00, 00, 00, " +
                                  "81, 01, 09, 00, 00, 08, " +
                                  "C0, 01, 40, 00, 00, 08]";

            Assert.AreEqual(dataStr, HexDump.ToHex(data));
            Assert.AreEqual(26, bytesWritten);
        }
Пример #2
0
        private void CheckFillFieldsSimple()
        {
            string dataStr = "33 00 " +       // options
                             "0B F0 " +       // recordid
                             "12 00 00 00 " + // remaining bytes
                             "BF 00 08 00 08 00 " +
                             "81 01 09 00 00 08 " +
                             "C0 01 40 00 00 08";

            EscherOptRecord r = new EscherOptRecord();

            r.FillFields(HexRead.ReadFromString(dataStr), new DefaultEscherRecordFactory());
            Assert.AreEqual((short)0x0033, r.Options);
            Assert.AreEqual(unchecked ((short)0xF00B), r.RecordId);
            Assert.AreEqual(3, r.EscherProperties.Count);
            EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296);
            EscherRGBProperty  prop2 = new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000009);
            EscherRGBProperty  prop3 = new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 0x08000040);

            Assert.AreEqual(prop1, r.GetEscherProperty(0));
            Assert.AreEqual(prop2, r.GetEscherProperty(1));
            Assert.AreEqual(prop3, r.GetEscherProperty(2));
        }