Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Some time ago I have to find any out of shelf WPF control for editing hex files.

I found really interesting and useful application for editing hex files: http://sourceforge.net/projects/hexbox/[^]

Although this control is written in WindowsForms I managed to use it in my solution via WindowsHosted functionality.

Recently because of some issues related to Airspace problem WPF[^] I decide to learn how to rewrite it to WPF.

A hosted Windows Forms control is drawn in a separate HWND, so it is always drawn on top of WPF elements.

Therefore I wonder how above Be.Hex control could be rewritten into WPF.

Is it possible?

Be.Hex implementation is really great. It contains all functionality such as editing ASCII part or directly Bytes part.

It looks quite complex, it contains many Windows.Forms handled events.
But thing that seems to be even more difficult to rewrite in WPF is:
delegate bool MessageDelegate(ref Message m);


Would anybody give me any advise how to implement such app in WPF.
I considered Grid at the beginning, or even Custom Grid.
Another thing to consider would be RichTextBox.

I would like to have somes tips, hints. I consider writing such app as a great way of learning WPF.
Posted
Updated 7-Nov-14 8:32am
v2

1 solution

It's possible just because there is nothing too sophisticated with hex editors.

Basically, forget about all Forms stuff; you will need to write it all from scratch. At best, you can use part of the Forms code for reference, and use some code fully abstracted from UI, such as pure calculations. WPF is fundamentally different, despite of many controls which are named in the same way as in Forms and behave very similarly. First of all, forget about events; with Forms, most UI events are based on Windows messages; but WPF doesn't do message pumping except the most low-level (input) messages at the level of top window. You can read about WPF implementation architecture in MSDN, but development doesn't really require that.

Anyway, if you have particular concerns, your questions will be welcome.

—SA
 
Share this answer
 
Comments
meOneKey 7-Nov-14 14:53pm    
Thanks for really interesting comment. Anyway, I would be thankful if you could give me a hint how to start. Should I use custom control. What would be your suggestion. Thanks in advance.
Sergey Alexandrovich Kryukov 7-Nov-14 15:14pm    
Why everyone asks where to start? I does not matter much. Well, start from the formal description of at least the major requirements. There can be many difference ways to start. I would rather be concerned if you can continue. :-)
Please, if you have some particular concerns, I'll answer.
—SA
meOneKey 7-Nov-14 15:54pm    
Yes you are right. To be honest I thought about Grid which would be filled with textboxes, but then I realized that I it will not have text selection.
Now I think that I should Use DataGrid with 3 colums, one for left index, middle for binding to hex bytes and on the right would be ASCII text. Another option I consider is RichTextBox. But I think it will not be easy to match selected text in HEX part with same text in ASCII part of potential solution. Learning by doing will be best solution. I will let you know if I can or cannot continue in the future. Thanks for any support and given ideas.
Sergey Alexandrovich Kryukov 7-Nov-14 16:03pm    
Maybe you can be better off by starting with the class FlowDocument...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900