Exemple #1
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;
        }
Exemple #2
0
        protected override void Execute(DnHexBox dnHexBox)
        {
            var sel = dnHexBox.Selection;

            if (sel == null)
            {
                return;
            }

            var ask = new AskForInput();

            ask.Owner         = MainWindow.Instance;
            ask.Title         = "Enter Value";
            ask.label.Content = "_Byte";
            ask.textBox.Text  = "0xFF";
            ask.ShowDialog();
            if (ask.DialogResult != true)
            {
                return;
            }

            string error;
            byte   b = NumberVMUtils.ParseByte(ask.textBox.Text, byte.MinValue, byte.MaxValue, out error);

            if (!string.IsNullOrEmpty(error))
            {
                MainWindow.Instance.ShowMessageBox(error);
                return;
            }

            dnHexBox.FillBytes(sel.Value.StartOffset, sel.Value.EndOffset, b);
            dnHexBox.Selection = null;
        }