PageRenderTime 224ms CodeModel.GetById 157ms app.highlight 3ms RepoModel.GetById 62ms app.codeStats 0ms

/SimulatorGui/InputLoad.cs

#
C# | 54 lines | 49 code | 5 blank | 0 comment | 1 complexity | a9f2d6f73c055eb7129e72061921be07 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.ComponentModel;
 4using System.Data;
 5using System.Drawing;
 6using System.Text;
 7using System.Windows.Forms;
 8using TuringMachine;
 9
10namespace SimulatorGui
11{
12    public partial class InputLoad : Form
13    {
14        private TapeControl _tapeControl = null;
15        private Controller _controller = null;
16        public InputLoad()
17        {
18            InitializeComponent();
19        }
20        public InputLoad(ref TapeControl tapeControl, ref Controller controller)
21        {
22            InitializeComponent();
23            _tapeControl = tapeControl;
24            _controller = controller;
25        }
26
27        private void button1_Click(object sender, EventArgs e)
28        {
29            UInt16 i;
30            string input;
31            try
32            {
33                
34                i = UInt16.Parse(textBox2.Text);
35                input = "#" + textBox1.Text;
36                if (i<0)
37                {
38                    throw new FormatException();
39                }
40                _tapeControl.CurrentIndex = i;
41                _tapeControl.Text = input;
42                _controller.SetTapeIndex(i);
43                _controller.SetTapeString(input);
44                this.Close();
45            }
46            catch (FormatException e1)
47            {
48
49                MessageBox.Show(e1.Message+Environment.NewLine+"Index should be non-negative number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
50            }
51           
52        }
53    }
54}