static void ExecuteInternal(DnHexBox dnHexBox, Window ownerWindow) { Debug.Assert(ownerWindow != null); if (dnHexBox == null) { return; } ulong start = dnHexBox.CaretPosition.Offset; ulong end = start; if (dnHexBox.Selection != null) { start = dnHexBox.Selection.Value.StartOffset; end = dnHexBox.Selection.Value.EndOffset; } var data = new SelectVM(dnHexBox.PhysicalToVisibleOffset(start), dnHexBox.PhysicalToVisibleOffset(end), dnHexBox.PhysicalToVisibleOffset(dnHexBox.StartOffset), dnHexBox.PhysicalToVisibleOffset(dnHexBox.EndOffset)); var win = new SelectDlg(); win.DataContext = data; win.Owner = ownerWindow ?? Application.Current.MainWindow; if (win.ShowDialog() != true) { return; } dnHexBox.Selection = new HexSelection(dnHexBox.VisibleToPhysicalOffset(data.EndVM.Value), dnHexBox.VisibleToPhysicalOffset(data.StartVM.Value)); dnHexBox.CaretPosition = new HexBoxPosition(dnHexBox.VisibleToPhysicalOffset(data.StartVM.Value), dnHexBox.CaretPosition.Kind, 0); }
internal static void Execute2(DnHexBox dnHexBox, Window ownerWindow) { Debug.Assert(ownerWindow != null); if (!CanExecute(dnHexBox)) { return; } var data = new GoToOffsetVM(dnHexBox.PhysicalToVisibleOffset(dnHexBox.CaretPosition.Offset), dnHexBox.PhysicalToVisibleOffset(dnHexBox.StartOffset), dnHexBox.PhysicalToVisibleOffset(dnHexBox.EndOffset)); var win = new GoToOffsetDlg(); win.DataContext = data; win.Owner = ownerWindow ?? Application.Current.MainWindow; if (dnHexBox.IsMemory) { win.Title = dnSpy_Shared_Resources.GoToOffset_Title_Address; win.offsetLabel.Content = dnSpy_Shared_Resources.GoToOffset_Address_Label; } else { win.Title = dnSpy_Shared_Resources.GoToOffset_Title; win.offsetLabel.Content = dnSpy_Shared_Resources.GoToOffset_Offset_Label; } if (win.ShowDialog() != true) { return; } dnHexBox.CaretPosition = new HexBoxPosition(dnHexBox.VisibleToPhysicalOffset(data.OffsetVM.Value), dnHexBox.CaretPosition.Kind, 0); }