private Stream GetSelectedBitmapStream(ImageListViewItem item) { try { byte[] data = new byte[item.ImageBlock.Length]; stream.Position = item.ImageBlock.Offset; if (stream.Read(data, 0, item.ImageBlock.Length) != item.ImageBlock.Length) { return null; } return new MemoryStream(data); } catch { return null; } }
private void CreateListviewItems(List<ProcessedCallLog> callLogs, List<ProcessedAddressBook> addressBook, List<ProcessedSms> sms, List<ImageBlock> imageBlocks, Dec0de.UI.DecodeFilters.Filters filters) { callLogItems = new List<CallLogListViewItem>(); foreach (ProcessedCallLog pcl in callLogs) { if (filters != null && filters.IsFiltered(pcl)) continue; CallLogListViewItem item = new CallLogListViewItem(pcl); MetaCallLog mcl = pcl.MetaData; item.Name = pcl.Id.ToString(); item.SubItems.Add(FormatPhoneNum(mcl.Number)); item.SubItems.Add(FormatName(mcl.Name)); item.SubItems.Add(FormatCallLogType(mcl.Type)); item.SubItems.Add(FormatTimestamp(mcl.TimeStamp)); callLogItems.Add(item); } adrBookItems = new List<AddressBookListViewItem>(); foreach (ProcessedAddressBook pab in addressBook) { if ((filters != null) && filters.IsFiltered(pab)) continue; AddressBookListViewItem item = new AddressBookListViewItem(pab); MetaAddressBookEntry mabe = pab.MetaData; item.Name = pab.Id.ToString(); item.SubItems.Add(FormatName(mabe.Name)); item.SubItems.Add(FormatPhoneNum(mabe.Number)); adrBookItems.Add(item); } smsItems = new List<SmsListViewItem>(); foreach (ProcessedSms psms in sms) { if ((filters != null) && filters.IsFiltered(psms)) continue; SmsListViewItem item = new SmsListViewItem(psms); MetaSms msms = psms.MetaData; item.Name = psms.Id.ToString(); item.SubItems.Add(FormatPhoneNum(msms.Number)); item.SubItems.Add(FormatPhoneNum(msms.Number2)); item.SubItems.Add(FormatMessage(msms.Message)); item.SubItems.Add(FormatTimestamp(msms.TimeStamp)); smsItems.Add(item); } imageItems = new List<ImageListViewItem>(); foreach (ImageBlock ib in imageBlocks) { ImageListViewItem item = new ImageListViewItem(ib); string name = String.Format("Image {0:D4}", ib.Num); item.Name = name; item.SubItems.Add(name); item.SubItems.Add(ib.GetImageType()); item.SubItems.Add(ib.Length.ToString()); item.SubItems.Add(ib.Offset.ToString()); imageItems.Add(item); } }