private void ReconstructList(bool StringsOnly) { BeginUpdate(); for (int i = 0; i < HMChunks.Count; i++) { object Chunk = HMChunks[i]; if (!(Chunk is string) && StringsOnly) { continue; } string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Chunk)); Items[i].SubItems[2].Text = Encoded; if (Chunk is string) { string Value = (string)Chunk; string EncodedLength = string.Empty; if ((Destination == HDestinations.Server && Protocol == HProtocols.Ancient) || Protocol == HProtocols.Modern) { EncodedLength = (Protocol == HProtocols.Modern ? HMessage.ToString(BigEndian.CypherShort((ushort)Value.Length)) : HMessage.ToString(Ancient.CypherShort((ushort)Value.Length))) + " | "; } Items[i].ToolTipText = string.Format("Type: String\nValue: {0}\n{1}Encoded: {2}", Value, string.Format("Length: {0}{1}\n", EncodedLength, Value.Length), Encoded); } else { Items[i].ToolTipText = Items[i].ToolTipText.Replace(Items[i].ToolTipText.GetChild("Encoded: ", '\n'), Encoded); } } EndUpdate(); }
public void AppendChunk(bool Value) { HMChunks.Add(Value); string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Value)); AddItemChunk("Boolean", Value, Encoded); }
public void ReplaceSelected(object Value) { int Index = SelectedIndices[0]; if (Value.Equals(HMChunks[Index])) { return; } HMChunks[Index] = Value; ListViewItem CurItem = Items[Index]; string Type = Value is string? "String" : Value is int? "Integer" : "Boolean"; string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Value)); Items[Index].SubItems[0].Text = Type; Items[Index].SubItems[1].Text = Value.ToString(); Items[Index].SubItems[2].Text = Encoded; string EncodedLength = string.Empty; if (Value is string) { if ((Destination == HDestinations.Server && Protocol == HProtocols.Ancient) || Protocol == HProtocols.Modern) { EncodedLength = (Protocol == HProtocols.Modern ? HMessage.ToString(BigEndian.CypherShort((ushort)Value.ToString().Length)) : HMessage.ToString(Ancient.CypherShort((ushort)Value.ToString().Length))) + " | "; } } Items[Index].ToolTipText = string.Format("Type: {0}\nValue: {1}\n{2}Encoded: {3}", Type, Value, string.Format("Length: {0}{1}\n", EncodedLength, Value.ToString().Length), Encoded); }
public void AppendChunk(int value) { _chunks.Add(value); string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, value)); AddItemChunk("Integer", value, encoded); }
private void ReconstructList(bool stringsOnly) { BeginUpdate(); for (int i = 0; i < _chunks.Count; i++) { object chunk = _chunks[i]; if (!(chunk is string) && stringsOnly) { continue; } string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, chunk)); Items[i].SubItems[2].Text = encoded; var value = chunk as string; if (value != null) { string encodedLength = string.Empty; if ((Destination == HDestination.Server && Protocol == HProtocol.Ancient) || Protocol == HProtocol.Modern) { ushort valueLength = (ushort)value.Length; byte[] data = Protocol == HProtocol.Ancient ? Ancient.CypherShort(valueLength) : Modern.CypherShort(valueLength); encodedLength = HMessage.ToString(data) + " | "; } Items[i].ToolTipText = string.Format("Type: String\nValue: {0}\n{1}Encoded: {2}", value, string.Format("Length: {0}{1}\n", encodedLength, value.Length), encoded); } else { Items[i].ToolTipText = Items[i].ToolTipText.Replace(Items[i].ToolTipText.GetChild("Encoded: ", '\n'), encoded); } } EndUpdate(); }
public void ReplaceSelected(object value) { _lastHeader = 0; int index = SelectedIndices[0]; if (value.Equals(_chunks[index])) { return; } _chunks[index] = value; ListViewItem curItem = Items[index]; string type = value is string? "String" : value is int? "Integer" : "Boolean"; string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, value)); curItem.SubItems[0].Text = type; curItem.SubItems[1].Text = value.ToString(); curItem.SubItems[2].Text = encoded; string encodedLength = string.Empty; if (value is string) { if ((Destination == HDestination.Server && Protocol == HProtocol.Ancient) || Protocol == HProtocol.Modern) { ushort valueLength = (ushort)value.ToString().Length; byte[] data = Protocol == HProtocol.Ancient ? Ancient.CypherShort(valueLength) : Modern.CypherShort(valueLength); encodedLength = HMessage.ToString(data) + " | "; } } curItem.ToolTipText = string.Format("Type: {0}\nValue: {1}\n{2}Encoded: {3}", type, value, string.Format("Length: {0}{1}\n", encodedLength, value.ToString().Length), encoded); }
public void AppendChunk(string Value) { HMChunks.Add(Value); string EncodedLength = string.Empty; string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Value)); if ((Destination == HDestinations.Server && Protocol == HProtocols.Ancient) || Protocol == HProtocols.Modern) { EncodedLength = (Protocol == HProtocols.Modern ? HMessage.ToString(BigEndian.CypherShort((ushort)Value.Length)) : HMessage.ToString(Ancient.CypherShort((ushort)Value.Length))) + " | "; } AddItemChunk("String", Value, Encoded, string.Format("Length: {0}{1}\n", EncodedLength, Value.Length)); }
public void AppendChunk(string value) { _chunks.Add(value); string encodedLength = string.Empty; string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, value)); if (Destination == HDestination.Server || Protocol == HProtocol.Modern) { ushort valueLength = (ushort)value.Length; byte[] data = Protocol == HProtocol.Ancient ? Ancient.CypherShort(valueLength) : Modern.CypherShort(valueLength); encodedLength = HMessage.ToString(data) + " | "; } AddItemChunk("String", value, encoded, string.Format("Length: {0}{1}\n", encodedLength, value.Length)); }