Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
//Klick auf Bild, Zeichnen-Funktion falls isActive == true private void Image_MouseClick(object sender, MouseEventArgs e) { int x = e.X, y = e.Y; if (isActive) { //Schuss dem Array hinzufügen shotsX[count] = x; shotsY[count] = y; rings[count] = Ring; count++; Shots++; //progressBar per Invoke() ruckelfrei darstellen? - denkste wohl progressBarShots.Invoke((MethodInvoker)delegate { progressBarShots.Value = Shots; progressBarShots.Update(); }); labelShotsLeft.Text = Convert.ToString(MaxShots - Shots); Shot(x, y, diameter, diameter, farbe); if (MaxShots - Shots == 0) { isActive = false; buttonAdd.Enabled = true; } } } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
private void button1_Click(object sender, EventArgs e) { double i = 0; double limit = 65535; while (i < limit) { progressBar1.Invoke((MethodInvoker)delegate { progressBar1.Value = (int)((i / limit) * 100 + 1); }); i++; } } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Wenn dieser Wert auf true ist, kann ich ich auf ein Bild klicken, dort werden dann Punkte gemalt und eben eine andere Variable hochgezählt, die dann auf der progressBar angezeigt werden soll.
Hochgezählt wird dann, wenn auf das Bild geklickt wird.Wenn dieser Wert auf true ist, kann ich ich auf ein Bild klicken, dort werden dann Punkte gemalt und eben eine andere Variable hochgezählt, die dann auf der progressBar angezeigt werden soll.
Wann und wie soll denn hochgezählt werden? Immer wenn die Maus sich bewegt? Immer wenn ein Punkt gemalt wird? Ständig mit einer konstanten Geschwindigkeit?
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
private void Image_MouseClick(object sender, MouseEventArgs e) { int x = e.X, y = e.Y; if (isActive) { shotsX[count] = x; shotsY[count] = y; rings[count] = Ring; count++; Shots++; progressBarShots.Value = Shots; labelShotsLeft.Text = Convert.ToString(MaxShots - Shots); //Shot(x, y, diameter, diameter, farbe); if (MaxShots - Shots == 0) { isActive = false; buttonAdd.Enabled = true; } } } |
Mach ich doch.Dann versteh ich nicht wo dein Problem liegt. Da brauchst du weder Threads noch sonst irgendwas. Einfach im entsprechenden Click Event ProgressBar.Value inkrementieren!?
C#-Quelltext
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 private void Image_MouseClick(object sender, MouseEventArgs e) { int x = e.X, y = e.Y; if (isActive) { shotsX[count] = x; shotsY[count] = y; rings[count] = Ring; count++; Shots++; progressBarShots.Value = Shots; labelShotsLeft.Text = Convert.ToString(MaxShots - Shots); //Shot(x, y, diameter, diameter, farbe); if (MaxShots - Shots == 0) { isActive = false; buttonAdd.Enabled = true; } } }
Quellcode |
|
1 2 |
Shots++; progressBarShots.Value = Shots; |
Werbeanzeige