internal IvaProgramDescription(int index, CmosType cmosType, ref IvBankList src) { this.ProgramNo = index; this.ProgramName = src.BankName; this.Configured = src.ConfiguredBank; this.MasterAvailable = src.Enable; Color[] imageData = new Color[4800]; if (this.MasterAvailable) { if (cmosType == CmosType.CmosMono) { Holder <IvThumbnailMono> holder = new Holder <IvThumbnailMono>(); IvaUtils.CopyStructure <IvThumbnailImage, IvThumbnailMono>(ref src.ThumbnailImage, ref holder.Target); for (int index1 = 0; index1 < 60; ++index1) { for (int index2 = 0; index2 < 80; ++index2) { byte num = holder.Target.ImageBuffer[index1 * 80 + index2]; imageData[index1 * 80 + index2] = Color.FromArgb((int)num, (int)num, (int)num); } } } else { Holder <IvThumbnailColor> holder = new Holder <IvThumbnailColor>(); IvaUtils.CopyStructure <IvThumbnailImage, IvThumbnailColor>(ref src.ThumbnailImage, ref holder.Target); for (int index1 = 0; index1 < 60; ++index1) { for (int index2 = 0; index2 < 80; ++index2) { ushort num = holder.Target.ImageBuffer[index1 * 80 + index2]; imageData[index1 * 80 + index2] = Color.FromArgb(((int)num & 63488) >> 8, ((int)num & 2000) >> 3, ((int)num & 31) << 3); } } } } this.ThumbnailImage = new ThumbnailImage(imageData); }
private WorkSpace ReceiveVariableLengthReply(Type expectedType) { List <byte> byteList = new List <byte>(); int count = Marshal.SizeOf(typeof(CommHeader)); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (byteList.Count < count && stopwatch.ElapsedMilliseconds < 45000L) { byteList.AddRange((IEnumerable <byte>) this._connection.Receive()); } if (byteList.Count < count) { throw new ConnectionLostException(string.Format("Type: {0} size is incorrect. Received size is {1}, but expected size is {2}.", (object)expectedType, (object)byteList.Count, (object)count)); } byte[] numArray = new byte[count]; byteList.CopyTo(0, numArray, 0, count); CommHeader structure = new CommHeader(); IvaUtils.BytesToStructure <CommHeader>(ref structure, numArray); int num1 = structure.lBodyLength + count; while (byteList.Count < num1 && stopwatch.ElapsedMilliseconds < 45000L) { byteList.AddRange((IEnumerable <byte>) this._connection.Receive()); } if (byteList.Count != num1) { throw new ConnectionLostException(string.Format("Type: {0} size is incorrect. Received size is {1}, but expected size is {2}.", (object)expectedType, (object)byteList.Count, (object)num1)); } byte[] array = byteList.ToArray(); IntPtr num2 = Marshal.AllocHGlobal(array.Length); Marshal.Copy(array, 0, num2, array.Length); return(new WorkSpace(expectedType, num2, array.Length)); }