コード例 #1
0
        private void txtValue_TextChanged(object sender, EventArgs e)
        {
            if (boxChange)
            {
                return;
            }
            txtValue.Text = txtValue.Text.ToUpper();
            for (int i = 0; i < txtValue.Text.Length; i++)
            {
                if (txtValue.Text[i] != '0' &&
                    txtValue.Text[i] != '1' &&
                    txtValue.Text[i] != '2' &&
                    txtValue.Text[i] != '3' &&
                    txtValue.Text[i] != '4' &&
                    txtValue.Text[i] != '5' &&
                    txtValue.Text[i] != '6' &&
                    txtValue.Text[i] != '7' &&
                    txtValue.Text[i] != '8' &&
                    txtValue.Text[i] != '9' &&
                    txtValue.Text[i] != 'A' &&
                    txtValue.Text[i] != 'B' &&
                    txtValue.Text[i] != 'C' &&
                    txtValue.Text[i] != 'D' &&
                    txtValue.Text[i] != 'E' &&
                    txtValue.Text[i] != 'F')
                {
                    txtValue.Text = txtValue.Text.Remove(i, 1);
                    i--;
                }
            }
            txtValue.SelectionStart  = txtValue.Text.Length;
            txtValue.SelectionLength = 0;
            txtAddress.Text          = txtAddress.Text.ToUpper();
            for (int i = 0; i < txtAddress.Text.Length; i++)
            {
                if (txtAddress.Text[i] != '0' &&
                    txtAddress.Text[i] != '1' &&
                    txtAddress.Text[i] != '2' &&
                    txtAddress.Text[i] != '3' &&
                    txtAddress.Text[i] != '4' &&
                    txtAddress.Text[i] != '5' &&
                    txtAddress.Text[i] != '6' &&
                    txtAddress.Text[i] != '7' &&
                    txtAddress.Text[i] != '8' &&
                    txtAddress.Text[i] != '9' &&
                    txtAddress.Text[i] != 'A' &&
                    txtAddress.Text[i] != 'B' &&
                    txtAddress.Text[i] != 'C' &&
                    txtAddress.Text[i] != 'D' &&
                    txtAddress.Text[i] != 'E' &&
                    txtAddress.Text[i] != 'F')
                {
                    txtAddress.Text = txtAddress.Text.Remove(i, 1);
                    i--;
                }
            }
            txtAddress.SelectionStart  = txtAddress.Text.Length;
            txtAddress.SelectionLength = 0;
            int value = 0;

            if (txtValue.Text != "")
            {
                value = int.Parse(txtValue.Text, System.Globalization.NumberStyles.HexNumber, null);
            }
            int address = 0;

            if (txtAddress.Text != "")
            {
                address = int.Parse(txtAddress.Text, System.Globalization.NumberStyles.HexNumber, null);
            }
            boxChange = true;
            if (address < 0x8000 || address > 0xFFFF || value < 0x00 || value > 0xFF)
            {
                txtCode.Text = "";
            }
            else
            {
                txtCode.Text = GameGenie.CreateCode(address, value);
            }
            boxChange = false;
        }