コード例 #1
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_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);
        }
コード例 #2
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;
        }
コード例 #3
0
        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);
        }
コード例 #4
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;
        }
コード例 #5
0
 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;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        internal static void Execute2(DnHexBox dnHexBox)
        {
            if (!CanExecute(dnHexBox))
            {
                return;
            }

            var data = GetBlobData(ClipboardUtils.GetData());

            if (data != null)
            {
                dnHexBox.Paste(data);
            }
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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();
                }
            }));
        }
コード例 #11
0
 public override bool IsVisible(DnHexBox dnHexBox) => true;
コード例 #12
0
 public override bool IsChecked(DnHexBox context) => context.LowerCaseHex ?? hexEditorSettings.LowerCaseHex;
コード例 #13
0
 public override void Execute(DnHexBox dnHexBox) => Execute2(dnHexBox);
コード例 #14
0
 public override bool IsEnabled(DnHexBox dnHexBox) => dnHexBox.CanPasteUnicode();
コード例 #15
0
 internal static bool CanExecute(DnHexBox dnHexBox) => dnHexBox != null && GetBlobData(ClipboardUtils.GetData()) != null;
コード例 #16
0
 public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyOffset();
コード例 #17
0
 public override void Execute(DnHexBox dnHexBox) => dnHexBox.PasteUnicode();
コード例 #18
0
 public override void Execute(DnHexBox dnHexBox) => dnHexBox.LowerCaseHex = !(dnHexBox.LowerCaseHex ?? hexEditorSettings.LowerCaseHex);
コード例 #19
0
 public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyUIContents();
コード例 #20
0
 public override bool IsEnabled(DnHexBox dnHexBox) => CanExecute(dnHexBox);
コード例 #21
0
 public override void Execute(DnHexBox dnHexBox)
 {
 }
コード例 #22
0
 internal static bool CanExecute(DnHexBox dnHexBox) => dnHexBox != null && dnHexBox.Document != null;
コード例 #23
0
 public override bool IsEnabled(DnHexBox dnHexBox) => dnHexBox.Selection != null;
コード例 #24
0
 public override bool IsVisible(DnHexBox dnHexBox) => CanExecute(dnHexBox);
コード例 #25
0
 public override void Execute(DnHexBox context)
 {
 }
コード例 #26
0
 public override void Execute(DnHexBox dnHexBox) => Execute2(dnHexBox, appWindow.MainWindow);
コード例 #27
0
 public override string GetHeader(DnHexBox context) => context.IsMemory ? dnSpy_Contracts_DnSpy_Resources.GoToAddressCommand : dnSpy_Contracts_DnSpy_Resources.GoToOffsetCommand;
コード例 #28
0
 public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyVBArray();
コード例 #29
0
 public override void Execute(DnHexBox dnHexBox) => dnHexBox.CopyUnicodeString();
コード例 #30
0
 public override bool IsChecked(DnHexBox context) => context.ShowAscii ?? hexEditorSettings.ShowAscii;