/// <summary> /// クイックビュータイプを切り替える /// </summary> /// <param name="sender"></param> /// <param name="type"></param> private void setQuickView(Button sender, QuickViewType type) { offViewButton.BackColor = SystemColors.Control; byteViewButton.BackColor = SystemColors.Control; int16ViewButton.BackColor = SystemColors.Control; int32ViewButton.BackColor = SystemColors.Control; int64ViewButton.BackColor = SystemColors.Control; singleViewButton.BackColor = SystemColors.Control; sender.BackColor = Color.LightCoral; currentQuickViewType = type; }
/// <summary> /// クイックビューを表示 /// </summary> /// <param name="startIndex"></param> /// <param name="type"></param> private void showQuickView(int startIndex, QuickViewType type) { var source = Bytes.Skip(startIndex).ToArray(); var showString = string.Empty; switch (type) { case QuickViewType.Byte: if (source.Length < sizeof(Byte)) { return; } hexTextBox.Select(startIndex * 3, sizeof(Byte) * 3); showString = string.Format("{0:#,0} (unsigned: {1:#,0})", (SByte)source[0], (Byte)source[0]); break; case QuickViewType.Int16: if (source.Length < sizeof(Int16)) { return; } hexTextBox.Select(startIndex * 3, sizeof(Int16) * 3); showString = string.Format("{0:#,0} (unsigned: {1:#,0})", BitConverter.ToInt16(source, 0), BitConverter.ToUInt16(source, 0)); break; case QuickViewType.Int32: if (source.Length < sizeof(Int32)) { return; } hexTextBox.Select(startIndex * 3, sizeof(Int32) * 3); showString = string.Format("{0:#,0} (unsigned: {1:#,0})", BitConverter.ToInt32(source, 0), BitConverter.ToUInt32(source, 0)); break; case QuickViewType.Int64: if (source.Length < sizeof(Int64)) { return; } hexTextBox.Select(startIndex * 3, sizeof(Int64) * 3); showString = string.Format("{0:#,0} (unsigned: {1:#,0})", BitConverter.ToInt64(source, 0), BitConverter.ToUInt64(source, 0)); break; case QuickViewType.Single: if (source.Length < sizeof(Single)) { return; } hexTextBox.Select(startIndex * 3, sizeof(Single) * 3); showString = string.Format("{0}", BitConverter.ToSingle(source, 0)); break; } var point = hexTextBox.PointToClient(Cursor.Position); point.Offset(0, 15); quickViewToolTip.Show(showString, hexTextBox, point); }