private void BtnSave_Click(object sender, EventArgs e) { SaveDLG.InitialDirectory = Application.StartupPath; if (SaveDLG.ShowDialog(this) == DialogResult.OK) { if (SaveDLG.FileName.Length == 0) { return; } FileStream fs = new FileStream(SaveDLG.FileName, FileMode.Create, FileAccess.Write); fs.WriteByte((byte)(PnlGUI.Start.X >> 8)); fs.WriteByte((byte)(PnlGUI.Start.X & 0x000000FF)); fs.WriteByte((byte)(PnlGUI.Start.Y >> 8)); fs.WriteByte((byte)(PnlGUI.Start.Y & 0x000000FF)); fs.WriteByte((byte)(PnlGUI.End.X >> 8)); fs.WriteByte((byte)(PnlGUI.End.X & 0x000000FF)); fs.WriteByte((byte)(PnlGUI.End.Y >> 8)); fs.WriteByte((byte)(PnlGUI.End.Y & 0x000000FF)); fs.WriteByte((byte)(ChkDiagonals.Checked ? 1 : 0)); fs.WriteByte((byte)(ChkHeavyDiagonals.Checked ? 1 : 0)); fs.WriteByte((byte)(ChkPunishChangeDirection.Checked ? 1 : 0)); fs.WriteByte((byte)(ChkReopenCloseNodes.Checked ? 1 : 0)); fs.WriteByte((byte)NumUpDownHeuristic.Value); fs.WriteByte((byte)CboFormula.SelectedIndex); fs.WriteByte((byte)(ChkTieBraker.Checked ? 1 : 0)); fs.WriteByte((byte)(((int)NumSearchLimit.Value) >> 24)); fs.WriteByte((byte)(((int)NumSearchLimit.Value) >> 16)); fs.WriteByte((byte)(((int)NumSearchLimit.Value) >> 8)); fs.WriteByte((byte)(((int)NumSearchLimit.Value) & 0x000000FF)); fs.WriteByte((byte)TBarGridSize.Value); fs.WriteByte((byte)TBarSpeed.Value); for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { fs.WriteByte(PnlGUI.Matrix[x, y]); } } fs.Close(); } }
private void BtnSave_Click(object sender, EventArgs e) { SaveDLG.InitialDirectory = Application.StartupPath; if (SaveDLG.ShowDialog(this) == DialogResult.OK) { if (SaveDLG.FileName.Length == 0) { return; } FileStream fs = new FileStream(SaveDLG.FileName, FileMode.Create, FileAccess.Write); fs.WriteByte((byte)(matrix_Base.Start.X >> 8)); fs.WriteByte((byte)(matrix_Base.Start.X & 0x000000FF)); fs.WriteByte((byte)(matrix_Base.Start.Y >> 8)); fs.WriteByte((byte)(matrix_Base.Start.Y & 0x000000FF)); fs.WriteByte((byte)(matrix_Base.End.X >> 8)); fs.WriteByte((byte)(matrix_Base.End.X & 0x000000FF)); fs.WriteByte((byte)(matrix_Base.End.Y >> 8)); fs.WriteByte((byte)(matrix_Base.End.Y & 0x000000FF)); fs.WriteByte((byte)(ChkDiagonals.Checked ? 1 : 0)); fs.WriteByte((byte)(ChkReopenCloseNodes.Checked ? 1 : 0)); fs.WriteByte((byte)NumUpDownHeuristic.Value); fs.WriteByte((byte)CboFormula.SelectedIndex); for (int y = 0; y < 1000; y++) { for (int x = 0; x < 1000; x++) { fs.WriteByte(matrix_Base.Matrix[x, y]); } } fs.Close(); } }