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_Contracts_DnSpy_Resources.GoToOffset_Title_Address; win.offsetLabel.Content = dnSpy_Contracts_DnSpy_Resources.GoToOffset_Address_Label; } else { win.Title = dnSpy_Contracts_DnSpy_Resources.GoToOffset_Title; win.offsetLabel.Content = dnSpy_Contracts_DnSpy_Resources.GoToOffset_Offset_Label; } if (win.ShowDialog() != true) { return; } dnHexBox.CaretPosition = new HexBoxPosition(dnHexBox.VisibleToPhysicalOffset(data.OffsetVM.Value), dnHexBox.CaretPosition.Kind, 0); }
public override void Execute(DnHexBox dnHexBox) { var sel = dnHexBox.Selection; if (sel == null) { return; } var res = messageBoxService.Ask <byte?>(dnSpy_Contracts_DnSpy_Resources.FillSelection_Label, "0xFF", dnSpy_Contracts_DnSpy_Resources.FillSelection_Title, s => { string error; byte b = SimpleTypeConverter.ParseByte(s, byte.MinValue, byte.MaxValue, out error); return(string.IsNullOrEmpty(error) ? b : (byte?)null); }, s => { string error; byte b = SimpleTypeConverter.ParseByte(s, byte.MinValue, byte.MaxValue, out error); return(error); }); if (res == null) { return; } dnHexBox.FillBytes(sel.Value.StartOffset, sel.Value.EndOffset, res.Value); dnHexBox.Selection = null; }
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) { var sel = dnHexBox.Selection; if (sel == null) { return; } dnHexBox.StartOffset = sel.Value.StartOffset; dnHexBox.EndOffset = sel.Value.EndOffset; }
public void CopyTo(DnHexBox dnHexBox) { dnHexBox.BytesGroupCount = this.BytesGroupCount; dnHexBox.BytesPerLine = this.BytesPerLine; dnHexBox.UseHexPrefix = this.UseHexPrefix; dnHexBox.ShowAscii = this.ShowAscii; dnHexBox.LowerCaseHex = this.LowerCaseHex; dnHexBox.AsciiEncoding = this.AsciiEncoding; dnHexBox.HexOffsetSize = this.HexOffsetSize; dnHexBox.UseRelativeOffsets = this.UseRelativeOffsets; dnHexBox.BaseOffset = this.BaseOffset; dnHexBox.StartOffset = this.StartOffset ?? dnHexBox.DocumentStartOffset; dnHexBox.EndOffset = this.EndOffset ?? dnHexBox.DocumentEndOffset; }
public LocalHexSettings(DnHexBox dnHexBox) { this.BytesGroupCount = dnHexBox.BytesGroupCount; this.BytesPerLine = dnHexBox.BytesPerLine; this.UseHexPrefix = dnHexBox.UseHexPrefix; this.ShowAscii = dnHexBox.ShowAscii; this.LowerCaseHex = dnHexBox.LowerCaseHex; this.AsciiEncoding = dnHexBox.AsciiEncoding; this.HexOffsetSize = dnHexBox.HexOffsetSize; this.UseRelativeOffsets = dnHexBox.UseRelativeOffsets; this.BaseOffset = dnHexBox.BaseOffset; this.StartOffset = dnHexBox.StartOffset == dnHexBox.DocumentStartOffset ? (ulong?)null : dnHexBox.StartOffset; this.EndOffset = dnHexBox.EndOffset == dnHexBox.DocumentEndOffset ? (ulong?)null : dnHexBox.EndOffset; }
public override void Execute(DnHexBox dnHexBox) { var data = new LocalSettingsVM(new LocalHexSettings(dnHexBox)); var win = new LocalSettingsDlg(); win.DataContext = data; win.Owner = appWindow.MainWindow; if (win.ShowDialog() != true) { return; } data.CreateLocalHexSettings().CopyTo(dnHexBox); }
internal static void Execute2(DnHexBox dnHexBox) { if (!CanExecute(dnHexBox)) { return; } var data = GetBlobData(ClipboardUtils.GetData()); if (data != null) { dnHexBox.Paste(data); } }
internal static void Execute2(DnHexBox dnHexBox, Window ownerWindow) { Debug.Assert(ownerWindow != null); var doc = dnHexBox.Document; if (doc == null) { return; } var sel = dnHexBox.Selection; if (sel == null) { return; } var dialog = new WF.SaveFileDialog() { Filter = PickFilenameConstants.AnyFilenameFilter, RestoreDirectory = true, ValidateNames = true, }; if (dialog.ShowDialog() != WF.DialogResult.OK) { return; } var data = new ProgressVM(Dispatcher.CurrentDispatcher, new HexDocumentDataSaver(doc, sel.Value.StartOffset, sel.Value.EndOffset, dialog.FileName)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = ownerWindow ?? Application.Current.MainWindow; win.Title = string.Format(dnSpy_Contracts_DnSpy_Resources.HexEditorSaveSelection_Title, sel.Value.StartOffset, sel.Value.EndOffset); var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } MsgBox.Instance.Show(string.Format(dnSpy_Contracts_DnSpy_Resources.AnErrorOccurred, data.ErrorMessage)); }
internal static void Execute2(DnHexBox dnHexBox) { dnHexBox.StartOffset = dnHexBox.DocumentStartOffset; dnHexBox.EndOffset = dnHexBox.DocumentEndOffset; var sel = dnHexBox.Selection; dnHexBox.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(delegate { if (sel != null && sel == dnHexBox.Selection) { dnHexBox.SetCaretPositionAndMakeVisible(sel.Value.StartOffset, sel.Value.EndOffset); } else { dnHexBox.BringCaretIntoView(); } })); }
public override bool IsVisible(DnHexBox dnHexBox) => true;
public override bool IsChecked(DnHexBox context) => context.LowerCaseHex ?? hexEditorSettings.LowerCaseHex;
public override void Execute(DnHexBox dnHexBox) => Execute2(dnHexBox);
public override bool IsEnabled(DnHexBox dnHexBox) => dnHexBox.CanPasteUnicode();
internal static bool CanExecute(DnHexBox dnHexBox) => dnHexBox != null && GetBlobData(ClipboardUtils.GetData()) != null;
public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyOffset();
public override void Execute(DnHexBox dnHexBox) => dnHexBox.PasteUnicode();
public override void Execute(DnHexBox dnHexBox) => dnHexBox.LowerCaseHex = !(dnHexBox.LowerCaseHex ?? hexEditorSettings.LowerCaseHex);
public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyUIContents();
public override bool IsEnabled(DnHexBox dnHexBox) => CanExecute(dnHexBox);
public override void Execute(DnHexBox dnHexBox) { }
internal static bool CanExecute(DnHexBox dnHexBox) => dnHexBox != null && dnHexBox.Document != null;
public override bool IsEnabled(DnHexBox dnHexBox) => dnHexBox.Selection != null;
public override bool IsVisible(DnHexBox dnHexBox) => CanExecute(dnHexBox);
public override void Execute(DnHexBox context) { }
public override void Execute(DnHexBox dnHexBox) => Execute2(dnHexBox, appWindow.MainWindow);
public override string GetHeader(DnHexBox context) => context.IsMemory ? dnSpy_Contracts_DnSpy_Resources.GoToAddressCommand : dnSpy_Contracts_DnSpy_Resources.GoToOffsetCommand;
public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyVBArray();
public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyUnicodeString();
public override bool IsChecked(DnHexBox context) => context.ShowAscii ?? hexEditorSettings.ShowAscii;