Hi Ihr da draußen.
Ich möchte folgende grafische Ausgabe erzeugen.
siehe Bild unten - Coffeebean
Dafür habe ich folgenden Quellcode erstellt:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Collections;
namespace Projekt
{
public partial class Form1 : Form
{
string[] readText;
string line;
ArrayList arrText = new ArrayList();
public Form1()
{
//InitializeComponent();
WriteFile();
}
private void WriteFile()
{
StreamWriter sw = new StreamWriter("quell.dat");
Console.WriteLine("Willkommen!");
Console.WriteLine("Bitte um Eingabe!");
while (true)
{
line = Console.ReadLine();
if (line == "") break;
else
sw.WriteLine(line);
}
sw.Close();
ReadFile();
}
private void ReadFile()
{
StreamReader objReader = new StreamReader("quell.dat");
readText = File.ReadAllLines("quell.dat");
objReader.Close();
}
protected override void OnPaint(PaintEventArgs e)
{
//foreach (string s in readText)
for (int i = 0; i < readText.Length; i++)
{
if (readText[i] == "#")
{
Font drawFont = new Font("Arial", 18.0f, FontStyle.Bold);
SolidBrush drawBush = new SolidBrush(Color.Blue);
e.Graphics.DrawString(readText[i], drawFont, drawBush, ClientRectangle);
}
else
{
Font drawFont = new Font("Arial", 10.0f, FontStyle.Bold);
SolidBrush drawBush = new SolidBrush(Color.Black);
e.Graphics.DrawString(readText[i], drawFont, drawBush, ClientRectangle);
}
}
}
}
static class Program
{ /// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
Leider funktioniert das so nicht richtig. Es wird alles in die erste Zeile geschrieben und das auch nur in einer Farbe. Weiß jemand, wie man das Bild aus dem Link erstellt bzw. was dafür am Quellcode geändert muss?
- performance is a feature -
Microsoft MVP - @Website - @AzureStuttgart - github.com/BenjaminAbt - Sustainable Code