/// <summary> /// 显示查询结果 /// </summary> private void ShowQueryResult(QueryInfo query_info, ByteArray by) { if (by.Available == 0) { m_query_info = null; MessageBox.Show("查询数据为空", "信息", MessageBoxButtons.OK); return; } m_query_info = query_info; int total_length_one_row = 0; foreach (var bin_header in m_list_bin_header) { switch (bin_header.type) { case "int": case "uint": total_length_one_row += bin_header.length; break; case "float": total_length_one_row += 4; break; case "double": total_length_one_row += 8; break; case "string": /**undo*/; break; default: continue; } } ///解析 m_list_bin_contentes.Clear(); while (by.Available > 0) { if ((query_info.fixed_length > 0 && by.Available < query_info.fixed_length) || (by.Available < total_length_one_row)) { MessageBox.Show("数据异常,长度不够", "警告", MessageBoxButtons.OK); break; } int start_pos = by.Head; List <BinContent> list = new List <BinContent>(); foreach (var bin_header in m_list_bin_header) { string value = ""; byte[] by_val = new byte[8]; switch (bin_header.type) { case "int": by.Read(ref by_val, bin_header.length); value = BitConverter.ToInt64(by_val, 0).ToString(); break; case "uint": by.Read(ref by_val, bin_header.length); value = BitConverter.ToUInt64(by_val, 0).ToString(); break; case "float": value = by.ReadFloat().ToString(); break; case "double": value = by.ReadDouble().ToString(); break; case "string": value = by.ReadString(); break; default: continue; } list.Add(new BinContent(bin_header.type, value)); } m_list_bin_contentes.Add(list); if (query_info.fixed_length > 0) { by.SetHead(start_pos + query_info.fixed_length); } } ///显示数据 m_find_result.Rows.Clear(); for (int row = 0; row < m_list_bin_contentes.Count; ++row) { int index = this.m_find_result.Rows.Add(); List <BinContent> list = m_list_bin_contentes[row]; for (int col = 0; col < list.Count; col++) { m_find_result.Rows[index].Cells[col].Value = list[col].value; } } }