How to create picture viewer/photo album
The subject says it all
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Sep 20, 2009, 3:48 AM
dont Forget to Mark "Do you like this Answer" please it will give me some credits :)
-----------------------------------------------------------------------------------------
+It Will change Picture Every 5 Second ( this is What you call SlidShow )
+If you Click Next It Will Show next Picture and Previous if Previous
+ It Will Zoom Image and Will Show Scroll bar also to Scroll the Image
+ Zooming Functionality
I have Included Project Files Also If you Not Understand the Code Correctly then you can use them :)
Download Link is at bottom of Post
namespace PictureBox
{
public partial class Form1 : Form
{
List<string> imageList;
int CurrentPosition = 0;
public Form1()
{
InitializeComponent();
}
private void btnNext_Click(object sender, EventArgs e)
{
if (CurrentPosition < imageList.Count-1)
{
CurrentPosition += 1;
}
pictureBox1.ImageLocation = imageList[CurrentPosition];
}
private void btnPrevious_Click(object sender, EventArgs e)
{
if (CurrentPosition >0)
{
CurrentPosition -= 1;
}
pictureBox1.ImageLocation = imageList[CurrentPosition];
}
private void btnZoomPlus_Click(object sender, EventArgs e)
{
pictureBox1.Width += 20;
pictureBox1.Height += 20;
}
private void btnZoomMinus_Click(object sender, EventArgs e)
{
pictureBox1.Width -= 20;
pictureBox1.Height -= 20;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (CurrentPosition == imageList.Count - 1)
{
CurrentPosition = 0;
}
else
{
CurrentPosition++;
}
pictureBox1.ImageLocation = imageList[CurrentPosition];
}
private void btnOpenFiles_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
imageList = new List<string>();
string[] filelist = ofd.FileNames;
foreach (string file in filelist)
{
FileInfo finfo = new FileInfo(file);
if (finfo.Extension == ".jpg" || finfo.Extension == ".gif" || finfo.Extension == ".jpeg" || finfo.Extension == ".png")
{
imageList.Add(finfo.FullName);
}
}
pictureBox1.ImageLocation = imageList[CurrentPosition];
timer1.Enabled = true;
}
}
}
}
Download Project Files