public bool EnterPlugin(int baseSize) { // Read the tag data in based off the base size _reader.SeekTo(_tag.MetaLocation.AsOffset()); var data = _reader.ReadBlock(baseSize); // Create a block for it and push it onto the block stack uint cont = _cacheFile.PointerExpander.Contract(_tag.MetaLocation.AsPointer()); var block = new DataBlock(cont, 1, 4, false, data); DataBlocks.Add(block); var blockList = new List <DataBlock> { block }; _blockStack.Push(blockList); if (_tag.Group.Magic == SoundGroup) { ReadSound(block, 0); } return(true); }
private DataBlock ReadDataBlock(uint pointer, int entrySize, int entryCount, int align) { _reader.SeekTo(_cacheFile.MetaArea.PointerToOffset(pointer)); byte[] data = _reader.ReadBlock(entrySize * entryCount); var block = new DataBlock(pointer, entryCount, align, data); DataBlocks.Add(block); return(block); }
private DataBlock ReadDataBlock(long pointer, int entrySize, int entryCount, int align, bool sort) { _reader.SeekTo(_cacheFile.MetaArea.PointerToOffset(pointer)); var data = _reader.ReadBlock(entrySize * entryCount); uint cont = _cacheFile.PointerExpander.Contract(pointer); var block = new DataBlock(cont, entryCount, align, sort, data); DataBlocks.Add(block); return(block); }
/// <summary> /// Reads in the content of the TZX file so that it can be played /// </summary> /// <returns>True, if read was successful; otherwise, false</returns> public virtual bool ReadContent() { var header = new TzxHeader(); try { header.ReadFrom(_reader); if (!header.IsValid) { throw new TzxException("Invalid TZX header"); } MajorVersion = header.MajorVersion; MinorVersion = header.MinorVersion; while (_reader.BaseStream.Position != _reader.BaseStream.Length) { var blockType = _reader.ReadByte(); if (!DataBlockTypes.TryGetValue(blockType, out var type)) { throw new TzxException($"Unkonwn TZX block type: {blockType}"); } try { var block = Activator.CreateInstance(type) as TzxDataBlockBase; if (block is TzxDeprecatedDataBlockBase deprecated) { deprecated.ReadThrough(_reader); } else { block?.ReadFrom(_reader); } DataBlocks.Add(block); } catch (Exception ex) { throw new TzxException($"Cannot read TZX data block {type}.", ex); } } return(true); } catch { // --- This exception is intentionally ignored return(false); } }
public bool EnterPlugin(int baseSize) { // Read the tag data in based off the base size _reader.SeekTo(_tagLocation.AsOffset()); byte[] data = _reader.ReadBlock(baseSize); // Create a block for it and push it onto the block stack var block = new DataBlock(_tagLocation.AsPointer(), 1, 4, data); DataBlocks.Add(block); var blockList = new List <DataBlock>(); blockList.Add(block); _blockStack.Push(blockList); return(true); }
protected virtual void InitBlocks(int totalBlocks, int entriesPerBlock) { Size blockSize = new Block(new Point(0, 0), 1, entriesPerBlock).GetSize(); int blockHeight = blockSize.Height; int blockCenterX = this.Center.X; int initBlockCenterY = this.Center.Y - (blockHeight / 2) * (totalBlocks - 1) + labelHeight - 3 * padding / 2; for (int blockNumber = 0; blockNumber < totalBlocks; blockNumber++) { int offsetY = blockNumber * blockHeight; int blockCenterY = initBlockCenterY + offsetY; Point blockCenter = new Point(blockCenterX, blockCenterY); Block blockToAdd = new Block(blockCenter, blockNumber, entriesPerBlock); DataBlocks.Add(blockToAdd); } SetBlockSelection(this.CurrentBlock, true); }
public override BaseGadgetControl AddControl(BaseGadgetControl control) { base.AddControl(control); if (control is ModulePrefs) { this.ModulePrefs = (ModulePrefs)control; } else if (control is ContentBlock) { this.AddContentBlock((ContentBlock)control); } else if (control is DataBlock) { ((DataBlock)control).ConfirmDataItemsRegistered(); DataBlocks.Add((DataBlock)control); } else if (control is TemplatesRoot) { MyCustomTagFactory.RegisterCustomTags(((TemplatesRoot)control).CustomTags); } return(control); }