Example #1
0
 private void setDefaultValues()
 {
     this.cvBack  = 0;
     this.cvFore  = 0;
     this.icoBack = Global.ColorIdentifier.auto;
     this.icoFore = Global.ColorIdentifier.auto;
     this.ipat    = ShadingPattern.Automatic;
 }
Example #2
0
 /// <summary>
 /// Parses the bytes to retrieve a ShadingDescriptor.
 /// </summary>
 /// <param name="bytes">The bytes</param>
 public ShadingDescriptor(byte[] bytes)
 {
     if (bytes.Length == 10)
     {
         //it's a Word 2000/2003 descriptor
         this.cvFore = Utils.BitArrayToUInt32(new BitArray(new byte[] { bytes[2], bytes[1], bytes[0] }));
         this.cvBack = Utils.BitArrayToUInt32(new BitArray(new byte[] { bytes[6], bytes[5], bytes[4] }));
         this.ipat   = (ShadingPattern)System.BitConverter.ToUInt16(bytes, 8);
     }
     else if (bytes.Length == 2)
     {
         //it's a Word 97 SPRM
         short val = System.BitConverter.ToInt16(bytes, 0);
         this.icoFore = (Global.ColorIdentifier)((val << 11) >> 11);
         this.icoBack = (Global.ColorIdentifier)((val << 2) >> 7);
         this.ipat    = (ShadingPattern)(val >> 10);
     }
     else
     {
         throw new ByteParseException("Cannot parse the struct SHD, the length of the struct doesn't match");
     }
 }
Example #3
0
        /// <summary>
        /// Parses the byte for a BRC
        /// </summary>
        /// <param name="bytes"></param>
        public BorderCode(byte[] bytes)
        {
            if (Utils.ArraySum(bytes) == bytes.Length * 255)
            {
                this.fNil = true;
            }
            else if (bytes.Length == 8)
            {
                //it's a border code of Word 2000/2003
                this.cv  = System.BitConverter.ToInt32(bytes, 0);
                this.ico = Global.ColorIdentifier.auto;

                this.dptLineWidth = bytes[4];
                this.brcType      = bytes[5];

                short val = System.BitConverter.ToInt16(bytes, 6);
                this.dptSpace = val & 0x001F;

                //not sure if this is correct, the values from the spec are definitly wrong:
                this.fShadow = Utils.BitmaskToBool(val, 0x20);
                this.fFrame  = Utils.BitmaskToBool(val, 0x40);
            }
            else if (bytes.Length == 4)
            {
                //it's a border code of Word 97
                ushort val = System.BitConverter.ToUInt16(bytes, 0);
                this.dptLineWidth = (byte)(val & 0x00FF);
                this.brcType      = (byte)((val & 0xFF00) >> 8);
                val           = System.BitConverter.ToUInt16(bytes, 2);
                this.ico      = (Global.ColorIdentifier)(val & 0x00FF);
                this.dptSpace = (val & 0x1F00) >> 8;
            }
            else
            {
                throw new ByteParseException("Cannot parse the struct BRC, the length of the struct doesn't match");
            }
        }