public Write_file(List <Tpoint> l, string arg, Tpoint rc) { FileStream output = new FileStream(Directory.GetCurrentDirectory() + @"\filesw" + @"\" + arg + ".txt", FileMode.Create, FileAccess.Write); BinaryWriter Boutput = new BinaryWriter(output); Boutput.Write(rc.r);//playground r*c Boutput.Write(rc.c); for (int i = 0; i < l.Count; i++) { output.Position = (i + 1) * sizeof(Int32) * 2;//2:int32 r,int32 c Boutput.Write(l[i].r); Boutput.Write(l[i].c); } Boutput.Close(); output.Close(); }
private void button1_Click(object sender, EventArgs e) { /*StreamWriter myf = File.AppendText(Directory.GetCurrentDirectory() + @"\namepath" + @"\" + "namepath.txt"); * myf.WriteLine(textBox1.Text); * myf.Close();*/ // FileStream output = new FileStream(" ",FileMode.Append,FileAccess.Write); //!!!!!!!!!!!!!!!!!!!!!!!!!!! Tpoint p = new Tpoint(row, culmn); f = new Write_file(map.lp, textBox1.Text, p); Form objform = new Form3(Directory.GetCurrentDirectory() + @"\filesw\" + textBox1.Text + ".txt"); objform.Show(); this.Dispose(); }
public Read_file(ref List <Tpoint> l, string arg, ref Tpoint rc) { FileStream input = new FileStream(arg, FileMode.Open, FileAccess.Read); BinaryReader Binput = new BinaryReader(input); rc.r = Binput.ReadInt32(); rc.c = Binput.ReadInt32(); int r0, c0; Tpoint b; while (Binput.PeekChar() != -1) { r0 = Binput.ReadInt32(); c0 = Binput.ReadInt32(); b = new Tpoint(r0, c0); l.Add(b); } Binput.Close(); input.Close(); }
//private List<Tblock>Listp; public Form2(int r, int c) { InitializeComponent(); row = r; culmn = c; cv = new Constvar(); widtht_pg = cv.width_pic * culmn; hight_pg = cv.hight_pic * row; map = new Tmap(); map.makeTmap(row, culmn); for (int i = 0; i < row; i++) { for (int j = 0; j < culmn; j++) { Controls.Add(map.block[i, j]); map.block[i, j].Visible = false; } } butterfly = new Tblock(0, 0); butterfly.BackColor = SystemColors.Control; Controls.Add(butterfly); butterfly.Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\pictures" + @"\" + "butterfly[1].gif"); gh = new Ghab(row, culmn); for (int i = 0; i < gh.sizeghab; i++) { Controls.Add(gh.ghab[i]); } map.lp = new List <Tpoint>(); Tpoint start = new Tpoint(0, 0); map.lp.Add(start); }
public Form3(string st) { InitializeComponent(); //-------------------------load path----------------------------------------------------------------------------------------------- Tpoint point = new Tpoint(); map = new Tmap(); Read_file rf = new Read_file(ref map.lp, st, ref point); row = point.r; culmn = point.c; //-------------------------make map----------------------------------------------------------------------------------------------- map.makeTmap(row, culmn); for (int i = 0; i < row; i++) { for (int j = 0; j < culmn; j++) { Controls.Add(map.block[i, j]); map.block[i, j].Visible = false; } } int c = 0; while (c != map.lp.Count) { map.block[map.lp[c].r, map.lp[c].c].Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\pictures" + @"\" + "1.jpg"); map.block[map.lp[c].r, map.lp[c].c].Visible = true; c++; } //------------------------------------------------------------------------------------------------------------------------------ cv = new Constvar(); widtht_pg = cv.width_pic * culmn; hight_pg = cv.hight_pic * row; Width = widtht_pg + 300; Height = hight_pg + 300; //-------------------------make Butterfky----------------------------------------------------------------------------------------------- butterfly = new Tbutterfly(row, culmn, row + 2, -1); Controls.Add(butterfly); butterfly.Ball.BringToFront(); Controls.Add(butterfly.Ball); for (int i = 0; i < 3; i++) { Controls.Add(butterfly.ball[i]); } //-------------------------make view----------------------------------------------------------------------------------------------- Pview = new Tblock(0, 0); Pview.Width = widtht_pg; Pview.Height = hight_pg; Pview.Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\pictures" + @"\" + "Score.jpg"); //Pview.BackColor = Color.Black; Controls.Add(Pview); //-------------------------make ghab----------------------------------------------------------------------------------------------- gh = new Ghab(row, culmn); for (int i = 0; i < gh.sizeghab; i++) { Controls.Add(gh.ghab[i]); } //-------------------------------------------------------------------------------------------------------------------------- button2.Left = button3.Left = cv.left_pg + culmn * cv.width_pic + 50; button2.Top = button3.Top = cv.top_pg; //System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(); //myPlayer.SoundLocation = @"f:\New Folder\SoundS\GameplayMusic.wav"; //myPlayer.PlayLooping(); }