public bool ReadRecord(out DrawGeometryCommand record) { record = default; unsafe { fixed(byte *pByte = this.buffer) { // This pointer points to the current read point in the // instruction stream. byte *pCur = pByte; // This points to the first byte past the end of the // instruction stream (i.e. when to stop) byte *pEndOfInstructions = pByte + this.currentReadOffset; if ((pCur >= pEndOfInstructions)) //reach end { return(false); } RecordHeader *pCurRecord = (RecordHeader *)pCur; if (pCurRecord->Type != RecordType.DrawGeometry) { return(false); } DrawGeometryCommand *data = (DrawGeometryCommand *)(pCur + sizeof(RecordHeader)); record = *data; this.currentReadOffset += pCurRecord->Size; return(true); } } }
public override void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { if (brush == null && pen == null || geometry == null) { return; } unsafe { EnsureContent(); var record = new DrawGeometryCommand( content.AddDependentResource(brush), content.AddDependentResource(pen), content.AddDependentResource(geometry) ); content.WriteRecord(RecordType.DrawGeometry, (byte *)&record, sizeof(DrawGeometryCommand)); } }