K
Kobioldo
Guest
Hello,
currently I try to visualize a Char Array which is containing a Labyrinth via OnPaint Method. Unfortunately I have no idea how to solve it.
Would someone have a hint how I can pass the Array "LabyrinthArray" to the Method "OnPaint"? I am a very beginner with graphic programming, so I would be very happy if you help me.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
namespace Laby
{
class Labyrinth : Form
{
static void Main()
{
Application.Run(new Labyrinth());
}
public Labyrinth()
{
FileStream fs = new FileStream("C:\\tmp\\Maze.dat", FileMode.Open);
StreamReader sr = new StreamReader(fs);
int Spaltenanzahl = (Convert.ToInt32(sr.ReadLine().Trim()));
int Zeilenanzahl = (Convert.ToInt32(sr.ReadLine().Trim()));
char[,] LabyrinthArray = new char[Spaltenanzahl, Zeilenanzahl];
for (int i = 0; i < Spaltenanzahl; i++)
{
//string line = sr.ReadLine();
for (int j = 0; j < Zeilenanzahl; j++)
{
LabyrinthArray[i,j] = Convert.ToChar(sr.Read());
Console.Write(LabyrinthArray[i,j]);
string zeichen = LabyrinthArray[i, j].ToString();
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
System.Drawing.Graphics formGraphics = this.CreateGraphics();
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
float x = 50.0F;
float y = 50.0F;
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
formGraphics.DrawString(Labyrinth[], drawFont, drawBrush, x, y, drawFormat);
}
}
}
Continue reading...
currently I try to visualize a Char Array which is containing a Labyrinth via OnPaint Method. Unfortunately I have no idea how to solve it.
Would someone have a hint how I can pass the Array "LabyrinthArray" to the Method "OnPaint"? I am a very beginner with graphic programming, so I would be very happy if you help me.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
namespace Laby
{
class Labyrinth : Form
{
static void Main()
{
Application.Run(new Labyrinth());
}
public Labyrinth()
{
FileStream fs = new FileStream("C:\\tmp\\Maze.dat", FileMode.Open);
StreamReader sr = new StreamReader(fs);
int Spaltenanzahl = (Convert.ToInt32(sr.ReadLine().Trim()));
int Zeilenanzahl = (Convert.ToInt32(sr.ReadLine().Trim()));
char[,] LabyrinthArray = new char[Spaltenanzahl, Zeilenanzahl];
for (int i = 0; i < Spaltenanzahl; i++)
{
//string line = sr.ReadLine();
for (int j = 0; j < Zeilenanzahl; j++)
{
LabyrinthArray[i,j] = Convert.ToChar(sr.Read());
Console.Write(LabyrinthArray[i,j]);
string zeichen = LabyrinthArray[i, j].ToString();
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
System.Drawing.Graphics formGraphics = this.CreateGraphics();
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
float x = 50.0F;
float y = 50.0F;
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
formGraphics.DrawString(Labyrinth[], drawFont, drawBrush, x, y, drawFormat);
}
}
}
Continue reading...