public void ReadProgress() { StreamReader streamReaderProgress = File.OpenText("progress.txt"); string header = streamReaderProgress.ReadLine(); _mapInput = new MapGeneratorInput(); _mapInput.Width = Convert.ToInt32(streamReaderProgress.ReadLine()); _mapInput.Height = Convert.ToInt32(streamReaderProgress.ReadLine()); _mapInput.FillRate = Convert.ToDouble(streamReaderProgress.ReadLine()); _mapInput.FillAlgorithm = Convert.ToInt32(streamReaderProgress.ReadLine()); _mapInput.H = Convert.ToDouble(streamReaderProgress.ReadLine()); _pathInput = new PathSearcherInput(); _pathInput.SearchAlgorithm = Convert.ToInt32(streamReaderProgress.ReadLine()); _pathInput.SearchType = Convert.ToInt32(streamReaderProgress.ReadLine()); _pathInput.Jump = Convert.ToInt32(streamReaderProgress.ReadLine()); _taskInput = new SearchTaskInput(); _taskInput.OuterIterations = Convert.ToInt32(streamReaderProgress.ReadLine()); _taskInput.InnerIterations = Convert.ToInt32(streamReaderProgress.ReadLine()); _taskInput.DisplayImage = Convert.ToBoolean(streamReaderProgress.ReadLine()); _taskInput.ThreadNum = Convert.ToInt32(streamReaderProgress.ReadLine()); _taskInput.SaveProgress = Convert.ToBoolean(streamReaderProgress.ReadLine()); _totalTime = Convert.ToInt64(streamReaderProgress.ReadLine()); _results = new Result[_taskInput.OuterIterations]; for (int i = 0; i < _taskInput.OuterIterations; i++) { _results[i] = new Result(); _results[i].Found = Convert.ToInt32(streamReaderProgress.ReadLine()); _results[i].Total = Convert.ToInt32(streamReaderProgress.ReadLine()); } streamReaderProgress.Close(); }
public Task(SearchTaskInput taskInput, PathSearcherInput pathInput, MapGeneratorInput mapInput) { _taskInput = taskInput; _pathInput = pathInput; _mapInput = mapInput; }
public FormSearchResults(SearchTaskInput taskInput, PathSearcherInput pathInput, MapGeneratorInput mapInput) { // // Windows Form 設計工具支援的必要項 // InitializeComponent(); // Input _taskInput = taskInput; _pathInput = pathInput; _mapInput = mapInput; // Write input values to textBoxOutput textBoxOutput.AppendText(String.Format("Matrix: {0} x {1}, {2}\r\n", _mapInput.Width, _mapInput.Height, _mapInput.FillRate)); string fillAlgorithm = "Error"; switch (_mapInput.FillAlgorithm) // 0 = Fixed Count, 1 = Random Count, 2 = Fractal { case 0: fillAlgorithm = "Fixed Count"; break; case 1: fillAlgorithm = "Random Count"; break; case 2: fillAlgorithm = "Fractal, H " + _mapInput.H.ToString(); break; } textBoxOutput.AppendText(String.Format("Fill: {0}\r\n", fillAlgorithm)); string pathAlgorithm = "Error"; /* * switch (_pathInput.SearchAlgorithm) // 1 = Priority Queue Search, 2 = DepthFirstSearch * { * case 1: * pathAlgorithm = "Priority Queue Search"; * break; * case 2: * pathAlgorithm = "Depth First Search"; * break; * } */ switch (_pathInput.SearchType) // 1 = 4 way, 2 = 8 way { case 1: pathAlgorithm = "4 way"; break; case 2: pathAlgorithm = "8 way"; break; } pathAlgorithm += ", Jump " + _pathInput.Jump.ToString(); textBoxOutput.AppendText(String.Format("Path: {0}\r\n", pathAlgorithm)); // Initialize progress display interface progressBar.Maximum = _taskInput.InnerIterations * _taskInput.OuterIterations; // Start task _task = new Task(taskInput, pathInput, mapInput); _task.Start(); // Enable UI progress timer timerUpdateDisplay.Enabled = true; if (_taskInput.SaveProgress) { timerSaveProgress.Enabled = true; } }