当前位置: 首页>>代码示例>>C#>>正文


C# Record.GetDataReader方法代码示例

本文整理汇总了C#中Record.GetDataReader方法的典型用法代码示例。如果您正苦于以下问题:C# Record.GetDataReader方法的具体用法?C# Record.GetDataReader怎么用?C# Record.GetDataReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Record的用法示例。


在下文中一共展示了Record.GetDataReader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public override void Init(Record record)
        {
            base.Init (record);

            BinaryFlashReader reader = record.GetDataReader();
            if (record.Tag == Flash.Tags.RemoveObject2)
                this.Depth = (int)reader.ReadUInt16();
            else
                throw new Exception("Placement version not implemented");
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:10,代码来源:Remove.cs

示例2: Init

        public override void Init(Record record)
        {
            base.Init (record);

            BinaryFlashReader reader = record.GetDataReader();

            if (this.Tag == Flash.Tags.PlaceObject)
            {
                this.CharacterId = reader.ReadUInt16();
                this.Depth = reader.ReadUInt16();
                this.Matrix = new Basic.Matrix(reader);
                this.ColorMatrix = new Basic.ColorMatrix(reader, false); //reader.ReadColorMatrix();
            }
            else
            {
                int nPlaceInfo = reader.ReadByte();

                bool bPlaceFlagHasClipActions = (nPlaceInfo & 128)>0;
                bool bPlaceFlagHasClipDepth = (nPlaceInfo & 64)>0;
                bool bPlaceFlagHasName = (nPlaceInfo & 32)>0;
                bool bPlaceFlagHasRatio = (nPlaceInfo & 16)>0;
                bool bPlaceFlagHasColorTransform = (nPlaceInfo & 8)>0;
                bool bPlaceFlagHasMatrix = (nPlaceInfo & 4)>0;
                bool bPlaceFlagHasCharacter = (nPlaceInfo & 2)>0;
                bool bPlaceFlagMove = (nPlaceInfo & 1)>0;

                this.Depth = reader.ReadUInt16();
                if (bPlaceFlagHasCharacter)
                    this.CharacterId = reader.ReadUInt16();
                if (bPlaceFlagHasMatrix)
                    this.Matrix = new Basic.Matrix(reader);
                if (bPlaceFlagHasColorTransform)
                    this.ColorMatrix = new Basic.ColorMatrix(reader, true);
                if (bPlaceFlagHasRatio)
                    this.Ratio = reader.ReadUInt16();
                if (bPlaceFlagHasName)
                    this.Name = reader.ReadPascalString(); //readNullString
                if (bPlaceFlagHasClipDepth)
                    this.ClipDepth = reader.ReadUInt16();
                if (bPlaceFlagHasClipActions)
                {
                    //TODO:!!!
                }

                bool bFilters = false;
                bool bBlend = false;
                bool bCache = false;
                if (this.Tag == Flash.Tags.PlaceObject3)
                {
                    nPlaceInfo = reader.ReadByte();
                    bFilters = (nPlaceInfo&1)>0; //TODO: reverse order? 128,64,32?
                    bBlend = (nPlaceInfo&2)>0; //TODO: implement blend&cache
                    bCache = (nPlaceInfo&4)>0;
                }
                if (bFilters)
                {
                    byte nNumFilters = reader.ReadByte();
                    for (int i=0; i<nNumFilters; i++)
                    {
                        byte filterId = reader.ReadByte();
                        Filter.Base filter = null;
                        switch (filterId)
                        {
                            case 0:
                                filter = new Filter.DropShadow();
                                break;
                            case 1:
                                filter = new Filter.Blue();
                                break;
                            case 2:
                                filter = new Filter.Glow();
                                break;
                            case 3:
                                filter = new Filter.Bevel();
                                break;
                            case 4:
                                filter = new Filter.GradientGlow();
                                break;
                            case 6:
                                filter = new Filter.AdjustColor();
                                break;
                            case 7:
                                filter = new Filter.GradientBevel();
                                break;
                        }
                    }
                }
            }
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:89,代码来源:Placement.cs

示例3: Init

        public override void Init(Record record)
        {
            base.Init (record);

            BinaryFlashReader reader = record.GetDataReader();
            //TODO: Is this a correct assumption about DefineShape5?
            this.UseAlpha = (this.Tag==Flash.Tags.DefineShape3 || this.Tag==Flash.Tags.DefineShape5)?true:false;
            this._extended = (this.Tag==Flash.Tags.DefineShape)?false:true;
            this._hasX = (this.Tag==Flash.Tags.DefineShape4 || this.Tag==Flash.Tags.DefineShape5)?true:false;
            this.Id = reader.ReadUInt16();
            this.Bounds = reader.ReadRect();

            if (this.Tag==Flash.Tags.DefineShape4)
                reader.ReadRect(); //TODO: what's this rect for?

            this.ReadShapeWithStyle(reader);

            this.InitDone();
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:19,代码来源:Shape.cs

示例4: Init

        public override void Init(Record record)
        {
            base.Init (record);

            BinaryFlashReader reader = record.GetDataReader();
            this.Id = reader.ReadUInt16();

            Bitmap bmp = null;
            byte[] alphaData = null;

            if (record.Tag == Flash.Tags.DefineBits) //Jpeg with separate jpeg table
            {
                ushort start = reader.ReadUInt16();
                if (start != 0xd8ff)
                    throw new Exception("JPEG start error");

                MemoryStream stream = new MemoryStream();
                BinaryWriter writer = new BinaryWriter(stream);
                writer.Write(this._jpegTables);
                writer.Write(reader.ReadBytes((int)record.TagLength));
                this._jpegTables = null;
                writer.Close();
                stream.Close();
                byte[] data = stream.ToArray();

                stream = new MemoryStream(data);
                bmp = new Bitmap(stream);
                stream.Close();
            }
            else if (record.Tag == Flash.Tags.DefineBitsJPEG2) //Jpeg with included jpeg table
            {
                byte[] data = reader.ReadBytes((int)record.TagLength);
                MemoryStream stream = new MemoryStream(data);
                bmp = new Bitmap(stream);
                stream.Close();
            }
            else if (record.Tag == Flash.Tags.DefineBitsJPEG3) //Jpeg with alpha
            {
                uint alphaDataOffset = reader.ReadUInt32();
                byte[] data = reader.ReadBytes((int)alphaDataOffset);
                MemoryStream stream = new MemoryStream(data);
                bmp = new Bitmap(stream);
                stream.Close();
                byte[] alphaDataZCompressed = reader.ReadBytes((int)reader.BytesToEnd);
                //TODO: unpack zlib compressed data
            }
            else
            {
                //ZLib-compressed
                bool UseAlpha = (record.Tag==Flash.Tags.DefineBitsLossless2?true:false);
                byte format = reader.ReadByte();
                ushort width = reader.ReadUInt16();
                ushort height = reader.ReadUInt16();
                int stride = ((width+3)/4)*4;

                int numPaletteEntries = 0;
                long size = 0;
                int bpp = 1;
                int bytesPerPaletteEntry = 3;

                if (format==3)
                {
                    numPaletteEntries = reader.ReadByte();
                    if (UseAlpha)
                        bytesPerPaletteEntry = 4;
                    size = stride*height + bytesPerPaletteEntry*numPaletteEntries;
                }
                else
                {
                    if (format==4)
                        bpp = 2;
                    else if (format==5)
                        bpp = 3;
                    size = bpp*width*height;
                }

                size+=248+1024; //Don't know why...

                byte[] compressed = reader.ReadBytes((int)reader.BytesToEnd);
                byte[] decompressed = null; //zlib.decompress(compressed);

                if (format==3)
                {
                    Color[] palette = new Color[numPaletteEntries];
                    for (int i=0; i<numPaletteEntries;i++)
                    {
                        Color clr = Color.White;
                        int ptr = i*bytesPerPaletteEntry;
                        if (bytesPerPaletteEntry==3)
                            clr = Color.FromArgb(decompressed[ptr],decompressed[ptr+1],decompressed[ptr+2]);
                        else
                            clr = Color.FromArgb(decompressed[ptr],decompressed[ptr+1],decompressed[ptr+2],decompressed[ptr+3]);
                        palette[i] = clr;
                    }
                    int pixelPtr = numPaletteEntries*bytesPerPaletteEntry;
                    bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    //TODO:
                }
                else
                {
//.........这里部分代码省略.........
开发者ID:timdetering,项目名称:Endogine,代码行数:101,代码来源:Image.cs

示例5: Init

        public override void Init(Record record)
        {
            base.Init (record);

            BinaryFlashReader reader = record.GetDataReader();
            if (this.Tag == Flash.Tags.DoInitAction)
                this.Sprite = reader.ReadUInt16();

            this.Actions = new ArrayList();
            while (true)
            {
                ActionTypes actionType = (ActionTypes)reader.ReadByte();
                //int nDataLength = 0;
                switch (actionType)
                {
                    case ActionTypes.StoreRegister:
                        byte register = reader.ReadByte();
                        break;
                    case ActionTypes.WaitForFrame_Dyn:
                        byte skip = reader.ReadByte();
                        break;
                    case ActionTypes.GetURL2:
                        byte method = reader.ReadByte();
                        break;
                    case ActionTypes.GotoFrame:
                        ushort frameNo = reader.ReadUInt16();
                        break;
                    case ActionTypes.BranchAlways:
                        short offset = reader.ReadInt16();
                        break;
                    case ActionTypes.BranchIfTrue:
                        short offsetX = reader.ReadInt16();
                        break;
                    case ActionTypes.GotoExpression:
                        //TODO: error in documentation. Says 2 bytes but declares a byte...
                        byte play = reader.ReadByte();
                        break;
                    case ActionTypes.WaitForFrame:
                        ushort frame = reader.ReadUInt16();
                        byte skipX = reader.ReadByte();
                        break;

                    case ActionTypes.GetURL:
                        string URL = reader.ReadPascalString();
                        string Target = reader.ReadPascalString();
                        break;
                    case ActionTypes.DeclareDictionary:
                        int nCount = reader.ReadUInt16();
                        string[] Dictionary = new string[nCount];
                        for (int i = 0; i < nCount; i++)
                            reader.ReadPascalString();
                        break;
                    case ActionTypes.SetTarget:
                        string TargetX = reader.ReadPascalString();
                        break;
                    case ActionTypes.GotoLabel:
                        string Label = reader.ReadPascalString();
                        break;
                    case ActionTypes.DeclareFunction_V7:
                        string Name = reader.ReadPascalString();
                        ushort argCount = reader.ReadUInt16();
                        byte regCount = reader.ReadByte();
                        //TODO: 7 bits?
                        ushort declareFunction2_reserved = reader.ReadUInt16(); //:7
                        //TODO: booleans?
                        ushort preloadGlobal = reader.ReadUInt16(); //:1
                        ushort preloadParent = reader.ReadUInt16(); //:1
                        ushort preloadRoot = reader.ReadUInt16(); //:1
                        ushort suppressSuper = reader.ReadUInt16(); //:1
                        ushort preloadSuper = reader.ReadUInt16(); //:1
                        ushort suppressArguments = reader.ReadUInt16(); //:1
                        ushort preloadArguments = reader.ReadUInt16(); //:1
                        ushort suppressThis = reader.ReadUInt16(); //:1
                        ushort preloadThis = reader.ReadUInt16(); //:1
                        //ArrayList parameters = new ArrayList();
                        for (int i = 0; i <argCount; i++)
                        {
                            byte paramRegister = reader.ReadByte();
                            string paramName = reader.ReadPascalString();
                        }
                        ushort functionLength = reader.ReadUInt16();
                        break;
                    case ActionTypes.Try:
                        //TODO: 5 bits and 1-bit bools?
                        byte tryReserved = reader.ReadByte(); //: 5;
                        byte catchInRegister = reader.ReadByte();//: 1;
                        byte useFinally = reader.ReadByte();//: 1;
                        byte useCatch = reader.ReadByte();//: 1;
                        ushort trySize = reader.ReadUInt16();
                        ushort catchSize = reader.ReadUInt16();
                        ushort finallySize = reader.ReadUInt16();
                        string catchName;
                        byte catchRegister;
                        if (catchInRegister == 0)
                            catchName = reader.ReadPascalString();
                        else
                            catchRegister = reader.ReadByte();
                        break;
                    case ActionTypes.PushData:
                        byte type = reader.ReadByte();
//.........这里部分代码省略.........
开发者ID:timdetering,项目名称:Endogine,代码行数:101,代码来源:DoAnAction.cs

示例6: Init

        public override void Init(Record record)
        {
            base.CopyRecord (record); //wheww, this is ugly.

            BinaryFlashReader reader = record.GetDataReader();
            //I don't need these (start/end bounds):
            this.Id = reader.ReadUInt16();
            reader.ReadRect();
            reader.ReadRect();

            // Offset to EndEdges
            uint offset = reader.ReadUInt32();
            int posForShape2 = (int) (reader.BaseStream.Position + offset);

            this.FillStyles = reader.ReadFillStyleArray(true, true, true);
            this.LineStyles = reader.ReadLineStyleArray(true, true, true, false);

            this.CommandList = ReadShapeCommands(reader, this.FillStyles, this.LineStyles, true, true, true, false);

            if (posForShape2 > reader.BaseStream.Position)
                throw new Exception("Morph target error");
            //make sure we're at the right position
            reader.BaseStream.Position = posForShape2;

            this._morphCommandList = ReadShapeCommands(reader, this.FillStyles, this.LineStyles, true, true, true, false);

            //Style changes are defined only in start shape - copy them to end shape!
            object carry = null;
            EPoint ptCurrent = new EPoint();
            ArrayList corrected = new ArrayList();
            IEnumerator enTarget = this._morphCommandList.GetEnumerator();
            foreach (ShapeCommand.Base cmd in this.CommandList)
            {
                if (cmd.IsStyle)
                    continue;

                if (carry!=null)
                {
                    corrected.Add(carry);
                    carry = null;
                }
                else
                {
                    if (!enTarget.MoveNext())
                        throw new Exception("Morph target is missing edges");

                    ShapeCommand.Base cmdTo = (ShapeCommand.Base)enTarget.Current;
                    if (cmd is ShapeCommand.Move)
                    {
                        if (cmdTo is ShapeCommand.Move)
                            corrected.Add(cmdTo);
                        else
                        {
                            carry = cmdTo;
                            corrected.Add(new ShapeCommand.Move(ptCurrent));
                        }
                    }
                    else
                        corrected.Add(cmdTo);

                    if (cmdTo is ShapeCommand.Move)
                        ptCurrent = ((ShapeCommand.Move)cmdTo).GetNewLoc(ptCurrent);
                    else if (cmdTo is ShapeCommand.Draw)
                        ptCurrent = ((ShapeCommand.Draw)cmdTo).GetNewLoc(ptCurrent);
                }
            }
            this._morphCommandList = corrected;

            string s = this.WriteCommands(this._morphCommandList);
            Endogine.Files.FileReadWrite.Write("MS"+this.Id+".txt", s);

            this.InitDone();
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:73,代码来源:MorphShape.cs


注:本文中的Record.GetDataReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。