Moim zadaniem jest napisanie programu, ktorego efekt dzialania nawiazywalby do wygaszacza ekranu pt. „Ukryj swoje myśli” (Windows XP).
Mam w zwiazku z tym Timera:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using bibliotekaGFX;
namespace timer
{
public partial class FormWithTimer : Form
{
Timer timer = new Timer();
Label label = new Label();
public rawBitmap rBM;
public int x = 100;
public FormWithTimer()
{
InitializeComponent();
timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called
timer.Interval = (1000) * (1); // Timer will tick evert second
timer.Enabled = true; // Enable the timer
timer.Start(); // Start the timer
label.Location = new Point(100, 100);
label.AutoSize = true;
label.Text = String.Empty;
this.Controls.Add(label);
}
private void FormWithTimer_Load(object sender, EventArgs e)
{
}
void timer_Tick(object sender, EventArgs e)
{
//label.Text = DateTime.Now.ToString();
drawLine3(x++, 100, 300, 300, 255, 0, 255, 0, 0, 255);
}
}
}
napisalem rowniez funkcje, ktora rysuje linie wg algorytmu Bressenhama:
public void drawLine3(int aX, int aY, int bX, int bY, int R, int G, int B, int R2, int G2, int B2)
{
/* Bresenham - zadanie 3b (z interpolacja kolorow) */
int i;
int x, y, Dx, Dy, di, rKrok, gKrok, bKrok, rTemp, gTemp, bTemp;
x = aX;
y = aY;
Dx = bX - aX;
Dy = bY - aY;
di = (Dy << 1) - Dx;
// liczymy krok rysowania kazdego koloru
rKrok = (R2 - R) / Dx;
gKrok = (G2 - G) / Dx;
bKrok = (B2 - B) / Dx;
rTemp = R;
gTemp = G;
bTemp = B;
for (i = 1; i <= Dx; i++)
{
rBM.setPixelAsRGB(x, y, rTemp, gTemp, bTemp);
if (di >= 0)
{
y += 1;
di -= (Dx << 1);
rTemp += rKrok;
gTemp += gKrok;
bTemp += bKrok;
}
x += 1;
di += (Dy << 1);
}
}
Moje pytanie brzmi, jak moge wstawic moja funkcje do Timera, tak aby konce linii co jakis czas przesuwaly sie kazdy w innym kierunku?