hi,
i need to know how can i give open dialog box file path to here...
string[] pathes = new string[] { to here};
if i put like this
string[] pathes = new string[] { @"c:\pic\h.jpg"};
string[] pathes = new string[] { dlg.fineName}; this way also working but only one picturecan load....
if i put string[] pathes = new string[] { dlg.fileNames}; if i put like this got ERROR........
i can load picture but its static.when user wants to load many pictues in to an array using open load box, if i could give the open dialog box path to there i can load dynamicaly. isn't it????
i mean by open dialog box path is......some thing like when we use pictureBox....
EG: - pictureBox1.Image = image.fromFile(dlg.filname);
is there got way to give path like this.....to array......???
public partial class Form10 : Form
{
public Form10()
{
InitializeComponent();
}
private void Form10_Load(object sender, EventArgs e)
{
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(108, 108);
imageList.ColorDepth = ColorDepth.Depth32Bit;
string[] pathes = new string[] { "*****i need to give OPEN DIALOGBOX PATH TO HERE"*******};
foreach (string path in pathes)
{
Image img1 = Image.FromFile(path);
imageList.Images.Add(getThumbnaiImage(imageList.ImageSize.Width, img1));
}
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items.Add("Image\n aaaaaa\r\n bbbbbbbbbbbbbbbbbbbbb ");
this.listView1.Items[j].ImageIndex = j;
}
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList;
}
private Image getThumbnaiImage(int width, Image img)
{
Image thumb = new Bitmap(width, width);
Image tmp = null;
//If the original image is small than the Thumbnail size, just draw in the center
if (img.Width < width && img.Height < width)
{
using (Graphics g = Graphics.FromImage(thumb))
{
int xoffset = (int)((width - img.Width) / 2);
int yoffset = (int)((width - img.Height) / 2);
g.DrawImage(img, xoffset, yoffset, img.Width, img.Height);
}
}
else //Otherwise we have to get the thumbnail for drawing
{
Image.GetThumbnailImageAbort myCallback = new
Image.GetThumbnailImageAbort(ThumbnailCallback);
if (img.Width == img.Height)
{
thumb = img.GetThumbnailImage(
width, width,
myCallback, IntPtr.Zero);
}
else
{
int k = 0;
int xoffset = 0;
int yoffset = 0;
if (img.Width < img.Height)
{
k = (int)(width * img.Width / img.Height);
tmp = img.GetThumbnailImage(k, width, myCallback, IntPtr.Zero);
xoffset = (int)((width - k) / 2);
}
if (img.Width > img.Height)
{
k = (int)(width * img.Height / img.Width);
tmp = img.GetThumbnailImage(width, k, myCallback, IntPtr.Zero);
yoffset = (int)((width - k) / 2);
}
using (Graphics g = Graphics.FromImage(thumb))
{
g.DrawImage(tmp, xoffset, yoffset, tmp.Width, tmp.Height);
}
}
}
using (Graphics g = Graphics.FromImage(thumb))
{
g.DrawRectangle(Pens.Green, 0, 0, thumb.Width - 1, thumb.Height - 1);
}
return thumb;
}
public bool ThumbnailCallback()
{
return true;
}
}
pl if anyone can help me.....thx a lot u all.....
LisaPosted Feb 19, 2009, 4:06 AM
thats because the dailog box doesnt contain anymore string when started again, so try saving the string of filenames and just start appending it to it as you open it again.
Thanks,
Lisa
asela WijesooriyaPosted Feb 18, 2009, 10:36 PM
hi Friends,
actually i managed to do that by my self.....
i hope for others will helpful this......so i posted what i have done.....
i count the open diolog box slected files and pass that valu in to array size. so array will creat according to the number of files that user select....
here is the codes....
int i = 0;
int x = 0;
int count;
string[] files = dlg.FileNames;
count = files.length;
x = count;
string[] pathes = new string[x];
while(i != x)
{
foreach(stirng file in files)
{
pathes[ i ] = file;
i++
}
dlg.reset( );
}
NOTE :- its working on the very fist time....u can load pictures as many as u can on ur own any loaction's but when u load again on second time the previous pictures will disapired and appier new picture on top.......
if some one can slove that.....just be kind to reply to this......
thx a lot.......u all.....
LisaPosted Feb 17, 2009, 8:08 AM
yes then thats why you got to use a hashtable or something like it to store all the image names and list them to user how ever you want to and once user selects a new or same image just get the path of that image and display it in to the picture box individually.
i am a bit confused what you are actually looking for??
Thanks,
Lisa
asela WijesooriyaPosted Feb 17, 2009, 8:01 AM
hi
r u saing.....something like this....
string
[] pathes = new string[] { @"c:\Pic.......\....jpg", @"c:\Pic.......\....jpg" }actualy i tried this.....ya by this can load images in thumbnail view.......but i need to specify each and every images. but let say if use want o load another pic other than from list......so thats y i use OPENDIALOGBox......so if i can gove the path.......by dlg.fileName or dlg.fileNames.......can be done....u know if i give dlg.fileName.......just one image can load......but once i put dlg.fileNames.......got error......
if u don't mind can u add me on asw.asela at hot.....
really thanx for ur help.....
LisaPosted Feb 17, 2009, 7:47 AM
what you can do is try build a string with all the filenames
for example : c:/temp.jpg,d:/tempimage.jpg.....etc
then you can parse the string as it is and store it wherever you want to,
and when you actually want to load it back you can split the strings with ',' and load the individual image next to the row you want to.
i am not really sure what you are actually trying to do.
Thanks,
Lisa.
asela WijesooriyaPosted Feb 17, 2009, 7:42 AM
i don't have knowlage about that......if u don't mind pl can u just explane about that.....thx a lot......
actualy just now i tried out this
string
[] pathes = new string[3]; int i = 0;while(i != 3)
{
pathes[i]= dlg.FileName;
dlg.Dispose();
i++;
}
u know by this can retrev throw array....
do u know how to clear dlg Box item......after load it in to array,......clear one by one.....
LisaPosted Feb 17, 2009, 7:29 AM
are you adding all the file names on a single click, if so try storing it with a delimeter.
Thanks,
Lisa
asela WijesooriyaPosted Feb 17, 2009, 7:16 AM
LisaPosted Feb 17, 2009, 3:52 AM
you have to add the path names individually for each and every image not all at once
then u can retrieve them back with the array index anytime
Thanks,
Lisa