/SimulatorGui/InputLoad.cs
C# | 54 lines | 49 code | 5 blank | 0 comment | 1 complexity | a9f2d6f73c055eb7129e72061921be07 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using TuringMachine;
-
- namespace SimulatorGui
- {
- public partial class InputLoad : Form
- {
- private TapeControl _tapeControl = null;
- private Controller _controller = null;
- public InputLoad()
- {
- InitializeComponent();
- }
- public InputLoad(ref TapeControl tapeControl, ref Controller controller)
- {
- InitializeComponent();
- _tapeControl = tapeControl;
- _controller = controller;
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- UInt16 i;
- string input;
- try
- {
-
- i = UInt16.Parse(textBox2.Text);
- input = "#" + textBox1.Text;
- if (i<0)
- {
- throw new FormatException();
- }
- _tapeControl.CurrentIndex = i;
- _tapeControl.Text = input;
- _controller.SetTapeIndex(i);
- _controller.SetTapeString(input);
- this.Close();
- }
- catch (FormatException e1)
- {
-
- MessageBox.Show(e1.Message+Environment.NewLine+"Index should be non-negative number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- }
- }
- }