Beh ... le righe in rosso in Program.cs non hanno senso ...
codice:
namespace FirstApp
{
public class Program
{
/// <summary>
/// Punto di ingresso principale dell'applicazione.
///
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 NewFile = new Form1();
NewFile.Init();
Application.Run(new Form1());
}
}
}
... semmai devi eseguire la Init cosi' come mostrato in rosso in Form1.cs ...
codice:
namespace FirstApp
{
public partial class Form1 : Form
{
byte tmp;
string path = @"E:\SrcSoftware\C#\FirstApp\Sun.bmp";
public Form1()
{
InitializeComponent();
Init();
}
private void button1_Click(object sender, EventArgs e)
{
string data = ">Ciao";
WriteCharOnCom1(data);
listBox1.Items.Add(data); // Questa viene stampata correttamente
}
private void button2_Click(object sender, EventArgs e)
{
label1.Text = "";
listBox1.Items.Clear();
listBox2.Items.Clear();
}
private void timer1_Tick(object sender, EventArgs e)
{
// Per test Timer, questa parte è funzionante
if ((++progressBar1.Value) >= 100)
progressBar1.Value = 0;
//
if (tmp == 1)
{
tmp = 0;
pictureBox1.Image = null;
}
else
{
tmp = 1;
pictureBox1.Image = Image.FromFile(path);
}
}
}
}