Exemple #1
0
        private void loadFormControls()
        {
            hexRows = new HexRow[nRows];
            int i = 0;

            for (; i < nRows; i++)
            {
                hexRows[i]          = new HexRow(startAddress + (16 * i), this);
                hexRows[i].Location = new Point(0, (HexRow.sizeY * i));
                hex_panel.Controls.Add(hexRows[i]);
            }

            modAddressControl          = new ModAddressControl(modAddress, true);
            modAddressControl.Location = new Point(0, 0);
            mod_panel.Controls.Add(modAddressControl);
            modAddressControl.lbl_name.Text = selectedAddress.ToString("X8");

            timer1.Start();
        }
Exemple #2
0
        private void highlightSelectedAddress(Int32 address, int bytes, bool resetList) //rewrite this
        {
            if (resetList)
            {
                //unhighlight currently selected textboxes and clear list
                highlightSelectedTextBoxes(false);
                highlightedTextBoxes.Clear();
            }

            if (startAddress + (hexRows.Length * 16) > selectedAddress &&
                selectedAddress + bytes > startAddress) //if a selected byte is visible on the screen
            {
                //select hexRow containing selected address
                HexRow hexRow             = null;
                int    hexRowStartIndex   = -1;
                int    hexRowStartAddress = -1;
                for (int i = 0; i < hexRows.Length; i++)
                {
                    hexRowStartAddress = trimAddress(selectedAddress);
                    if (hexRowStartAddress == hexRows[i].startAddress)
                    {
                        hexRowStartIndex = i;
                        hexRow           = hexRows[i];
                        break;
                    }
                }

                //highlight selected bytes
                int byteOffset           = selectedAddress - hexRowStartAddress;
                int totalHexRows         = ((bytes + byteOffset) / 16) + 1;
                int totalLeftToHighlight = bytes;

                for (int j = 0; j < totalHexRows; j++)             //for each row
                {
                    if (hexRowStartIndex + j > hexRows.Length - 1) //the following bytes are off screen
                    {
                        break;
                    }
                    else if (hexRowStartIndex + j < 0) //selected address is above the screen
                    {
                        //subtract bytes that are not visible and reset offset and start index to 0 (first visible textbox)
                        int firstVisibleAddress = hexRows[0].startAddress;
                        int differenceInBytes   = firstVisibleAddress - selectedAddress;
                        bytes           -= differenceInBytes;
                        byteOffset       = 0;
                        hexRowStartIndex = 0;

                        totalHexRows--;
                    }

                    for (int i = byteOffset; i < bytes + byteOffset && totalLeftToHighlight > 0; i++) //for each byte
                    {
                        if (i <= 15)
                        {
                            TextBox tb = hexRows[hexRowStartIndex + j].getByteTextBox(i);
                            highlightTextBox(tb, true);
                            highlightedTextBoxes.Add(tb);
                            totalLeftToHighlight--;
                        }
                        else
                        {
                            //start on new row
                            byteOffset = 0;
                        }
                    }
                }
            }
        }