示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     a = Int32.Parse(textBox1.Text);
     b = Int32.Parse(textBox2.Text);
     width = Int32.Parse(textBox3.Text);
     height = Int32.Parse(textBox4.Text);
     lista.Clear();
     g.Clear(Color.White);
     for (int i = 0; i < b; i++)
     {
         for (int j = 0; j < a; j++)
         {
             g.DrawImage(bitmapy[comboBox1.SelectedIndex], j * width, i * height, width, height);
             Brick brick = new Brick(j * width, i * height, bitmapy[comboBox1.SelectedIndex], comboBox1.SelectedIndex>0?true:false, comboBox1.SelectedIndex);
             lista.Add(brick);
             pictureBox1.Refresh();
         }
     }
 }
示例#2
0
 private void button4_Click(object sender, EventArgs e)
 {
     lista.Clear();
     g.Clear(Color.White);
     openFileDialog1.Filter = "Dokument tekstowy|*.txt";
     openFileDialog1.Title = "Wczytaj poziom";
     openFileDialog1.ShowDialog();
     string odczyt = "";
     if (openFileDialog1.FileName != "")
     {
         System.IO.FileStream plik =
             (System.IO.FileStream)openFileDialog1.OpenFile();
         StreamReader sr = new StreamReader(plik);
         a = Int16.Parse(sr.ReadLine());
         MessageBox.Show("" + a);
         b = Int16.Parse(sr.ReadLine());
         MessageBox.Show("" + b);
         width = Int16.Parse(sr.ReadLine());
         MessageBox.Show("" + width);
         height = Int16.Parse(sr.ReadLine());
         MessageBox.Show("" + height);
         odczyt = sr.ReadLine();
         MessageBox.Show(odczyt);
         sr.Close();
         plik.Close();
     }
     for (int i = 0; i < b; i++)
     {
         for (int j = 0; j < a; j++)
         {
             int k = Int32.Parse(odczyt[i * a + j].ToString());
             Brick brick = new Brick(j * width, i * height, bitmapy[k], k>0?true:false, k);
             lista.Add(brick);
             g.DrawImage(bitmapy[k], j * width, i * height, width, height);
             pictureBox1.Refresh();
         }
     }
 }