HexControl

Public function to get actual data and render the blocks of bytes, provided by the IByteProvider implementation. Full control redraw is implemented in OnPaint() override method.

scrollable-area.png

DrawBlock()

HexView is capable of rendering on-demand for the selected byte offset, rather than totally redraw itself to reflect data changes. Tracking actual data changes is completely outside of the scope of the responsibility of a rendering control.

        public void DrawBlock(int byteIndex)
        {
            hexView1.DrawBlock(byteIndex);
        }

UpdateView()

UpdateView() method calls the HexView's UpdateModel() which is is used to measure two rendering block type sizes: one for the legend and the other for the byte group (column). Following code controls the visibility of the scroll bars:

        public void UpdateView()
        {
            hexView1.UpdateModel();
            int visibleColumns = hexView1.GetVisibleColumns();
            int visibleRows = hexView1.GetVisibleRows();
            if (visibleColumns < hexView1.Model.MaxColumns)
            {
                this.hexView1.Model.Column = 0;
                this.hScrollBar1.Minimum = 0;
                this.hScrollBar1.Value = 0;
                this.hScrollBar1.Maximum = hexView1.Model.MaxColumns - visibleColumns;
                this.hScrollBar1.Visible = true;
            }
            else
            {
                this.hScrollBar1.Visible = false;
            }
            if (visibleRows < hexView1.Model.MaxRows)
            {
                this.hexView1.Model.Row = 0;
                this.vScrollBar1.Minimum = 0;
                this.vScrollBar1.Value = 0;
                this.vScrollBar1.Maximum = hexView1.Model.MaxRows - visibleRows;
                this.vScrollBar1.Visible = true;
            }
            else
            {
                this.vScrollBar1.Visible = false;
            }
            hexView1.Invalidate();
        }

Last edited May 1, 2012 at 3:35 AM by hack2root, version 15

Comments

No comments yet.