Beispiel #1
0
		public void CopyTo(HexTabState tabState) {
			tabState.BytesGroupCount = this.BytesGroupCount;
			tabState.BytesPerLine = this.BytesPerLine;
			tabState.UseHexPrefix = this.UseHexPrefix;
			tabState.ShowAscii = this.ShowAscii;
			tabState.LowerCaseHex = this.LowerCaseHex;
			tabState.AsciiEncoding = this.AsciiEncoding;
			tabState.HexBox.HexOffsetSize = this.HexOffsetSize;
			tabState.HexBox.UseRelativeOffsets = this.UseRelativeOffsets;
			tabState.HexBox.BaseOffset = this.BaseOffset;
			tabState.HexBox.StartOffset = this.StartOffset ?? tabState.DocumentStartOffset;
			tabState.HexBox.EndOffset = this.EndOffset ?? tabState.DocumentEndOffset;
		}
Beispiel #2
0
		public LocalHexSettings(HexTabState tabState) {
			this.BytesGroupCount = tabState.BytesGroupCount;
			this.BytesPerLine = tabState.BytesPerLine;
			this.UseHexPrefix = tabState.UseHexPrefix;
			this.ShowAscii = tabState.ShowAscii;
			this.LowerCaseHex = tabState.LowerCaseHex;
			this.AsciiEncoding = tabState.AsciiEncoding;
			this.HexOffsetSize = tabState.HexBox.HexOffsetSize;
			this.UseRelativeOffsets = tabState.HexBox.UseRelativeOffsets;
			this.BaseOffset = tabState.HexBox.BaseOffset;
			this.StartOffset = tabState.HexBox.StartOffset == tabState.DocumentStartOffset ? (ulong?)null : tabState.HexBox.StartOffset;
			this.EndOffset = tabState.HexBox.EndOffset == tabState.DocumentEndOffset ? (ulong?)null : tabState.HexBox.EndOffset;
		}
Beispiel #3
0
 HexTabState CreateNewHexTabState(TabManager<TabState> tabManager)
 {
     var tabState = new HexTabState();
     return (HexTabState)tabManager.AddNewTabState(tabState);
 }
Beispiel #4
0
        protected override void Execute(HexTabState tabState)
        {
            var doc = tabState.HexBox.Document;
            if (doc == null)
                return;
            var sel = tabState.HexBox.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 filename = dialog.FileName;
            try {
                using (var file = File.Create(filename))
                    Write(doc, file, sel.Value.StartOffset, sel.Value.EndOffset);
            }
            catch (Exception ex) {
                MainWindow.Instance.ShowMessageBox(string.Format("Could not save '{0}'\nERROR: {1}", filename, ex.Message));
            }
        }
Beispiel #5
0
 protected override bool IsEnabled(HexTabState tabState)
 {
     return tabState.HexBox.CanPasteUtf8();
 }
Beispiel #6
0
 protected override void Initialize(HexTabState tabState, MenuItem menuItem)
 {
     foreach (var info in subMenus) {
         var mi = new MenuItem {
             Header = info.Item2,
             IsChecked = info.Item1 == tabState.BytesPerLine,
         };
         var tmpInfo = info;
         mi.Click += (s, e) => tabState.BytesPerLine = tmpInfo.Item1;
         menuItem.Items.Add(mi);
     }
 }
Beispiel #7
0
        static void Execute2(HexTabState tabState)
        {
            if (!CanExecute(tabState))
                return;

            var data = GetBlobData(ClipboardUtils.GetData());
            if (data != null)
                tabState.HexBox.Paste(data);
        }
Beispiel #8
0
 protected override bool IsEnabled(HexTabState tabState)
 {
     return CanExecute(tabState);
 }
Beispiel #9
0
 protected override bool IsVisible(HexTabState tabState)
 {
     return CanExecute(tabState);
 }
Beispiel #10
0
 protected override void Execute(HexTabState tabState)
 {
     tabState.HexBox.CopyVBArray();
 }
