public MainForm()
        {
            InitializeComponent();
            hexBox.ByteProvider = _dbp = new FixedByteProvider(eeprom);

            _dbp.Changed += new EventHandler(onDataProviderChanged);            // No point doing something every time this changes, as it only alerts to the fact that something has changed and not what specific byte has changed
        }
        private void btnRead_Click(object sender, EventArgs e)
        {
            CommPrgForm commPrgForm = new CommPrgForm();

            commPrgForm.StartPosition = FormStartPosition.CenterParent;
            commPrgForm.IsRead        = true;
            MainForm.startAddress     = int.Parse(txtStartAddr.Text, System.Globalization.NumberStyles.HexNumber);
            if (MainForm.startAddress % 32 != 0)
            {
                MessageBox.Show("Start address must be a multiple of 0x20");
                return;
            }

            MainForm.transferLength = int.Parse(txtLen.Text, System.Globalization.NumberStyles.HexNumber);
            if (MainForm.transferLength == 0)
            {
                MessageBox.Show("Length cant be zero");
                return;
            }
            if (MainForm.transferLength % 32 != 0)
            {
                MessageBox.Show("Length must be a multplie of 0x20");
                return;
            }

            if (MainForm.startAddress + MainForm.transferLength > MainForm.eeprom.Length)
            {
                MessageBox.Show("Start address and length settings would result in reading beyond the end of memory");
                return;
            }
            commPrgForm.ShowDialog();
            hexBox.ByteProvider = _dbp = new FixedByteProvider(eeprom);
            _hexboxHasChanged   = false;
        }
Ejemplo n.º 3
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "binary files (*.bin)|*.bin|All files (*.*)|*.*";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    byte [] tmp = File.ReadAllBytes(openFileDialog1.FileName);
                    if (tmp.Length != MainForm.CommsBuffer.Length)
                    {
                        MessageBox.Show("File is smaller than the size of the flash memory.\nOnly the fisrt " + tmp.Length + " bytes have been updated", "Warning");
                    }
                    CommsBuffer = new byte[1024 * 1024];                    // Clear the whole memory buffer my making a new one.
                    tmp.CopyTo(MainForm.CommsBuffer, 0);                    // copy the new data into the empty buffer
                    MainForm.FileName        = openFileDialog1.FileName;
                    MainForm.ActiveForm.Text = AppName + " - Current File: " + FileName;
                    hexBox.ByteProvider      = _dbp = new FixedByteProvider(CommsBuffer);
                    _hexboxHasChanged        = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
        private void btnCalibration_Click(object sender, EventArgs e)
        {
            CalibrationForm cf = new CalibrationForm();

            cf.ShowDialog();
            hexBox.ByteProvider = _dbp = new FixedByteProvider(CommsBuffer);
            hexBox.ScrollByteToTop(0x8F000);
        }
Ejemplo n.º 5
0
        public MainForm()
        {
            InitializeComponent();
            // Hide calibration from normal users
            this.btnReadCalibration.Visible  = false;
            this.btnWriteCalibration.Visible = false;
            this.btnCalibration.Visible      = false;

            hexBox.ByteProvider = _dbp = new FixedByteProvider(CommsBuffer);

            _dbp.Changed += new EventHandler(onDataProviderChanged);            // No point doing something every time this changes, as it only alerts to the fact that something has changed and not what specific byte has changed
        }
Ejemplo n.º 6
0
        private void btnReadCalibration_Click(object sender, EventArgs e)
        {
            CommPrgForm commPrgForm = new CommPrgForm();

            commPrgForm.StartPosition = FormStartPosition.CenterParent;
            commPrgForm.IsRead        = true;
            MainForm.startAddress     = 0x80000;
            MainForm.transferLength   = 0x10000;
            commPrgForm.ShowDialog();
            hexBox.ByteProvider = _dbp = new FixedByteProvider(CommsBuffer);
            hexBox.ScrollByteToTop(0x8F000);
            _hexboxHasChanged = false;
        }
Ejemplo n.º 7
0
        private void btnCalibration_Click(object sender, EventArgs e)
        {
            int offsetAddress = 0x8F000;

            if (Control.ModifierKeys == Keys.Shift)
            {
                offsetAddress = 0x50100;
            }
            CalibrationForm cf = new CalibrationForm(offsetAddress);

            cf.ShowDialog();
            hexBox.ByteProvider = _dbp = new FixedByteProvider(CommsBuffer);
            hexBox.ScrollByteToTop(0x8F000);
        }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "binary files (*.bin)|*.bin|All files (*.*)|*.*";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    MainForm.eeprom     = File.ReadAllBytes(openFileDialog1.FileName);
                    hexBox.ByteProvider = _dbp = new FixedByteProvider(eeprom);
                    _hexboxHasChanged   = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Ejemplo n.º 9
0
        private void mergeFile()
        {
            byte[]         tmp;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "binary files (*.bin)|*.bin|All files (*.*)|*.*";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    tmp = File.ReadAllBytes(openFileDialog1.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                    return;
                }
                MainForm.FileName        = openFileDialog1.FileName;
                MainForm.ActiveForm.Text = AppName + " - Current File: " + FileName;
                MergeFileForm mff = new MergeFileForm();

                if (DialogResult.OK == mff.ShowDialog())
                {
                    try
                    {
                        tmp.CopyTo(MainForm.CommsBuffer, int.Parse(mff.MergeAddress, System.Globalization.NumberStyles.HexNumber));

                        hexBox.ByteProvider = _dbp = new FixedByteProvider(CommsBuffer);
                        _hexboxHasChanged   = false;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Data could be merged.  System error: " + ex.Message);
                    }
                }
            }
        }