KONU : C Sharp Uygulamalar - C Sharp ( C# ) formun kenarları arasında rastgele hareket eden buton kontrolü uygulaması.
ETİKETLER: C sharp buton - c sharp timer - c sharp form- c sharp buton hareketi - c# timer - c# button - c# buton hareketi - c sharp buton hareket ettirme - c# buton hareket ettirme - c sharp button left - c sharp button top - csharp timer - csharp timer kullanımı
UYGULAMAYI İNDİR
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 DortDonenButon
{
public partial class Form1 : Form
{
int xArtis = 9, yArtis = 9;
Point yeniNokta;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
yeniNokta = new Point(button1.Location.X,button1.Location.Y);
//butona tıklandıktan sonra buton hareket etmeye başlasın
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
//timer tick olayı gerçekleştiğinde buton hareket yönünde 9 birim ilerlesin
yeniNokta.X += xArtis;
yeniNokta.Y += yArtis;
button1.Location = yeniNokta;
if (button1.Left <= 0 || button1.Location.X >= this.ClientSize.Width - button1.Width)
{
xArtis *= -1;
}
if (button1.Top <= 0 || button1.Location.Y >= this.ClientSize.Height - button1.Height)
{
yArtis *= -1;
}
}
}
}
UYGULAMAYI İNDİR