PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/SimulatorGui/InputLoad.cs

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