برنامه زیر عکس را برویه فرم به حرکت در می آورد.
کد به صورت زیر است .
شما میتوانید برنامه را از همین جا دانلود کنید .
تصویر محیط نرم افزار :
کد برنامه :
فرم اصلی :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Text;
namespace mesal1
{
public partial class Form1 : Form
{
static public int tim;
public Form1()
{
InitializeComponent();
}
private void btnimage_Click(object sender, EventArgs e)
{
if (timer1 .Enabled = true)
{
timer1.Enabled = false;
pictureBox1.Image = null;
}
openFileDialog1.Filter = "Jpg(*.jpg)|*.jpg|Gif(*.gif)|*.gig";
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pictureBox1.ImageLocation = openFileDialog1.FileName;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if(pictureBox1.Left <= panel1.Width)
{
pictureBox1.Left = pictureBox1.Left + 100;
}
else
{
pictureBox1.Left = 0;
}
}
private void btnstart_Click(object sender, EventArgs e)
{
timer1.Interval = Properties.Settings.Default.time;
timer1.Enabled = true;
}
private void btnstop_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}
private void btntanzimat_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
Form2 t = new Form2();
t.ShowDialog();
}
private void Form1_Load(object sender, EventArgs e)
{
InstalledFontCollection fo = new InstalledFontCollection();
}
}
}
فرم تنضیمات :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace mesal1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void buttonX1_Click(object sender, EventArgs e)
{
this.Close();
}
private void buttonX2_Click(object sender, EventArgs e)
{
if (txttime.Text == "")
{
errorProvider1.SetError(txttime, "زمان تایمر را مشخص نکردی");
}
else
{
errorProvider1.Clear();
Properties.Settings.Default.time = Convert.ToInt32(txttime.Text);
Properties.Settings.Default.Save();
txttime.ResetText();
this.Close();
}
}
private void txttime_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (txttime.Text == "")
{
errorProvider1.SetError(txttime, "زمان تایمر را مشخص نکردی");
}
else
{
errorProvider1.Clear();
Properties.Settings.Default.time = Convert.ToInt32(txttime.Text);
Properties.Settings.Default.Save();
txttime.ResetText();
this.Close();
}
}
}
}
}
برای دانلود بر رویه لینک زیر کلیک کنید