Autor Beitrag
Vitalic
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Di 09.11.10 13:13 
Hallo,
ich dem unten angegebenen Quellcode möchte ich mehrere Punkte nach 3 sek. zeichnen.
Es wird jedoch immer die letzte Ausgabe gezeichnet.
Ich möchte aber, dass erst Punkt 1 dargestellt wird, dann Punkt 2 ...
Es soll ein Bewegungsablauf ersichtlich sein.


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
            
            int a = 20;

            for (int i = 0; i < 10; i++)
            {
                a += 10;
                
                Thread.Sleep(3000);
                g.FillEllipse(brush, 350+a, 200+a, 99);
                g.DrawString("(350,200)", font, Brushes.Gray, new Point(350 + 10200 + 10));
                this.Response.Flush();
            }



Danke für die Mühe!!!

Gruß,
Vitalic
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Di 09.11.10 16:27 
Hallo,

mit "Thread.Sleep" blockierst du deine GUI und daher siehst du erst am Ende der Schleife das Gezeichnete (s.a. Warum blockiert mein GUI?)
Verwende für Animationen einen Timer und zeichne nur im Paint-Ereignis.

Such hier im Forum mal nach "Timer" und "Paint", um weitere Hilfe dazu zu erhalten.
Ich habe selber auch schon einige Links dazu gepostet, s. z.B.
www.c-sharp-forum.de....php?p=612608#612608
www.c-sharp-forum.de....php?p=563652#563652
www.c-sharp-forum.de....php?p=615052#615052

www.c-sharp-forum.de....php?p=623150#623150
www.c-sharp-forum.de....php?p=613633#613633
Vitalic Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Mi 10.11.10 16:12 
Danke für die Hilfe Th69.

Ich habe leider immer noch das Problem.
Ich habe momentan ein sehr aufwendiges Programm, welches einen Thread beinhaltet.
Dieser Thread liefert mir eine Liste von Werten(Koordinaten). Diese Koordinate möchte ich nun in asp.net grafisch darstellen.
Wenn der Thread neue Werte hat, dann soll sich der contentplaceholder aktualisieren.

Und ich weiß nicht so genau, wie man das mit .net machen könnte.


Gruß,
Vitalic
Vitalic Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Fr 12.11.10 18:55 
Hallo,also ich habe das mal mit dem Timer versucht, aber es funktioniert auch nicht!
Ich bekomme kein Bild angezeigt.
Ich habe das ganze mit dem Label ausprobiert und das funktioniert, aber mit dem Image klappt es nicht.
Ich bitte um Lösungsvorschläge.

Default.aspx.cs


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
     protected void Timer1_Tick(object sender, EventArgs e)
     {
            Bitmap image = new Bitmap(700500);
            Graphics g = Graphics.FromImage(image);
            g.DrawRectangle(Pens.Red, 0505050);
            Font font = new Font("Calibri"8, FontStyle.Regular);
            image.Save(Response.OutputStream, ImageFormat.Png);
     }



Default.aspx

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="1000">
        </asp:Timer>
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
            <asp:Image ID="image" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>



Gruß, Vitalic
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Fr 12.11.10 19:13 
Sorry vitalic,

ich hatte nicht gesehen, daß du ja im ASP.NET-Unterforum gepostet hattest - daher gelten dafür leicht andere Vorgehensweisen. Ich kenne mich aber damit leider nicht so aus.

Ich hoffe, ich habe dich jetzt nicht auf die falsche Fährte gelockt...