/// <summary> /// Convert data to TBL string. /// </summary> /// <param name="data"></param> /// <param name="tbl"></param> /// <returns> /// Return string converted to TBL string representation. /// Return null on error /// </returns> public string ToTBLString(byte[] data) { if (data != null) { StringBuilder sb = new StringBuilder(); string MTE; for (int i = 0; i < data.Length; i++) { if (i < data.Length - 1) { MTE = FindMatch((ByteConverters.ByteToHex(data[i]) + ByteConverters.ByteToHex(data[i + 1])), true); if (MTE != "#") { sb.Append(MTE); continue; } } sb.Append(FindMatch(ByteConverters.ByteToHex(data[i]), true)); } return(sb.ToString()); } return(null); }
private void UpdateHexString() { if (Byte != null) { HexString = ByteConverters.ByteToHex(Byte.Value); } else { HexString = string.Empty; } }
/// <summary> /// Update control label from byte property /// </summary> private void UpdateLabelFromByte() { if (Byte != null) { switch (TypeOfCharacterTable) { case CharacterTable.ASCII: StringByteLabel.Content = ByteConverters.ByteToChar(Byte.Value); Width = 12; break; case CharacterTable.TBLFile: ReadOnlyMode = true; if (_TBLCharacterTable != null) { string content = "#"; string MTE = (ByteConverters.ByteToHex(Byte.Value) + ByteConverters.ByteToHex(ByteNext.Value)).ToUpper(); content = _TBLCharacterTable.FindTBLMatch(MTE, true); if (content == "#") { content = _TBLCharacterTable.FindTBLMatch(ByteConverters.ByteToHex(Byte.Value).ToUpper().ToUpper(), true); } StringByteLabel.Content = content; //Adjuste wight if (content.Length == 1) { Width = 12; } else if (content.Length == 2) { Width = 12 + content.Length * 2D; } else if (content.Length > 2) { Width = 12 + content.Length * 3.8D; } } else { goto case CharacterTable.ASCII; } break; } } else { StringByteLabel.Content = ""; } }
private void UpdateLabelFromByte() { if (Byte != null) { string hexabyte = ByteConverters.ByteToHex(Byte.Value); FirstHexChar.Content = hexabyte.Substring(0, 1); SecondHexChar.Content = hexabyte.Substring(1, 1); } else { FirstHexChar.Content = ""; SecondHexChar.Content = ""; } }
public static TBLStream CreateDefaultASCII(DefaultCharacterTableType type = DefaultCharacterTableType.ASCII) { TBLStream tbl = new TBLStream(); switch (type) { case DefaultCharacterTableType.ASCII: for (byte i = 0; i < 255; i++) { DTE dte = new DTE(ByteConverters.ByteToHex(i).ToUpper(), $"{ByteConverters.ByteToChar(i)}"); tbl.Add(dte); } break; } tbl.AllowEdit = true; return(tbl); }
/// <summary> /// Detect if is a PE file and create the backgroung based on file data /// </summary> /// TODO : complete with other various custombackground based on file public List <CustomBackgroundBlock> GetCustomBackgroundBlock(ByteProvider provider) { if (ByteProvider.CheckIsOpen(provider)) { //Added only if is a PE file... if (ByteConverters.ByteToHex(provider.GetCopyData(0, 1, true)) == "4D 5A") { //Load default var list = GetCustomBackgroundBlock(); //Add CBB : This program cannot be run in DOS mode list.Add(new CustomBackgroundBlock("0x4E", 38, Brushes.PaleVioletRed, CBB_EXEFile_NotDOSProgramString)); return(list); } } return(new List <CustomBackgroundBlock>()); }