Как запустить функции Winforms из консольного приложения? - PullRequest
0 голосов
/ 17 апреля 2020

Я пытаюсь разработать консольное приложение, которое читает из указанного c .txt файла и др aws строку в форме, однако, хотя я могу запустить форму, функция рисования не вызывается , Как я могу это назвать?

class Form1 : Form
{
        string[] SpielField;
        int column;
        int line;
        public Form1(int c,int l,string[] input)
        {
            this.Width = 600;
            this.Height = 600;
            this.column = c;
            this.line = l;
            SpielField = new string[c];
            SpielField = input;
        }

    public void Form1_Paint(object sender, PaintEventArgs e)
    {
        for (int i = 0; i < column-2; i++)
        {
            e.Graphics.DrawString(SpielField[i+2].ToString(), new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular),
                 new SolidBrush(Color.Black), 10, 550-i*50);
        }
    }
}
class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        string filePath = System.IO.Directory.GetCurrentDirectory() + "\\maze.txt";
        string[] input = File.ReadAllLines(filePath);
        int c = Convert.ToInt32(input[0]);
        int l = Convert.ToInt32(input[1]);
        Form1 form = new Form1(c, l, input);



        Application.EnableVisualStyles();
        Application.Run(form);
        Console.ReadLine();


    }
}

Форма вызывается и открывается, но др aws ничего.

...