From b06e3628f098f98ceb269ebb8513d5c0d1fab041 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 23 Mar 2021 14:55:00 -0400 Subject: [PATCH] improve parsing of entered data in conversion text boxes --- .../Editors/Binary/BinaryEditor.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Libraries/UniversalEditor.UserInterface/Editors/Binary/BinaryEditor.cs b/Libraries/UniversalEditor.UserInterface/Editors/Binary/BinaryEditor.cs index 8ce181d7..70206193 100644 --- a/Libraries/UniversalEditor.UserInterface/Editors/Binary/BinaryEditor.cs +++ b/Libraries/UniversalEditor.UserInterface/Editors/Binary/BinaryEditor.cs @@ -513,8 +513,14 @@ namespace UniversalEditor.Editors.Binary return sb.ToString(); }, delegate(string input) { - long b = Int64.Parse(input); - return BitConverter.GetBytes(b); + string[] pieces = input.Split(new char[] { ' ' }); + byte[] bytes = new byte[pieces.Length]; + for (int i = 0; i < pieces.Length; i++) + { + bytes[i] = Byte.Parse(pieces[i]); + } + + return bytes; }, 4), new CONVERSION_DATA(null, "Octal", delegate(byte[] input) { @@ -780,6 +786,11 @@ namespace UniversalEditor.Editors.Binary sb.AppendLine(String.Format("Value for {0} must be between {1} and {2}", converter.DataType.Name, minValue, maxValue)); } } + else + { + // byte array + + } MessageDialog.ShowDialog(sb.ToString(), "Error", MessageDialogButtons.OK, MessageDialogIcon.Error); }