simsonfahrer
New member
Ich habe eine analoge Uhr in c# (sharp) programmiert.
Soweit Funktioniert diese auch.
Jetzt besteht mein problem darin, das ich die Webseite jede sekunde aktualisieren muss.
Hier mal der Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8;"/>
<title>Die analoge Uhr created by ...</title>
</head>
<body>
<%@ Import namespace="System.Drawing" %>
<%@ Import namespace="System.Drawing.Imaging" %>
<script runat="server">
int radius = 250;
int radius_stunde = 170;
int radius_minute = 200;
int radius_sekunde = 230;
double Grad = (2*Math.PI)/360;
float x2, y2;
double x,y;
int Stunde, Schleifenvariable;
Color Farbe;
void Page_Load(object sender, EventArgs e)
{
Bitmap b = new Bitmap(2 * radius, 2 * radius);
Graphics g = Graphics.FromImage(b);
Brush brush = new SolidBrush(Color.White);
Pen pen = new Pen(Color.Black);
pen.Width = 3;
g.Clear(Color.White);
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawEllipse(pen, 1, 1, 2 *radius - 2, 2 *radius - 2);
pen.Width = 1;
for(int i=0; i<360; i+=1) //Minuten kennzeichnen
{
x = Math.Sin(Math.PI-i*6*Grad)*radius+radius;
x2 = (short)x;
y = Math.Cos(Math.PI-i*6*Grad)*radius+radius;
y2 = (short)y;
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);}
g.FillEllipse(brush, 8, 8, 2 *radius - 16, 2 *radius - 16);
pen.Width = 3;
for(int i=0; i<360; i+=5) //Stunden kennzeichnen
{
x = Math.Sin(Math.PI-i*6*Grad)*radius+radius;
x2 = (short)x;
y = Math.Cos(Math.PI-i*6*Grad)*radius+radius;
y2 = (short)y;
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);}
g.FillEllipse(brush, 15, 15, 2 *radius - 30, 2 *radius - 30);
x = Math.Sin(Math.PI - DateTime.Now.Second * 6 * Grad) * radius_sekunde + radius ; //Sek.-Zeiger zeichnen
x2 = (short)x;
y = Math.Cos(Math.PI - DateTime.Now.Second * 6 * Grad) * radius_sekunde + radius ;
y2 = (short)y;
pen.Width = 1;
Farbe = Color.Red;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);
x = Math.Sin(Math.PI - ((DateTime.Now.Minute ) * 6 + DateTime.Now.Second * 0.1) * Grad) * radius_minute + radius ; //Min.-Zeiger zeichnen
x2 = (short)x;
y = Math.Cos(Math.PI - ((DateTime.Now.Minute )* 6 + DateTime.Now.Second * 0.1) * Grad) * radius_minute + radius ;
y2 = (short)y;
Farbe = Color.Yellow;
pen.Color = Farbe;
pen.Width = 3;
g.DrawLine(pen, radius, radius, x2, y2);
if(DateTime.Now.Hour <= 12) Stunde = DateTime.Now.Hour ;
else Stunde = DateTime.Now.Hour - 12 ;
x = Math.Sin(Math.PI - (Stunde * 30 + DateTime.Now.Minute * 0.5 + DateTime.Now.Second * (0.5/60)) * Grad) * radius_stunde + radius ; //Std.-Zeiger zeichnen
x2 = (short)x;
y = Math.Cos(Math.PI - (Stunde * 30 + DateTime.Now.Minute * 0.5 + DateTime.Now.Second * (0.5/60)) * Grad) * radius_stunde + radius ;
y2 = (short)y;
pen.Width = 5;
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);
g.Flush();
Response.ContentType = "image/gif";
b.Save(Response.OutputStream, ImageFormat.Gif);
Response.Flush();
}
</script>
<% @Page Language="C#" %>
</body>
</html>
Ende des codes.
Ich mus dazusagen, ich bin ein lausiger anfänger
und hab mich in 2 Tagen in C# "eingearbeitet" aber mit den xhtml klappt es noch nicht so wirklich.
Das ganze ist eine praktikumsaufgabe und wenn ich diese schnellst möglich löse,
dann kann ich in dem betrieb vielleicht meine ausbildung anfangen.
bitte helft mir
Soweit Funktioniert diese auch.
Jetzt besteht mein problem darin, das ich die Webseite jede sekunde aktualisieren muss.
Hier mal der Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8;"/>
<title>Die analoge Uhr created by ...</title>
</head>
<body>
<%@ Import namespace="System.Drawing" %>
<%@ Import namespace="System.Drawing.Imaging" %>
<script runat="server">
int radius = 250;
int radius_stunde = 170;
int radius_minute = 200;
int radius_sekunde = 230;
double Grad = (2*Math.PI)/360;
float x2, y2;
double x,y;
int Stunde, Schleifenvariable;
Color Farbe;
void Page_Load(object sender, EventArgs e)
{
Bitmap b = new Bitmap(2 * radius, 2 * radius);
Graphics g = Graphics.FromImage(b);
Brush brush = new SolidBrush(Color.White);
Pen pen = new Pen(Color.Black);
pen.Width = 3;
g.Clear(Color.White);
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawEllipse(pen, 1, 1, 2 *radius - 2, 2 *radius - 2);
pen.Width = 1;
for(int i=0; i<360; i+=1) //Minuten kennzeichnen
{
x = Math.Sin(Math.PI-i*6*Grad)*radius+radius;
x2 = (short)x;
y = Math.Cos(Math.PI-i*6*Grad)*radius+radius;
y2 = (short)y;
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);}
g.FillEllipse(brush, 8, 8, 2 *radius - 16, 2 *radius - 16);
pen.Width = 3;
for(int i=0; i<360; i+=5) //Stunden kennzeichnen
{
x = Math.Sin(Math.PI-i*6*Grad)*radius+radius;
x2 = (short)x;
y = Math.Cos(Math.PI-i*6*Grad)*radius+radius;
y2 = (short)y;
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);}
g.FillEllipse(brush, 15, 15, 2 *radius - 30, 2 *radius - 30);
x = Math.Sin(Math.PI - DateTime.Now.Second * 6 * Grad) * radius_sekunde + radius ; //Sek.-Zeiger zeichnen
x2 = (short)x;
y = Math.Cos(Math.PI - DateTime.Now.Second * 6 * Grad) * radius_sekunde + radius ;
y2 = (short)y;
pen.Width = 1;
Farbe = Color.Red;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);
x = Math.Sin(Math.PI - ((DateTime.Now.Minute ) * 6 + DateTime.Now.Second * 0.1) * Grad) * radius_minute + radius ; //Min.-Zeiger zeichnen
x2 = (short)x;
y = Math.Cos(Math.PI - ((DateTime.Now.Minute )* 6 + DateTime.Now.Second * 0.1) * Grad) * radius_minute + radius ;
y2 = (short)y;
Farbe = Color.Yellow;
pen.Color = Farbe;
pen.Width = 3;
g.DrawLine(pen, radius, radius, x2, y2);
if(DateTime.Now.Hour <= 12) Stunde = DateTime.Now.Hour ;
else Stunde = DateTime.Now.Hour - 12 ;
x = Math.Sin(Math.PI - (Stunde * 30 + DateTime.Now.Minute * 0.5 + DateTime.Now.Second * (0.5/60)) * Grad) * radius_stunde + radius ; //Std.-Zeiger zeichnen
x2 = (short)x;
y = Math.Cos(Math.PI - (Stunde * 30 + DateTime.Now.Minute * 0.5 + DateTime.Now.Second * (0.5/60)) * Grad) * radius_stunde + radius ;
y2 = (short)y;
pen.Width = 5;
Farbe = Color.Black;
pen.Color = Farbe;
g.DrawLine(pen, radius, radius, x2, y2);
g.Flush();
Response.ContentType = "image/gif";
b.Save(Response.OutputStream, ImageFormat.Gif);
Response.Flush();
}
</script>
<% @Page Language="C#" %>
</body>
</html>
Ende des codes.
Ich mus dazusagen, ich bin ein lausiger anfänger
und hab mich in 2 Tagen in C# "eingearbeitet" aber mit den xhtml klappt es noch nicht so wirklich.
Das ganze ist eine praktikumsaufgabe und wenn ich diese schnellst möglich löse,
dann kann ich in dem betrieb vielleicht meine ausbildung anfangen.
bitte helft mir