معرض صور بلغة #C

معرض صور بلغة السي شارب 

يجب عليك اولا انشاء مجلد جديد في اي من الاقراص المحليه 
ثم تسمية اسماء الصور بالترتيب مثلا الصورة الاولى  1.jpg
والثانية 2.jpg 
وهكذا...



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;



namespace Photo_Gallery

{

    public partial class Form1 : Form

    {

        public int i = 1;

        public string State = "true";

        public Form1()

        {

            InitializeComponent();

            /* 

             * create file in D or E and copy the path 

             * rename your photos and select your photos .jpg

             */

            pictureBox1.Image = Image.FromFile("E:\\Photo\\1.jpg");

        }



        private void pictureBox1_Click(object sender, EventArgs e)

        {

        }



        private void btn_next_Click(object sender, EventArgs e)

        {

            // button next 

           //i<=6 means the number of photo-1 in your file

            if(i >= 1 && i<=6)

            {

                i++;

                pictureBox1.Image = Image.FromFile("E:\\Photo\\"+i+".jpg");

            }

            else

            {

                i = 1;

                pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

            }

        }



        private void btn_perv_Click(object sender, EventArgs e)

        {

            //button periv

            if(i >= 2 && i <=7)

            {

                i--;

                pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

            }

            else

            {

                i = 7;

                pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

            }

        }



        private void pictureBox2_Click(object sender, EventArgs e)

        {

                timer1.Enabled = false;

        }



        private void Form1_Load(object sender, EventArgs e)

        {

        }



        private void btn_frist_Click(object sender, EventArgs e)

        {

            i = 1;

            pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

        }



        private void btn_last_Click(object sender, EventArgs e)

        {

            i = 7;

            pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

        }



        private void timer1_Tick(object sender, EventArgs e)

        {

            if (i >= 1 && i <= 6)

            {

                i++;

                pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

            }

            else

            {

                i = 1;

                pictureBox1.Image = Image.FromFile("E:\\Photo\\" + i + ".jpg");

            }



        }



        private void pictureBox3_Click(object sender, EventArgs e)

        {

            timer1.Enabled = true;

        }



        private void pictureBox3_MouseMove(object sender, MouseEventArgs e)

        {

            pictureBox2.BackColor = Color.DimGray;

            pictureBox3.BackColor = Color.DimGray;

        }



        private void pictureBox3_MouseLeave(object sender, EventArgs e)

        {

            pictureBox2.BackColor = Color.Transparent;

            pictureBox3.BackColor = Color.Transparent;

        }

    }

}





تحميل المشروع https://cut-win.com/LAqPtCtF




ليست هناك تعليقات:

يتم التشغيل بواسطة Blogger.