|
-
July 18th, 2009, 09:14 AM
#1
viewing images in a picturebox P2
I have some code that some one help me with. Its just that theres a new part that I added to my software. And the code I have doesn't want to work right.
What I'm trying to do is, I have whats called a Terrain. The Terrain has 3 parts (Images) A color image. B&W image and a 3D image.
C = Color
D = 3d
H = B&W
I have a 3 buttons that says C H D. What I want to do is scroll threw the color images and when I come to a Terrain that I want to view the D and H images. I just click the D and H buttons.
The problem is that they roll back one (1) or two (2) images, So you not really viewing the right image.
The code I have is below. I tried to explain this as best as I can.
VC# 2008 in NET 3.5.
I have a textbox1 that displays the file name. with a C D H buttons and a Next and Prev Bottons on one (1) form.
Code:
public partial class Terrain : Form
{
public Terrain()
{
InitializeComponent();
}
public List<string> list;
public int count;
public int index = 0;
private void Terrain_Load(object sender, EventArgs e)
{
string[] fl = Directory.GetFiles(@"images\ViewC\");
list = new List<string>();
foreach (string str in fl)
{
if (str.EndsWith(".jpg"))
{
list.Add(str);
}
}
count = list.Count;
if (count != 0)
{
this.pictureBox1.ImageLocation = list[0];
index = 0;
textBox1.Text = list[0];
}
}
private void btnC_Click(object sender, EventArgs e)
{
string[] fl = Directory.GetFiles(@"images\ViewC\");
list = new List<string>();
foreach (string str in fl)
{
if (str.EndsWith(".jpg"))
{
list.Add(str);
}
}
count = list.Count;
if (count != 0)
{
this.pictureBox1.ImageLocation = list[0];
index = 0;
}
}
private void btnNext_Click(object sender, EventArgs e)
{
if (count > 1)
{
if (index == 0)
{
index = count - 1;
}
else
{
index--;
}
}
this.pictureBox1.ImageLocation = list[index];
//textBox1.Text =
textBox1.Text = list[index];
}
private void btnPrev_Click(object sender, EventArgs e)
{
if (count > 1)
{
if (index == count - 1)
{
index = 0;
}
else
{
index++;
}
}
this.pictureBox1.ImageLocation = list[index];
//textBox1.Text =
textBox1.Text = list[index];
}
private void btnD_Click(object sender, EventArgs e)
{
string[] fl = Directory.GetFiles(@"images\ViewD\");
list = new List<string>();
foreach (string str in fl)
{
if (str.EndsWith(".jpg"))
{
list.Add(str);
}
}
count = list.Count;
if (count != 0)
{
this.pictureBox1.ImageLocation = list[0];
index = 0;
}
}
private void btnH_Click(object sender, EventArgs e)
{
string[] fl = Directory.GetFiles(@"images\ViewH\");
list = new List<string>();
foreach (string str in fl)
{
if (str.EndsWith(".jpg"))
{
list.Add(str);
}
}
count = list.Count;
if (count != 0)
{
this.pictureBox1.ImageLocation = list[0];
index = 0;
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|