diff --git a/src/HexManiac.Core/ViewModels/ViewPort.cs b/src/HexManiac.Core/ViewModels/ViewPort.cs index 991d0450..fc3eca72 100644 --- a/src/HexManiac.Core/ViewModels/ViewPort.cs +++ b/src/HexManiac.Core/ViewModels/ViewPort.cs @@ -334,6 +334,13 @@ namespace HavenSoft.HexManiac.Core.ViewModels { get => selectedLength; set => Set(ref selectedLength, value, SelectedLengthChanged); } + + private bool base10SelectionLength; + public bool Base10SelectionLength { + get => base10SelectionLength; + set => Set(ref base10SelectionLength, value, arg => UpdateSelectedAddress()); + } + public string SelectedElementName => selectedElementName; private void UpdateSelectedAddress() { @@ -346,7 +353,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels { Set(ref selectedElementName, elementName ?? string.Empty, nameof(SelectedElementName)); int length = Math.Abs(dataIndex1 - dataIndex2) + 1; - Set(ref selectedLength, length.ToString("X1"), nameof(SelectedLength)); + var lengthText = base10SelectionLength ? length.ToString() : length.ToString("X1"); + Set(ref selectedLength, lengthText, nameof(SelectedLength)); } private void SelectedAddressChanged(string old) { @@ -355,7 +363,12 @@ namespace HavenSoft.HexManiac.Core.ViewModels { } private void SelectedLengthChanged(string old) { - if (!selectedLength.TryParseHex(out int length)) return; + int length; + if (base10SelectionLength) { + if (!int.TryParse(selectedLength, out length)) return; + } else { + if (!selectedLength.TryParseHex(out length)) return; + } var left = Math.Min(ConvertViewPointToAddress(SelectionStart), ConvertViewPointToAddress(SelectionEnd)); SelectionStart = ConvertAddressToViewPoint(left); SelectionEnd = ConvertAddressToViewPoint(left + length - 1); diff --git a/src/HexManiac.WPF/Controls/AngleTextBox.xaml.cs b/src/HexManiac.WPF/Controls/AngleTextBox.xaml.cs index 52395711..51ec2015 100644 --- a/src/HexManiac.WPF/Controls/AngleTextBox.xaml.cs +++ b/src/HexManiac.WPF/Controls/AngleTextBox.xaml.cs @@ -17,6 +17,7 @@ namespace HavenSoft.HexManiac.WPF.Controls { public partial class AngleTextBox { private static readonly Thickness TextContentThickness = new(0, 1, 0, 1); + private ContextMenu menu; private bool keepTextBoxForContextMenu; public TextBox GetTextBox() { @@ -146,6 +147,12 @@ namespace HavenSoft.HexManiac.WPF.Controls { BorderThickness = TextContentThickness, VerticalAlignment = VerticalAlignment.Stretch, }; + if (ContextMenu != null) { + menu = ContextMenu; + ContextMenu = null; + } + if (menu != null) textBox.ContextMenu = menu; + if (DataContext is FieldArrayElementViewModel) textBox.InputBindings.Add( new KeyBinding { Key = Key.Enter, diff --git a/src/HexManiac.WPF/Controls/TabView.xaml b/src/HexManiac.WPF/Controls/TabView.xaml index 2f299412..a0c39fa9 100644 --- a/src/HexManiac.WPF/Controls/TabView.xaml +++ b/src/HexManiac.WPF/Controls/TabView.xaml @@ -44,7 +44,14 @@ - + + + + + + +