Вот код моей «программы» . Я пока тренируюсь, понимаю, говнокод.
Ну хоть логически, как сделать? Что использовать?
/*
*
* User: user
* Date: 25.02.2011
* Time: 23:41
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using System.IO;
using System.Net;
//using MySql.Data.MySqlClient;
namespace xxx
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
MainMenu Menu1;
Label msg;
System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
MenuItem Item1;
MenuItem Item2;
MenuItem Item3;
//запускаем программу
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
//настраиваем окно
public void windowConf() {
this.BackColor = Color.White;
this.Width = 1000;
this.Height = 400;
}
//создаем меню
public void menuCreater() {
Menu1 = new MainMenu();
Item1 = new MenuItem("Управление");
Item2 = new MenuItem("Выйти");
Item3 = new MenuItem("О программе");
Menu1.MenuItems.Add(Item1);
Item1.MenuItems.Add(Item2);
Item1.MenuItems.Add(Item3);
this.Menu = Menu1;
Item2.Click += new EventHandler(Item1_Click);
}
//читаем данные с сервера
public void GFS() {
HttpWebRequest request= (HttpWebRequest)WebRequest.Create("http://team.b13.su");
request.ContentType=@"text/xml;charset=""utf-8""";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en)";
request.Method = "POST";
request.KeepAlive = true;
byte[] message = new byte[256];
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(message,0,message.Length);
requestStream.Close();
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using(StreamReader sr = new StreamReader(response.GetResponseStream()))
{
string ttt = sr.ReadToEnd();
File.WriteAllText("serverChache.txt",ttt);
}
}
public void EchoLabel() {
string[] s = File.ReadAllLines("serverChache.txt");
int y = 0;
for (int i = 0; i < 10; i++)
{
msg = new Label();
msg.Width = 900;
msg.Height = 30;
msg.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
msg.Location = new Point(1,y);
msg.Text = s;
y = y + 29;
this.Controls.Add(msg);
}
}
public void RefreshWhithTimer() {
myTimer.Tick += new EventHandler(Tr);
myTimer.Interval = 1000;
myTimer.Start();
myTimer.Enabled = true;
}
public MainForm()
{
windowConf();
menuCreater();
GFS();
RefreshWhithTimer();
EchoLabel();
}
void Item1_Click(object sender, EventArgs e) {
Application.Exit();
}
void Tr(object sender, EventArgs e) {
GFS();
EchoLabel();
}
}
}