private void Button1_Click(object sender, EventArgs e) { using (OpenFileDialog fd = new OpenFileDialog()) { fd.DefaultExt = "map"; fd.Filter = "Map files|*.map"; if (fd.ShowDialog() == DialogResult.OK) { TextBox1.Text = fd.FileName; byte[] tmp = File.ReadAllBytes(fd.FileName); map = new TileIndex[128, 128]; for (int lr = 0; lr < 128; lr++) { for (int lc = 0; lc < 128; lc++) { if (((lr * 128) + lc) * 2 < tmp.Length) { map[lc, lr] = new TileIndex(tmp, ((lr * 128) + lc) * 2); } } } LevelBmp = new Bitmap(Panel1.Width, Panel1.Height); LevelImg8bpp = new BitmapBits(Panel1.Width, Panel1.Height); LevelGfx = Graphics.FromImage(LevelBmp); LevelGfx.SetOptions(); PanelGfx = Panel1.CreateGraphics(); PanelGfx.SetOptions(); loaded = true; Button2.Enabled = true; DrawLevel(); } } }
private void Initialize() { oudeX = 0; oudeY = 0; x = 2; y = 2; diameter = 30; holeX = Convert.ToInt32(((Panel1.Width - diameter) / 2) - 4); holeY = Convert.ToInt32(((Panel1.Height - diameter) / 2) - 4); paper = Panel1.CreateGraphics(); }
private void PrintScreen() { Graphics mygraphics = Panel1.CreateGraphics(); Size s = Panel1.Size; memoryImage = new Bitmap(s.Width, s.Height, mygraphics); Graphics memoryGraphics = Graphics.FromImage(memoryImage); IntPtr dc1 = mygraphics.GetHdc(); IntPtr dc2 = memoryGraphics.GetHdc(); BitBlt(dc2, 0, 0, Panel1.ClientRectangle.Width, Panel1.ClientRectangle.Height, dc1, 0, 0, 13369376); mygraphics.ReleaseHdc(dc1); memoryGraphics.ReleaseHdc(dc2); }
private void DibuixaQuadrat(int col, int row) { Graphics meuBoard; int tamanyX, tamanyY; int fila, columna; fila = row; columna = col; meuBoard = Panel1.CreateGraphics(); tamanyX = ImageList1.Images[0].Width; tamanyY = ImageList1.Images[0].Height; meuBoard.DrawRectangle(Pens.Blue, columna * tamanyY + 1, fila * tamanyX + 1, 32, 32); meuBoard.Dispose(); }
private void DibuixaTauler() { Graphics meuBoard; int fila; int columna; int tamanyX; int tamanyY; meuBoard = Panel1.CreateGraphics(); tamanyX = ImageList1.Images[0].Width; tamanyY = ImageList1.Images[0].Height; for (fila = 0; fila < 8; fila++) { for (columna = 0; columna < 8; columna++) { DibuixaCassella(fila, columna); } } meuBoard.Dispose(); }
private void DibuixaCassella(int row, int col) { Graphics meuBoard; int tamanyX; int tamanyY; int fila; int columna; fila = row; columna = col; meuBoard = Panel1.CreateGraphics(); tamanyX = ImageList1.Images[0].Width; tamanyY = ImageList1.Images[0].Height; switch (tauler[fila, columna]) { case Rb: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[1], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[0], columna * tamanyX, fila * tamanyY); } break; case Db: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[3], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[2], columna * tamanyX, fila * tamanyY); } break; case Tb: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[5], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[4], columna * tamanyX, fila * tamanyY); } break; case Ab: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[7], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[6], columna * tamanyX, fila * tamanyY); } break; case Cb: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[9], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[8], columna * tamanyX, fila * tamanyY); } break; case Pb: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[11], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[10], columna * tamanyX, fila * tamanyY); } break; case Rn: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[13], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[12], columna * tamanyX, fila * tamanyY); } break; case Dn: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[15], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[14], columna * tamanyX, fila * tamanyY); } break; case Tn: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[17], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[16], columna * tamanyX, fila * tamanyY); } break; case An: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[19], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[18], columna * tamanyX, fila * tamanyY); } break; case Cn: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[21], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[20], columna * tamanyX, fila * tamanyY); } break; case Pn: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[23], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[22], columna * tamanyX, fila * tamanyY); } break; default: if (cNegre[fila, columna] == 1) { meuBoard.DrawImage(ImageList1.Images[25], columna * tamanyX, fila * tamanyY); } else { meuBoard.DrawImage(ImageList1.Images[24], columna * tamanyX, fila * tamanyY); } break; } meuBoard.Dispose(); }
private void timer1_Tick(object sender, EventArgs e) { conteo++; distancia = conteo * 93.07; //Aumenta el valor del label Tiempo cuando se inica el timer segundos++; Calculo(); //dibujo de linea Graphics dibujo = Panel1.CreateGraphics(); //define los puntos para poder crear la curva Point[] puntos = { new Point(X1, Y1), //inicio new Point(X3, Y3), //altura new Point(X2, Y2) }; //final //dibuja la curva dibujo.DrawCurve(new Pen(Brushes.Blue), puntos); if (X == X3 && Y == Y3) { mitad = true; segundos = 1; } if (mitad == true) { if (X3 > X2) { //como va hacia la izquierda se resta X = Convert.ToInt32(X3 - segundos); Y = Convert.ToInt32((((Y2 - Y3) * (X - X3)) / (X2 - X3)) + Y3); } if (X3 < X2) { //como va hacia la derecha se suma X = Convert.ToInt32(X3 + segundos); Y = Convert.ToInt32((((Y2 - Y3) * (X - X3)) / (X2 - X3)) + Y3); } } //cambia la posicion del avion Avion.Location = new Point(X, Y); //muestra la pocision actual del avion label1.Text = "X = " + Avion.Location.X; label2.Text = "Y = " + Avion.Location.Y; label3.Text = "Distancia: " + distancia + "km (aprox.)"; if (X == X2 && Y == Y2) { timer1.Stop(); Texto.Text = "Gracias por viajar con nosotros"; } }