abbaye / WpfHexEditorControl

Wpf Hexeditor is a powerful and fully customisable user control for editing file or stream as hexadecimal, decimal and binary. Can be used in Wpf or WinForm application
https://www.nuget.org/packages/WPFHexaEditor/
Apache License 2.0
813 stars 135 forks source link

Ability to insert bytes everywhere #31

Open Mgamerz opened 6 years ago

Mgamerz commented 6 years ago

Expected Behavior

Using insert mode (Insert key) should allow me to insert bytes in at arbitrary points. I should be able to press backspace or delete to erase bytes, rather than reset to them to zero.

Actual Behavior

Insert doesn't seem to be possible, only appending. Deleting bytes, from what I can tell, just reset them to zero rather than actually wiping them.

Steps to Reproduce the Problem

Try to use insert or backspace/delete for bytes. It does not work.

abbaye commented 6 years ago

For info : Alway use HexaEditor You should not use DrawedHexEditor because it's a alpha stage.

The actual version support delete (anywhere) and insert byte (EOF only).

When you delete the byte reset to zero and turn to red... the byte will be really deleted when you save change to you file/stream

Mgamerz commented 6 years ago

Would there be a way to add bytes via insert? Or have a toggle that will hide deleted bytes, even if I have not committed the actual backing stream?

abbaye commented 6 years ago

Not for now but soon :)

abbaye commented 6 years ago

Project are made in me free time

abbaye commented 5 years ago

Now you can insert byte at end of file.

When I have more time I will add the ability to insert byte anywhere

vector-man commented 5 years ago

@Mgamerz I plan on making dialogs for this for now. Might be a workaround for you. Something like the following: https://www.sweetscape.com/010editor/manual/InsertBytes.htm

abbaye commented 5 years ago

It's a good idea and a good solution for insert byte anywhere.

I think I can make a real-time insert bytes in control. (I just need more free time for me...)

Mgamerz commented 5 years ago

Unfortunately, I just used Be.Hexbox in a hosted control, and for the most part have completed my project. It works, for the most part.

vector-man commented 5 years ago

@abbaye I have not thoroughly examined the ByteProvider, but I'm thinking something like this:

Add a List called _insertions Add a long called _insertionStart When insert key is pressed, the UI enters insertion mode, _insertionStart is set to caret position offset. When typing in insertion mode, add the bytes, not directly to the stream, but to the _insertion list.

When doing rendering: Render everything from the start of the stream before the offset of _insertionStart , followed by everything in _insertions (up until _insertionStart + _insertion.Count()), finally everything in the stream at the offset _insertionStart. This will give the appearance that data is inserted in the UI.

When insertion is ended, we can update the stream by

  1. Resizing the stream length to length + _insertionCount (zero fill the end)
  2. Overwriting the stream at offset _insertionStart + _insertion.Count() with copied stream data at offset _insertionStart (not reading from _insertions, but the actual stream). This will create room for step3
  3. Seeking back to _insertionStart and writing _insertions data

Just an idea.

abbaye commented 5 years ago

Hi vector-man.

Yes is a think like this. :)

I'm at the end of my University's session (ending ~17 April). After that I will can work on insert byte (everywhere)

WrongBit commented 3 years ago

Any progress on ADDING ONE BYTE??? :) It's ridiculous, heh... Standard editing function and so much awaiting. One more note: control sources look overbloated for such simplistic task - edit hex bytes! And sorry, but better you made "adding byte" function than waste time on... translation! If you edit HEX, you definitely KNOW english!

abbaye commented 3 years ago

Hi @WrongBit

I know that inserting byte is a basic function ... but I build this control for fun and when I have free time in my real life (I have one 😅). Adding this bug-free feature takes a long time and I don't have much at the moment. I hope to be able to work on this function this winter.

For your information: Some features I added were added because they were quick to implement.

On the other hand, if you want to code the functionality and send a "pull resquest" 😀 I will be happy to add it later ...

PS: It is more interesting to contribute in a project than to send this type of message to a guy who gives his time for free. Your Github profile is empty, you should probably have some time to code the byte insertion. 😅😁

kind regards...

vector-man commented 1 year ago

Hey there. I think I'm going to take try at adding this feature soon. If I do, I'll send a pull request after I get it working well.

abbaye commented 1 year ago

Thank you very much!

I want to work on this project but I'm working on the last 6 months over 70 by week. 😵‍💫😅

Thank for you help