This project is read-only.

Usage

To use the control, author must provide an implementation of the IByteProvider interface. The key part is that after you set the model's IByteProvider property, you have to update the view to reflect changes using the UpdateView() method of the HexControl control.

        class ByteProvider : IByteProvider
        {
            private byte[] bytes;

            public ByteProvider(byte[] bytes)
            {
                this.bytes = bytes;
            }

            public byte GetByte(int offset)
            {
                return bytes[offset];
            }

            public int Length
            {
                get { return bytes.Length; }
            }
        }

Example

This is an initialization of a custom font collection for a form and a byte provider data, in form constructor:

            try
            {
                pfc = new PrivateFontCollection();
                pfc.AddFontFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "fonts\\consola.ttf"));
                this.Font = new Font(pfc.Families[0], 8.25f);
                this.bottom0.Model.ByteProvider = new ByteProvider(memory.bytes);
                this.bottom0.UpdateView();
            }
            catch (FileNotFoundException)
            {
            }

Last edited May 1, 2012 at 3:44 AM by hack2root, version 9

Comments

No comments yet.