Beispiel #11
0
 protected override void Execute(HexTabState tabState)
 {
     tabState.HexBox.CopyUTF8String();
 }
Beispiel #12
0
 protected override void Execute(HexTabState tabState)
 {
     tabState.HexBox.CopyUIContents();
 }
Beispiel #13
0
 protected override bool IsEnabled(HexTabState tabState)
 {
     return tabState.HexBox.Selection != null;
 }
Beispiel #14
0
        protected override void Execute(HexTabState tabState)
        {
            var sel = tabState.HexBox.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;
            }

            tabState.HexBox.FillBytes(sel.Value.StartOffset, sel.Value.EndOffset, b);
            tabState.HexBox.Selection = null;
        }
Beispiel #15
0
 protected override void Execute(HexTabState tabState)
 {
     tabState.HexBox.CopyOffset();
 }
Beispiel #16
0
 protected override void Execute(HexTabState tabState)
 {
     tabState.LowerCaseHex = !(tabState.LowerCaseHex ?? HexSettings.Instance.LowerCaseHex);
 }
Beispiel #17
0
 protected override void Initialize(HexTabState tabState, MenuItem menuItem)
 {
     menuItem.IsChecked = tabState.LowerCaseHex ?? HexSettings.Instance.LowerCaseHex;
 }
Beispiel #18
0
 static bool CanExecute(HexTabState tabState)
 {
     return tabState != null;
 }
Beispiel #19
0
 static bool CanExecute(HexTabState tabState)
 {
     return tabState != null && GetBlobData(ClipboardUtils.GetData()) != null;
 }
Beispiel #20
0
        static void Execute2(HexTabState tabState)
        {
            if (!CanExecute(tabState))
                return;

            var hb = tabState.HexBox;
            var data = new GoToOffsetVM(hb.PhysicalToVisibleOffset(hb.CaretPosition.Offset), hb.PhysicalToVisibleOffset(hb.StartOffset), hb.PhysicalToVisibleOffset(hb.EndOffset));
            var win = new GoToOffsetDlg();
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            hb.CaretPosition = new HexBoxPosition(hb.VisibleToPhysicalOffset(data.OffsetVM.Value), hb.CaretPosition.Kind, 0);
        }
Beispiel #21
0
 protected override void Execute(HexTabState tabState)
 {
 }
Beispiel #22
0
 protected abstract void Execute(HexTabState tabState);
Beispiel #23
0
 protected override void Execute(HexTabState tabState)
 {
     tabState.HexBox.PasteUtf8();
 }
Beispiel #24
0
 protected virtual void Initialize(HexTabState tabState, MenuItem menuItem)
 {
 }
Beispiel #25
0
 protected override bool IsVisible(HexTabState tabState)
 {
     return true;
 }
Beispiel #26
0
 protected virtual bool IsEnabled(HexTabState tabState)
 {
     return IsVisible(tabState);
 }
Beispiel #27
0
 HexTabState CreateHexTabState(HexTabState tabState, SavedHexTabState savedHexTabState)
 {
     tabState.Restore(savedHexTabState);
     return InitializeHexDocument(tabState, savedHexTabState.FileName);
 }
Beispiel #28
0
 protected abstract bool IsVisible(HexTabState tabState);
Beispiel #29
0
 HexTabState InitializeHexDocument(HexTabState tabState, string filename)
 {
     var doc = HexDocumentManager.Instance.GetOrCreate(filename);
     tabState.SetDocument(doc);
     if (doc == null)
         ShowIgnorableMessageBox("hex: load doc err", string.Format("Error loading {0}", filename), MessageBoxButton.OK);
     return tabState;
 }
Beispiel #30
0
        protected override void Execute(HexTabState tabState)
        {
            var data = new LocalSettingsVM(new LocalHexSettings(tabState));
            var win = new LocalSettingsDlg();
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            data.CreateLocalHexSettings().CopyTo(tabState);
        }