Click here to Skip to main content
15,920,633 members
Home / Discussions / C#
   

C#

 
AnswerRe: cartoon yourself?????????????????????????? Pin
Christian Graus7-Nov-09 9:04
protectorChristian Graus7-Nov-09 9:04 
QuestionProblem reading image tag info using Microsoft PropertyItems. Pin
ftCalhouner7-Nov-09 5:47
ftCalhouner7-Nov-09 5:47 
Questionhow to write xml? [modified] Pin
Member 23212937-Nov-09 5:38
Member 23212937-Nov-09 5:38 
AnswerRe: how to write xml? Pin
Not Active7-Nov-09 6:45
mentorNot Active7-Nov-09 6:45 
AnswerRe: how to write xml? Pin
PIEBALDconsult7-Nov-09 10:18
mvePIEBALDconsult7-Nov-09 10:18 
QuestionRegistration required Pin
_Madmatt7-Nov-09 5:13
_Madmatt7-Nov-09 5:13 
AnswerRe: Registration required Pin
Not Active7-Nov-09 5:36
mentorNot Active7-Nov-09 5:36 
GeneralRe: Registration required Pin
_Madmatt7-Nov-09 5:46
_Madmatt7-Nov-09 5:46 
GeneralRe: Registration required Pin
Not Active7-Nov-09 6:09
mentorNot Active7-Nov-09 6:09 
GeneralRe: Registration required [modified] Pin
_Madmatt7-Nov-09 6:20
_Madmatt7-Nov-09 6:20 
GeneralRe: Registration required Pin
Not Active7-Nov-09 6:39
mentorNot Active7-Nov-09 6:39 
GeneralRe: Registration required Pin
_Madmatt7-Nov-09 6:43
_Madmatt7-Nov-09 6:43 
GeneralRe: Registration required Pin
Not Active7-Nov-09 6:46
mentorNot Active7-Nov-09 6:46 
GeneralRe: Registration required Pin
Judah Gabriel Himango7-Nov-09 7:36
sponsorJudah Gabriel Himango7-Nov-09 7:36 
GeneralRe: Registration required Pin
Not Active7-Nov-09 8:29
mentorNot Active7-Nov-09 8:29 
GeneralRe: Registration required Pin
_Madmatt7-Nov-09 8:44
_Madmatt7-Nov-09 8:44 
GeneralRe: Registration required Pin
#realJSOP8-Nov-09 1:48
professional#realJSOP8-Nov-09 1:48 
GeneralRe: Registration required Pin
Christian Graus7-Nov-09 9:11
protectorChristian Graus7-Nov-09 9:11 
GeneralRe: Registration required [modified] Pin
_Madmatt7-Nov-09 21:35
_Madmatt7-Nov-09 21:35 
GeneralRe: Registration required Pin
#realJSOP8-Nov-09 1:54
professional#realJSOP8-Nov-09 1:54 
QuestionSpeech Recognition for vista and xp too using c# 2008 Pin
krinaljariwala7-Nov-09 4:43
krinaljariwala7-Nov-09 4:43 
AnswerRe: Speech Recognition for vista and xp too using c# 2008 Pin
0x3c07-Nov-09 5:34
0x3c07-Nov-09 5:34 
QuestionEventHandler in DirectoryTreeView App Pin
thungphan7-Nov-09 3:54
thungphan7-Nov-09 3:54 
Hi everybody!
I have a DirectoryTreeView app to display all images in the selected directory, including:
A TreeView include drives and directories.
All images have put into a FlowLayoutPanel.
When i click an image within it, this image will be display in a PictureBox.
My key matter is that when click an image in FlowLayoutPanel (called from FolderTreeViewAfterSelect method to pic_Click method by using EventHandler)
i also want to gain filename of this image to do more something in pic_Click method.
How could i get it? Please help me! Thank you so much!
Here's my code.

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace DirectoryTreeView
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{				
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
						
		}
						
		void FolderTreeViewBeforeExpand(object sender, TreeViewCancelEventArgs e)
		{
            MainForm.ActiveForm.Cursor = System.Windows.Forms.Cursors.WaitCursor;
        	TreeNode currentnode= e.Node;
        	if (currentnode.Nodes.Count==1) currentnode.Nodes[0].Remove();
            
            if (currentnode.Nodes.Count==0)
            {
	            int step = 0;
	            DirectoryInfo di = new DirectoryInfo(currentnode.FullPath);
	            DirectoryInfo[] dirs = null;
	            try
	            {
	            	dirs = di.GetDirectories();
	            }
	            catch(Exception ex)
	            {	                
	            }
	            
	            foreach (DirectoryInfo dir in dirs)
	            {
	                currentnode.Nodes.Add(dir.Name);
	                DirectoryInfo[] subfolder;
	                
	                try
	                {
	                    subfolder = dir.GetDirectories();
	                }
	                catch (Exception ex)
	                {
	                    continue;
	                }
	                if (subfolder.Length > 0)
	                {
	                    currentnode.Nodes[step].Nodes.Add("");
	                }
	                
	                step++;
	            }   
            }
            MainForm.ActiveForm.Cursor = System.Windows.Forms.Cursors.Default;
		}				
		
		void MainFormLoad(object sender, EventArgs e)
		{
			int step = 0;
            foreach(string str in Directory.GetLogicalDrives())
            {
                folderTreeView.Nodes.Add(str);                
                folderTreeView.Nodes[step].Nodes.Add("");
                step++;
            }	
		}
		
		void FolderTreeViewBeforeSelect(object sender, TreeViewCancelEventArgs e)
		{
			MainForm.ActiveForm.Text = e.Node.FullPath;
		}
		
		void FolderTreeViewAfterSelect(object sender, TreeViewEventArgs e)
		{
			MainForm.ActiveForm.Cursor=System.Windows.Forms.Cursors.WaitCursor;			
			thumbnailsFLP.Controls.Clear();
			displayPictureBox.Image = null;
			string[] Files = Directory.GetFiles(e.Node.FullPath);
			thumbnailsFLP.Controls.Clear();
						
			foreach (String fn in Files)
			{								
				PictureBox pic = new PictureBox();
				pic.SizeMode = PictureBoxSizeMode.StretchImage;
				
				if (fn.ToLower().EndsWith(".jpg") || fn.ToLower().EndsWith(".GIF") || fn.ToLower().EndsWith(".png") || fn.ToLower().EndsWith(".bmp") || fn.ToLower().EndsWith(".jpeg"))
				{
					pic.Image = Image.FromFile(fn);
					pic.Height = 100;
					pic.Width = 100;
					pic.Cursor = Cursors.Hand;
					thumbnailsFLP.Controls.Add(pic);
					pic.Click += new EventHandler(pic_Click);
				}
			}													
			MainForm.ActiveForm.Cursor=System.Windows.Forms.Cursors.Default;		
		}
		
		void pic_Click(object sender, EventArgs e)
		{
			PictureBox pic = (PictureBox)sender;
			displayPictureBox.SizeMode=PictureBoxSizeMode.StretchImage;
			displayPictureBox.Image = pic.Image;			
		}						
	}
}


Code link:
http://www.fileden.com/files/2007/12/28/1667604/DirectoryTreeView.rar
AnswerRe: EventHandler in DirectoryTreeView App Pin
Luc Pattyn7-Nov-09 4:19
sitebuilderLuc Pattyn7-Nov-09 4:19 
GeneralRe: EventHandler in DirectoryTreeView App Pin
thungphan7-Nov-09 5:05
thungphan7-Nov-09 5:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.