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); }
public override void Execute(DnHexBox dnHexBox) { var sel = dnHexBox.Selection; if (sel == null) { return; } var res = messageBoxManager.Ask <byte?>(dnSpy_Shared_Resources.FillSelection_Label, "0xFF", dnSpy_Shared_Resources.FillSelection_Title, s => { string error; byte b = NumberVMUtils.ParseByte(s, byte.MinValue, byte.MaxValue, out error); return(string.IsNullOrEmpty(error) ? b : (byte?)null); }, s => { string error; byte b = NumberVMUtils.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; }
internal static void Execute2(DnHexBox dnHexBox) { var sel = dnHexBox.Selection; if (sel == null) { return; } dnHexBox.StartOffset = sel.Value.StartOffset; dnHexBox.EndOffset = sel.Value.EndOffset; }
internal static void Execute2(DnHexBox dnHexBox) { if (!CanExecute(dnHexBox)) { return; } var data = GetBlobData(ClipboardUtils.GetData()); if (data != null) { dnHexBox.Paste(data); } }
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, 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_Shared_Resources.HexEditorSaveSelection_Title, sel.Value.StartOffset, sel.Value.EndOffset); var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } App.MsgBox.Instance.Show(string.Format(dnSpy_Shared_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 MemoryContent(IWpfCommandManager wpfCommandManager, IThemeManager themeManager, IMenuManager menuManager, IHexEditorSettings hexEditorSettings, IMemoryVM memoryVM, IAppSettings appSettings) { this.memoryControl = new MemoryControl(); this.vmMemory = memoryVM; this.vmMemory.SetRefreshLines(() => this.memoryControl.DnHexBox.RedrawModifiedLines()); this.memoryControl.DataContext = this.vmMemory; var dnHexBox = new DnHexBox(menuManager, hexEditorSettings) { CacheLineBytes = true, IsMemory = true, }; dnHexBox.SetBinding(HexBox.DocumentProperty, "HexDocument"); this.memoryControl.DnHexBox = dnHexBox; dnHexBox.StartOffset = 0; dnHexBox.EndOffset = IntPtr.Size == 4 ? uint.MaxValue : ulong.MaxValue; appSettings.PropertyChanged += AppSettings_PropertyChanged; UpdateHexBoxRenderer(appSettings.UseNewRenderer_HexEditor); wpfCommandManager.Add(CommandConstants.GUID_DEBUGGER_MEMORY_CONTROL, memoryControl); wpfCommandManager.Add(CommandConstants.GUID_DEBUGGER_MEMORY_HEXBOX, memoryControl.DnHexBox); }
public override bool IsVisible(DnHexBox dnHexBox) { return(CanExecute(dnHexBox)); }
public HexBoxFileTabUIContext(HexDocument hexDocument, IMenuManager menuManager, IHexEditorSettings hexEditorSettings, IAppSettings appSettings, IHexBoxUndoManager hexBoxUndoManager) { this.hexDocument = hexDocument; this.dnHexBox = new DnHexBox(menuManager, hexEditorSettings); this.dnHexBox.Document = this.hexDocument; this.dnHexBox.InitializeStartEndOffsetToDocument(); this.scrollViewer = new ScrollViewer { Content = this.dnHexBox, CanContentScroll = true, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Focusable = false, }; this.appSettings = appSettings; this.hexBoxUndoManager = hexBoxUndoManager; appSettings.PropertyChanged += AppSettings_PropertyChanged; UpdateHexBoxRenderer(appSettings.UseNewRenderer_HexEditor); hexBoxUndoManager.Initialize(this.dnHexBox); }
public override void Execute(DnHexBox dnHexBox) { Execute2(dnHexBox, appWindow.MainWindow); }
public override bool IsVisible(DnHexBox dnHexBox) { return(true); }
public override bool IsEnabled(DnHexBox dnHexBox) { return(dnHexBox.Selection != null); }
public override bool IsEnabled(DnHexBox dnHexBox) { return(dnHexBox.CanPasteUnicode()); }
internal static bool CanExecute(DnHexBox dnHexBox) { return(dnHexBox != null && dnHexBox.Document != null); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.CopyUIContents(); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.CopyUnicodeString(); }
public override bool IsChecked(DnHexBox context) { return(context.UseHexPrefix ?? hexEditorSettings.UseHexPrefix); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.CopyVBArray(); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.ShowAscii = !(dnHexBox.ShowAscii ?? hexEditorSettings.ShowAscii); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.CopyOffset(); }
public override bool IsChecked(DnHexBox context) { return(context.ShowAscii ?? hexEditorSettings.ShowAscii); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.PasteUnicode(); }
public override void Execute(DnHexBox dnHexBox) { dnHexBox.LowerCaseHex = !(dnHexBox.LowerCaseHex ?? hexEditorSettings.LowerCaseHex); }
internal static bool CanExecute(DnHexBox dnHexBox) { return(dnHexBox != null && GetBlobData(ClipboardUtils.GetData()) != null); }
public override bool IsChecked(DnHexBox context) { return(context.LowerCaseHex ?? hexEditorSettings.LowerCaseHex); }
public override void Execute(DnHexBox dnHexBox) { Execute2(dnHexBox); }
public override void Execute(DnHexBox context) { }
public override bool IsEnabled(DnHexBox dnHexBox) { return(CanExecute(dnHexBox)); }
static bool IsVisible(DnHexBox dnHexBox, ulong start, ulong length) { ulong end = length == 0 ? start : start + length - 1; if (end < start) return false; return start >= dnHexBox.StartOffset && end <= dnHexBox.EndOffset; }