/// <summary> /// Конструктор формы /// </summary> public MainForm() { InitializeComponent(); _Laser = new LaserSource(new Point((int)numericUpDownLaserPosX.Value,(int)numericUpDownLaserPosY.Value), new Point(5,5)); _Mirrors = new List<Point>(); _Holes = new List<Point>(); _Goals = new List<Point>(); _Game = new LasersGame(_FieldWidth, _FieldHeight); timer1.Start(); }
/// <summary> /// Конструктор класса /// </summary> /// <param name="parGame"></param> public LaserGameSolver(LasersGame parGame) : base(parGame) { _Task = parGame; _Mirrors = _Task.Mirrors; _Holes = _Task.Holes; _Goals = _Task.Goals; _Laser = _Task.Laser; _FieldHeight = _Task.FieldHeight; _FieldWidth = _Task.FieldWidth; MaxAlowableDepth = _Task.Mirrors.Count; }
/// <summary> /// Нажатие кнопки "Загрузить пример" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonOpen_Click(object sender, EventArgs e) { try { OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); using (FileStream fs = File.Open(ofd.FileName, FileMode.Open)) { _Game = null; BinaryFormatter formatter = new BinaryFormatter(); _Game = (LasersGame)formatter.Deserialize(fs); } _FieldHeight = _Game.FieldHeight; _FieldWidth = _Game.FieldWidth; numericUpDownHeightField.Value = _FieldHeight; numericUpDownWidhField.Value = _FieldWidth; _Laser = _Game.Laser.LaserSource; numericUpDownLaserPosX.Value = _Laser.Position.X; numericUpDownLaserPosY.Value = _Laser.Position.Y; if (_Laser.Vector == new Point(5, 5)) { radioButton45.Checked = true; } if (_Laser.Vector == new Point(-5, 5)) { radioButton135.Checked = true; } if (_Laser.Vector == new Point(-5, -5)) { radioButton225.Checked = true; } if (_Laser.Vector == new Point(5, -5)) { radioButton315.Checked = true; } _Mirrors = _Game.GetMirrors(); _Holes = _Game.GetHoles(); _Goals = _Game.GetGoals(); OutMirrorsList(); OutHolesList(); OutGoalsList(); _Action = Action.None; } catch { MessageBox.Show("Пример не был загружен"); } }