public static void ShowHex() { var ntop = Application.Top; var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Close", "", () => { running = MainApp; Application.RequestStop(); }, null, null, Key.AltMask | Key.Q), }), }); ntop.Add(menu); string fname = GetFileName(); var win = new Window(fname) { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill() }; ntop.Add(win); var source = System.IO.File.OpenRead(fname); var hex = new HexView(source) { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; win.Add(hex); Application.Run(ntop); }
public static bool IsMultiLineSpan(HexView hexView, HexBufferSpan bufferSpan) { var lineNum1 = hexView.BufferLines.GetLineNumberFromPosition(bufferSpan.Start); var lineNum2 = hexView.BufferLines.GetLineNumberFromPosition(bufferSpan.End); return(lineNum1 != lineNum2); }
public HexViewEditorFormatMap(HexView hexView, TC.EditorFormatMapService editorFormatMapService) : base(editorFormatMapService, DefaultWpfHexViewOptions.AppearanceCategoryName) { this.hexView = hexView ?? throw new ArgumentNullException(nameof(hexView)); hexView.Options.OptionChanged += Options_OptionChanged; Initialize(); }
public void Source_Sets_DisplayStart_And_Position_To_Zero_If_Greater_Than_Source_Length() { var hv = new HexView(LoadStream()) { Width = 10, Height = 5 }; Application.Top.Add(hv); Application.Begin(Application.Top); Assert.True(hv.ProcessKey(new KeyEvent(Key.End, new KeyModifiers()))); Assert.Equal(62, hv.DisplayStart); Assert.Equal(64, hv.Position); hv.Source = new MemoryStream(); Assert.Equal(0, hv.DisplayStart); Assert.Equal(0, hv.Position - 1); hv.Source = LoadStream(); hv.Width = Dim.Fill(); hv.Height = Dim.Fill(); Application.Top.LayoutSubviews(); Assert.Equal(0, hv.DisplayStart); Assert.Equal(0, hv.Position - 1); Assert.True(hv.ProcessKey(new KeyEvent(Key.End, new KeyModifiers()))); Assert.Equal(0, hv.DisplayStart); Assert.Equal(64, hv.Position); hv.Source = new MemoryStream(); Assert.Equal(0, hv.DisplayStart); Assert.Equal(0, hv.Position - 1); }
public HexViewClassificationFormatMap(TC.ClassificationFormatMapService classificationFormatMapService, HexView hexView) : base(classificationFormatMapService, DefaultWpfHexViewOptions.AppearanceCategoryName) { this.hexView = hexView ?? throw new ArgumentNullException(nameof(hexView)); hexView.Options.OptionChanged += Options_OptionChanged; Initialize(); }
public void Position_Using_Encoding_Default() { var hv = new HexView(LoadStream()) { Width = 20, Height = 20 }; Assert.Equal(63, hv.Source.Length); Assert.Equal(63, hv.Source.Position); Assert.Equal(1, hv.Position); // left side needed to press twice Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorRight, new KeyModifiers()))); Assert.Equal(63, hv.Source.Position); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorRight, new KeyModifiers()))); Assert.Equal(63, hv.Source.Position); Assert.Equal(2, hv.Position); // right side only needed to press one time Assert.True(hv.ProcessKey(new KeyEvent(Key.Enter, new KeyModifiers()))); Assert.Equal(63, hv.Source.Position); Assert.Equal(2, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorLeft, new KeyModifiers()))); Assert.Equal(63, hv.Source.Position); Assert.Equal(1, hv.Position); // last position is equal to the source length Assert.True(hv.ProcessKey(new KeyEvent(Key.End, new KeyModifiers()))); Assert.Equal(63, hv.Source.Position); Assert.Equal(64, hv.Position); Assert.Equal(hv.Position - 1, hv.Source.Length); }
public void CursorPosition_Encoding_Default() { var hv = new HexView(LoadStream()) { Width = Dim.Fill(), Height = Dim.Fill() }; Application.Top.Add(hv); Application.Begin(Application.Top); Assert.Equal(new Point(1, 1), hv.CursorPosition); Assert.True(hv.ProcessKey(new KeyEvent(Key.Enter, new KeyModifiers()))); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorRight | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(hv.CursorPosition.X, hv.BytesPerLine); Assert.True(hv.ProcessKey(new KeyEvent(Key.Home, new KeyModifiers()))); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorRight, new KeyModifiers()))); Assert.Equal(new Point(2, 1), hv.CursorPosition); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorDown, new KeyModifiers()))); Assert.Equal(new Point(2, 2), hv.CursorPosition); Assert.True(hv.ProcessKey(new KeyEvent(Key.End, new KeyModifiers()))); var col = hv.CursorPosition.X; var line = hv.CursorPosition.Y; var offset = (line - 1) * (hv.BytesPerLine - col); Assert.Equal(hv.Position, col * line + offset); }
public void TileInitialize(Vector2 position, MapController map) { view = GetComponent <HexView>(); state = TileState.free; this.hexPosition = position; this.map = map; }
public HexQuickInfoSessionImpl(HexView hexView, HexCellPosition triggerPoint, bool trackMouse, HexIntellisensePresenterFactoryService intellisensePresenterFactoryService, Lazy <HexQuickInfoSourceProvider, VSUTIL.IOrderable>[] quickInfoSourceProviders) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } if (triggerPoint.IsDefault) { throw new ArgumentException(); } if (intellisensePresenterFactoryService == null) { throw new ArgumentNullException(nameof(intellisensePresenterFactoryService)); } if (quickInfoSourceProviders == null) { throw new ArgumentNullException(nameof(quickInfoSourceProviders)); } QuickInfoContent = new VSLI.BulkObservableCollection <object>(); HexView = hexView; TriggerPoint = triggerPoint; TrackMouse = trackMouse; this.intellisensePresenterFactoryService = intellisensePresenterFactoryService; this.quickInfoSourceProviders = quickInfoSourceProviders; HexView.Closed += HexView_Closed; }
public static void ShowHex(Toplevel top) { var tframe = top.Frame; var ntop = new Toplevel(tframe); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Close", "", () => { Application.RequestStop(); }), }), }); ntop.Add(menu); var win = new Window("/etc/passwd") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill() }; ntop.Add(win); var source = System.IO.File.OpenRead("/etc/passwd"); var hex = new HexView(source) { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; win.Add(hex); Application.Run(ntop); }
public IEnumerable <IHexTagger <T> > Create <T>(HexView hexView, HexBuffer buffer) where T : HexTag { foreach (var t in Create <T>(buffer)) { yield return(t); } var type = typeof(T); foreach (var info in hexViewTaggerProviders) { if (!(info.Metadata.TextViewRoles is null) && !hexView.Roles.ContainsAny(info.Metadata.TextViewRoles)) { continue; } if (CanCreateTagger(type, info.Metadata.TagTypes)) { var tagger = info.Value.CreateTagger <T>(hexView, buffer); if (!(tagger is null)) { yield return(tagger); } } } }
public override bool Handle(HexView hexView, object reference, IList <string> tags) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } if (reference == null) { throw new ArgumentNullException(nameof(reference)); } reference = ConvertReference(hexView, reference); if (reference == null) { return(false); } if (tags == null) { tags = Array.Empty <string>(); } foreach (var lz in hexReferenceHandlers) { if (lz.Value.Handle(hexView, reference, tags)) { return(true); } } return(false); }
public HexScrollMapImpl(HexView hexView) { HexView = hexView ?? throw new ArgumentNullException(nameof(hexView)); HexView.BufferLinesChanged += HexView_BufferLinesChanged; HexView.LayoutChanged += HexView_LayoutChanged; HexView.Closed += HexView_Closed; }
public override bool Handle(HexView hexView, object reference, IList <string> tags) { bool newTab = tags.Contains(PredefinedHexReferenceHandlerTags.NewTab); documentTabService.FollowReference(reference, newTab: newTab); return(true); }
public HexAndAdornmentSequencerImpl(HexView hexView, HexTagAggregator <HexSpaceNegotiatingAdornmentTag> hexTagAggregator) { this.hexView = hexView ?? throw new ArgumentNullException(nameof(hexView)); this.hexTagAggregator = hexTagAggregator ?? throw new ArgumentNullException(nameof(hexTagAggregator)); hexView.Closed += HexView_Closed; hexTagAggregator.TagsChanged += HexTagAggregator_TagsChanged; }
void OpenBankFile() { var d = new OpenDialog("Open", "Open a Bank File"); Application.Run(d); if (!d.Canceled) { //MessageBox.Query(50, 7, "Selected File", d.FilePath, "OK"); string fname = d.FilePath.ToString(); byte[] data = File.ReadAllBytes(fname); Bank bank = new Bank(data); var source = System.IO.File.OpenRead(fname); var hex = new HexView(source) { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; this.win.Add(hex); } }
public void KeyBindings_Command() { var hv = new HexView(LoadStream()) { Width = 20, Height = 10 }; Application.Top.Add(hv); Application.Begin(Application.Top); Assert.Equal(63, hv.Source.Length); Assert.Equal(1, hv.Position); Assert.Equal(4, hv.BytesPerLine); // right side only needed to press one time Assert.True(hv.ProcessKey(new KeyEvent(Key.Enter, new KeyModifiers()))); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorRight, new KeyModifiers()))); Assert.Equal(2, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorLeft, new KeyModifiers()))); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorDown, new KeyModifiers()))); Assert.Equal(5, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorUp, new KeyModifiers()))); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.V | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(41, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent('v' + Key.AltMask, new KeyModifiers()))); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.PageDown, new KeyModifiers()))); Assert.Equal(41, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.PageUp, new KeyModifiers()))); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.End, new KeyModifiers()))); Assert.Equal(64, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.Home, new KeyModifiers()))); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorRight | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(4, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorLeft | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(1, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorDown | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(37, hv.Position); Assert.True(hv.ProcessKey(new KeyEvent(Key.CursorUp | Key.CtrlMask, new KeyModifiers()))); Assert.Equal(1, hv.Position); }
public override HexClassifier GetClassifier(HexView hexView) { if (hexView is null) { throw new ArgumentNullException(nameof(hexView)); } return(new HexViewClassifierAggregator(hexViewTagAggregatorFactoryService, classificationTypeRegistryService, hexView)); }
public VSTC.IClassificationFormatMap GetClassificationFormatMap(HexView hexView) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } return(hexView.Properties.GetOrCreateSingletonProperty(typeof(TC.ViewClassificationFormatMap), () => CreateViewClassificationFormatMap(hexView))); }
/// <summary> /// Constructor /// </summary> /// <param name="hexView">Hex view</param> public LocalGroupOptions(HexView hexView) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } InitializeFrom(hexView); }
public HexViewContext(HexView hexView) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } HexView = hexView; }
public override HexCommandOperations GetCommandOperations(HexView hexView) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } return(hexView.Properties.GetOrCreateSingletonProperty(typeof(HexCommandOperations), () => new HexCommandOperationsImpl(messageBoxService, hexEditorGroupFactoryService, hexView))); }
public HexCommandOperationsImpl(IMessageBoxService messageBoxService, Lazy <HexEditorGroupFactoryService> hexEditorGroupFactoryService, Lazy <HexBufferFileServiceFactory> hexBufferFileServiceFactory, HexView hexView) { this.messageBoxService = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService)); this.hexEditorGroupFactoryService = hexEditorGroupFactoryService ?? throw new ArgumentNullException(nameof(hexEditorGroupFactoryService)); this.hexBufferFileServiceFactory = hexBufferFileServiceFactory ?? throw new ArgumentNullException(nameof(hexBufferFileServiceFactory)); HexView = hexView ?? throw new ArgumentNullException(nameof(hexView)); hexView.Closed += HexView_Closed; }
public HexViewTagAggregator(HexTaggerFactory hexTaggerFactory, HexView hexView) : base(hexView.Buffer) { this.hexTaggerFactory = hexTaggerFactory; this.hexView = hexView; hexView.Closed += HexView_Closed; Initialize(); }
public override HexToolTipService Get(HexView hexView) { if (hexView == null) { throw new ArgumentNullException(nameof(hexView)); } return(hexView.Properties.GetOrCreateSingletonProperty(typeof(HexToolTipServiceImpl), () => new HexToolTipServiceImpl(viewTagAggregatorFactoryService, hexView))); }
static void RedisplayHexLines(HexView hexView) { var line = hexView.HexViewLines.FirstVisibleLine; var verticalDistance = line.Top - hexView.ViewportTop; var bufferPosition = line.BufferStart; hexView.DisplayHexLineContainingBufferPosition(bufferPosition, verticalDistance, VSTE.ViewRelativePosition.Top, null, null, DisplayHexLineOptions.CanRecreateBufferLines); }
public override HexAndAdornmentSequencer Create(HexView view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } return(view.Properties.GetOrCreateSingletonProperty(typeof(HexAndAdornmentSequencer), () => new HexAndAdornmentSequencerImpl(view, hexViewTagAggregatorFactoryService.CreateTagAggregator <HexSpaceNegotiatingAdornmentTag>(view)))); }
public override HexScrollMap Create(HexView hexView) { if (hexView is null) { throw new ArgumentNullException(nameof(hexView)); } return(new HexScrollMapImpl(hexView)); }
public override bool IsQuickInfoActive(HexView hexView) { if (hexView is null) { throw new ArgumentNullException(nameof(hexView)); } return(GetSessions(hexView).Count != 0); }
void GUIPtr(uint ptr, string parse = "X4") { EditorGUILayout.TextField(ptr.ToString(parse)); if (GUILayout.Button("")) { HexView.InitAtOffset(ptr); } }
private void InitializeComponent() { this.viewer = new HexView(); this.SuspendLayout(); // //viewer // this.viewer.Anchor = (System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.viewer.Location = new System.Drawing.Point(0, 0); this.viewer.Name = "viewer"; this.viewer.Size = new System.Drawing.Size(472, 312); this.viewer.TabIndex = 0; // //HexFileViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(472, 310); this.Controls.Add(this.viewer); this.Name = "HexFileViewer"; this.Text = "File Viewer"; this.ResumeLayout(false); }
/// <summary> /// Creates a <see cref="HexStructureInfoProvider"/> instance /// </summary> /// <param name="hexView">Hex view</param> /// <returns></returns> public abstract HexStructureInfoProvider Create(HexView hexView);
/// <summary> /// Gets the default local options /// </summary> /// <param name="hexView">Hex view</param> /// <returns></returns> public abstract LocalGroupOptions GetDefaultLocalOptions(HexView hexView);
/// <summary> /// Creates a <see cref="HexStructureInfoAggregator"/> instance /// </summary> /// <param name="hexView">Hex view</param> /// <returns></returns> public abstract HexStructureInfoAggregator Create(HexView hexView);
/// <summary> /// Creates a <see cref="HexScrollMap"/> instance /// </summary> /// <param name="hexView">Hex view</param> /// <returns></returns> public abstract HexScrollMap Create(HexView hexView);
public HexEditor (string tagName, byte[] data, int bytesPerElem) { InitializeComponent(); EditView textView = new TextView(statusStrip1, bytesPerElem); textView.Initialize(); textView.SetRawData(data); textView.Modified += (s, e) => { _modified = true; }; _views.Add(textView.TabPage, textView); viewTabs.TabPages.Add(textView.TabPage); EditView hexView = null; if (!IsMono()) { hexView = new HexView(statusStrip1, bytesPerElem); hexView.Initialize(); hexView.SetRawData(data); hexView.Modified += (s, e) => { _modified = true; }; _views.Add(hexView.TabPage, hexView); viewTabs.TabPages.Add(hexView.TabPage); } if (bytesPerElem > 1 || IsMono()) { textView.Activate(); viewTabs.SelectedTab = textView.TabPage; } else { hexView.Activate(); viewTabs.SelectedTab = hexView.TabPage; } viewTabs.Deselected += (o, e) => { _previousPage = e.TabPage; }; viewTabs.Selecting += HandleTabChanged; this.Text = "Editing: " + tagName; _bytesPerElem = bytesPerElem; _data = new byte[data.Length]; Array.Copy(data, _data, data.Length); }
private void InitializeComponent() { this.StatusBar1 = new System.Windows.Forms.StatusBar(); this.pnlCurrentSector = new System.Windows.Forms.StatusBarPanel(); this.pnlTotalSectors = new System.Windows.Forms.StatusBarPanel(); this.UIPrevSector = new System.Windows.Forms.Button(); this.UINextSector = new System.Windows.Forms.Button(); this.UISector = new System.Windows.Forms.TextBox(); this.UIFirstSector = new System.Windows.Forms.Button(); this.UILastSector = new System.Windows.Forms.Button(); this.viewer = new HexView(); ((System.ComponentModel.ISupportInitialize)(this.pnlCurrentSector)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pnlTotalSectors)).BeginInit(); this.SuspendLayout(); // // StatusBar1 // this.StatusBar1.Location = new System.Drawing.Point(0, 281); this.StatusBar1.Name = "StatusBar1"; this.StatusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { this.pnlCurrentSector, this.pnlTotalSectors}); this.StatusBar1.ShowPanels = true; this.StatusBar1.Size = new System.Drawing.Size(544, 24); this.StatusBar1.TabIndex = 4; this.StatusBar1.Text = "StatusBar1"; // // pnlCurrentSector // this.pnlCurrentSector.Name = "pnlCurrentSector"; // // pnlTotalSectors // this.pnlTotalSectors.Name = "pnlTotalSectors"; // // UIPrevSector // this.UIPrevSector.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.UIPrevSector.Location = new System.Drawing.Point(221, 255); this.UIPrevSector.Name = "UIPrevSector"; this.UIPrevSector.Size = new System.Drawing.Size(24, 20); this.UIPrevSector.TabIndex = 6; this.UIPrevSector.Text = "<"; this.UIPrevSector.Click += new System.EventHandler(this.UIPrevSector_Click); // // UINextSector // this.UINextSector.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.UINextSector.Location = new System.Drawing.Point(299, 255); this.UINextSector.Name = "UINextSector"; this.UINextSector.Size = new System.Drawing.Size(24, 20); this.UINextSector.TabIndex = 7; this.UINextSector.Text = ">"; this.UINextSector.Click += new System.EventHandler(this.UINextSector_Click); // // UISector // this.UISector.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.UISector.Location = new System.Drawing.Point(246, 256); this.UISector.Name = "UISector"; this.UISector.Size = new System.Drawing.Size(52, 20); this.UISector.TabIndex = 9; this.UISector.TextChanged += new System.EventHandler(this.UISector_TextChanged); // // UIFirstSector // this.UIFirstSector.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.UIFirstSector.Location = new System.Drawing.Point(195, 255); this.UIFirstSector.Name = "UIFirstSector"; this.UIFirstSector.Size = new System.Drawing.Size(24, 20); this.UIFirstSector.TabIndex = 10; this.UIFirstSector.Text = "|<"; this.UIFirstSector.Click += new System.EventHandler(this.UIFirstSector_Click); // // UILastSector // this.UILastSector.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.UILastSector.Location = new System.Drawing.Point(325, 255); this.UILastSector.Name = "UILastSector"; this.UILastSector.Size = new System.Drawing.Size(24, 20); this.UILastSector.TabIndex = 11; this.UILastSector.Text = ">|"; this.UILastSector.Click += new System.EventHandler(this.UILastSector_Click); // // viewer // this.viewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.viewer.Location = new System.Drawing.Point(0, 0); this.viewer.Name = "viewer"; this.viewer.Size = new System.Drawing.Size(544, 249); this.viewer.TabIndex = 8; // // SectorViewer // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(544, 305); this.Controls.Add(this.UILastSector); this.Controls.Add(this.UIFirstSector); this.Controls.Add(this.UISector); this.Controls.Add(this.viewer); this.Controls.Add(this.UINextSector); this.Controls.Add(this.UIPrevSector); this.Controls.Add(this.StatusBar1); this.Name = "SectorViewer"; this.Text = "Sector Viewer"; this.Load += new System.EventHandler(this.SectorViewer_Load); ((System.ComponentModel.ISupportInitialize)(this.pnlCurrentSector)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pnlTotalSectors)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }
/// <summary> /// Gets the hex view's <see cref="HexEditorOperations"/> instance /// </summary> /// <param name="hexView">Hex view</param> /// <returns></returns> public abstract HexEditorOperations GetEditorOperations(HexView hexView);