There are many things you can change to practice. You can change the interval of the timer to make it faster. For instance: timer1.Interval=100; will make it move very fast. Also, instead of the images changes by clicking you can make it change after each position (top, center, bottom) and so on. The possibilities are endless.
================================
================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScreenSaver1
{
public partial class Form1 : Form
{
private Image[] imgs = { ScreenSaver1.Properties.Resources.Autumn_Leaves,
ScreenSaver1.Properties.Resources.Creek,
ScreenSaver1.Properties.Resources.Desert_Landscape,
ScreenSaver1.Properties.Resources.Dock,
ScreenSaver1.Properties.Resources.Forest};
private int next = 1;
private int position = 0;//0 is top left, 1 is center, 2 is bottom right
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
switch (position)
{
case 0:
this.Location = new Point(1, 1);
break;
case 1:
this.CenterToScreen();
break;
case 2:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height);
break;
default:
break;
}
position = (position + 1) % 3;
}
private void Form1_Load(object sender, EventArgs e)
{
this.MinimumSize= this.MaximumSize = this.Size;
this.timer1.Interval = 2000;
this.timer1.Start();
this.Location = new Point(1, 1);
}
private void Form1_Click(object sender, EventArgs e)
{
this.BackgroundImage = this.imgs[++next % imgs.Length];
}
}
}
$40 off Craftsman 5 Drawer Homeowner Tool Center with Riser and Parts Bins $99.99 on sale 10/2-10/8
Sears Deal of the Day: Thule Car Top Carrier, Quest
No comments:
Post a Comment