예제 #1
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            using (var openFileDialog1 = new OpenFileDialog())
            {
                //Stream myStream = null;

                openFileDialog1.InitialDirectory = "c:\\";
                openFileDialog1.Filter = "Assembly files (*.s)|*.txt|All files (*.*)|*.*";
                openFileDialog1.FilterIndex = 2;
                openFileDialog1.RestoreDirectory = true;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        myIPE = new IPE(openFileDialog1.FileName);
                        myCPU = new CPU();

                        myIPE.Parse();
                        myCPU.readFile(myIPE.getFileName());
                        refresh();
                        RunButton.Enabled = true;
                        NextInstructionButton.Enabled = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                        RunButton.Enabled = false;
                        NextInstructionButton.Enabled = false;
                    }
                }
            }
        }
예제 #2
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            using (var openFileDialog1 = new OpenFileDialog())
            {
                //Stream myStream = null;

                openFileDialog1.InitialDirectory = "c:\\";
                openFileDialog1.Filter = "Assembly files (*.s)|*.txt|All files (*.*)|*.*";
                openFileDialog1.FilterIndex = 2;
                openFileDialog1.RestoreDirectory = true;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        myIPE = new IPE(openFileDialog1.FileName);
                        myIPE.Parse();
                        myCPU = new CPU(myIPE.getFileName());
                        cpuDone = false;
                        progressBar1.Maximum = myCPU.getLengthOfInstructions() + 2;
                        progressBar1.Value = 0;
                        delayProgressBar.Value = 0;
                        delays = 0;
                        refresh();
                        RunButton.Enabled = true;
                        NextInstructionButton.Enabled = true;

                        myCPU.barrierDone += myCPU_barrierDone;
                        myCPU.programDone += myCPU_programDone;
                        myCPU.PCIncremented += myCPU_PCIncremented;
                        myCPU.delayCycle += myCPU_delayCycle;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                        RunButton.Enabled = false;
                        NextInstructionButton.Enabled = false;
                    }
                }
            }
        }