You are on page 1of 9

‫برمجة مرئية ‪C#‬‬

‫المحاضرة الرابعة‬

‫علوم حاسوب تقنية معلومات‬


‫مستوى ثالث – ترم أول‬

‫‪sunny‬‬
‫‪Sunnyhealer9@gmail.com‬‬
5 ‫ إلى الصورة رقم‬1 ‫نموذج يعمل على عرض الصور بالتتابع عبر االزرار من الصورة رقم‬
‫مع مالحظة ظهور الصورة بحجم الفورم ؟‬

namespace lecture02
{
public partial class Form3 : Form
{
int i = 1;
public Form3()
{
InitializeComponent();
}

private void btn_left_Click(object sender, EventArgs e)


{
i--;
if (i <= 1)
i = 1;

this.BackgroundImage = Image.FromFile(i.ToString() + ".jpg");


this.BackgroundImageLayout = ImageLayout.Stretch;
}

private void Form3_Load(object sender, EventArgs e)


{
this.BackgroundImage = Image.FromFile(i.ToString()+".jpg");
this.BackgroundImageLayout = ImageLayout.Stretch;
}

private void btn_right_Click(object sender, EventArgs e)


1
{
i++;
if (i >= 5)
i = 5;
this.BackgroundImage = Image.FromFile(i.ToString() + ".jpg");
this.BackgroundImageLayout = ImageLayout.Stretch;

}
}
}

‫ إلى الصورة رقم‬1 ‫نموذج يعمل على عرض الصور تلقائيا خالل فتره زمنية من الصورة رقم‬
‫ مع مالحظة ظهور الصورة بحجم الفورم ؟‬5

namespace lecture05
{
public partial class Form13 : Form
{
int i = 1;
public Form13()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)


{
if (i >= 5)
i = 1;
this.BackgroundImage = Image.FromFile(i.ToString() + ".jpg");
this.BackgroundImageLayout = ImageLayout.Stretch;
i++;
}

private void Form13_Load(object sender, EventArgs e)


{
this.BackgroundImage = Image.FromFile(i.ToString() + ".jpg");
this.BackgroundImageLayout = ImageLayout.Stretch;
}
}
}
2
6 ‫ إلى الصورة رقم‬1 ‫نموذج يعمل على عرض الصور بالتتابع عبر االزرار من الصورة رقم‬
‫ ثم يصغر حجمها‬picture box ‫مع مالحظة عمل حركة للصورة بحيث تعرض بحجم أداة‬
‫حتى تختفي ؟‬

namespace lecture07
{
public partial class Form1 : Form
{
int i = 1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
timer2.Start();
}

private void btn_right_Click(object sender, EventArgs e)


{
i++;
if (i > 6)
i = 1;
pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
timer1.Start();
timer2.Interval = 2000;
timer2.Start();
}

3
private void btn_left_Click(object sender, EventArgs e)
{
i--;
if (i < 1)
i = 6;
pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
timer1.Start();
timer2.Interval = 2000;
timer2.Start();
}

private void timer1_Tick(object sender, EventArgs e)


{
if (pictureBox1.Width < this.Width - 100)
{
pictureBox1.Width += 10;
pictureBox1.Height += 6;
pictureBox1.Left -= 5;
pictureBox1.Top -= 3;
}
else
{
timer1.Stop();
}
}

private void timer2_Tick(object sender, EventArgs e)


{
timer2.Interval = 100;
if (pictureBox1.Width > 0)
{
pictureBox1.Width -= 10;
pictureBox1.Height -= 6;
pictureBox1.Left += 5;
pictureBox1.Top += 3;
}
else
{
timer2.Stop();
}
}
}
}

4
‫نموذج محاكي بسيط لمعرض الصور مع وجود زر الستعراض الصورة من الكمبيوتر ؟‬

namespace lecture07
{
public partial class Form2 : Form
{
int i = 1;
public Form2()
{
InitializeComponent();
}

private void btn_right_Click(object sender, EventArgs e)


{
i++;
if (i > 6)
i = 1;
pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
}

private void btn_left_Click(object sender, EventArgs e)


{
i--;
if (i < 1)
i = 6;
pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
}

5
private void Form2_Load(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
//trackBar1.Value = pictureBox1.Width;
pictureBox1.Left = (this.Width - pictureBox1.Width) / 2;
pictureBox1.Top = (this.Height - pictureBox1.Height) / 2;
}

private void btn_big_Click(object sender, EventArgs e)


{
pictureBox1.Width += 10;
pictureBox1.Height += 10;
pictureBox1.Left -= 5;
pictureBox1.Top -= 5;
}

private void btn_small_Click(object sender, EventArgs e)


{
pictureBox1.Width -= 10;
pictureBox1.Height -= 10;
pictureBox1.Left += 5;
pictureBox1.Top += 5;
}

private void btn_trackbar_Click(object sender, EventArgs e)


{
if (trackBar1.Visible == false)
trackBar1.Visible = true;
else
trackBar1.Visible = false;
}

private void trackBar1_Scroll(object sender, EventArgs e)


{
pictureBox1.Width = trackBar1.Value;
pictureBox1.Height = trackBar1.Value;
pictureBox1.Left = (this.Width - pictureBox1.Width) / 2;
pictureBox1.Top = (this.Height - pictureBox1.Height) / 2;
}

6
private void btn_rotate_Click(object sender, EventArgs e)
{
pictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipY);
pictureBox1.Refresh();
}

private void btnTurnUp_Click(object sender, EventArgs e)


{
pictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
pictureBox1.Refresh();

private void btnOpen_Click(object sender, EventArgs e)


{
string path;
openFileDialog1.Filter = "ImageFile(*.jpg;*.bmp)|*.jpg;*.bmp";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
path = openFileDialog1.FileName;
txtPath.Text = path;
pictureBox1.Image = Image.FromFile(path);

}
}

private void button1_Click_1(object sender, EventArgs e)


{
if (button1.Text == "‫)"معاينة‬
{
timer1.Start();
button1.Text = "‫;"ايقاف‬
}
else
{
timer1.Stop();
button1.Text = "‫;"معاينة‬
}

7
}

private void timer1_Tick(object sender, EventArgs e)


{
//i++;
//if (i > 6)
// i = 1;
//else
// pictureBox1.Image = Image.FromFile(i.ToString() + ".jpg");
btn_right_Click(sender,e);

}
}
}

You might also like