using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Biff8Excel.Interfaces;

namespace Biff8Excel.Records
{
    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
    struct RecordPrintGridLines
    {
        public ushort opcode;
        public ushort length;
        public ushort print;
    }

    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
    struct RecordGridSet
    {
        public ushort opcode;
        public ushort length;
        public ushort printchanged;
    }

    internal class PrintGridLines : IRecords
    {
        RecordPrintGridLines printgridlines;
        RecordGridSet gridset;

        public PrintGridLines()
        {
            printgridlines.opcode = 0x2B;
            printgridlines.length = 0x2;

            gridset.opcode = 0x82;
            gridset.length = 0x2;
            gridset.printchanged = 0x1;
        }

        public ushort PrintLines
        {
            set 
            { 
                printgridlines.print = value; 
            }
        }

        #region IRecords ��Ա

        public byte[] GetByte()
        {
            byte[] b = new byte[12];
            Globals.GetStructToBytes(printgridlines).CopyTo(b, 0);
            
            // Create a GRIDSET Record
            Globals.GetStructToBytes(gridset).CopyTo(b, 6);
            //b[6] = 0x82;
            //b[8] = 0x2;
            //b[10] = 0x1;

            return b;
        }

        #endregion
    }
}