이미지뷰어!
훈스 닷넷에서 질문올라온것을 살짝 작성해본 것임.
// 소스!
public partial class Form1 : Form
{
string DirectoryPath = string.Empty;
int Index = 0;
public Form1()
{
InitializeComponent();
}
#region 이전
private void toolStripButton1_Click(object sender, EventArgs e)
{
이전();
}
private void button1_Click(object sender, EventArgs e)
{
이전();
}
void 이전()
{
검색(-1);
}
#endregion
#region 다음
private void button2_Click(object sender, EventArgs e)
{
다음();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
다음();
}
void 다음()
{
검색(+1);
}
#endregion
void 검색(int ImageIndex )
{
this.Index += ImageIndex;
if (Index < 0)
Index = 0;
else if (Index > listBox1.Items.Count - 1)
Index = listBox1.Items.Count - 1;
if (this.listBox1.Items.Count > 0 )
{
this.pictureBox1.ImageLocation = string.Format("{0}\\{1}",DirectoryPath, listBox1.Items[Index].ToString());
this.listBox1.SelectedIndex = this.Index;
}
}
private void button3_Click(object sender, EventArgs e)
{// 디렉토리 설정 및 파일리스트 로딩.
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = DirectoryPath = folderBrowserDialog1.SelectedPath;
string[] fileNames = System.IO.Directory.GetFiles(DirectoryPath);
listBox1.Items.Clear();
foreach (string fileName in fileNames)
{
listBox1.Items.Add(fileName.Replace(DirectoryPath, ""));
}
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.Index = listBox1.SelectedIndex - 1 ;
검색(+1);
}
}
'# 2) .Net ( Vs 2005 ) > WinForm' 카테고리의 다른 글
판넬 슬라이드 애니메이션 (0) | 2009.05.01 |
---|---|
데이타베이스 브라우져 ver3 (0) | 2009.05.01 |
다각형 내부 클릭 체크. (0) | 2009.05.01 |
프로시져 생성기 (0) | 2009.05.01 |
유저컨트롤-[도구모음] (0) | 2009.05.01 |