public void Prepare(string path)
{
if (File.Exists(path) == false && Directory.Exists(path) == false)
return;
//Reset current index
GlobalSetting.CurrentIndex = 0;
string initFile = "";
//Check path is file or directory?
if (File.Exists(path))
{
initFile = path;
path = path.Substring(0, path.LastIndexOf("\\") + 1);
}
else if (Directory.Exists(path))
{
path = path.Replace("\\\\", "\\");
}
//Declare a new list to store filename
GlobalSetting.ImageFilenameList = new List<string>();
//Get supported image extensions from path
GlobalSetting.ImageFilenameList = LoadImageFilesFromDirectory(path);
//Dispose all garbage
GlobalSetting.ImageList.Dispose();
//Set filename to image list
GlobalSetting.ImageList = new ImgMan(GlobalSetting.ImageFilenameList.ToArray());
//Find the index of current image
GlobalSetting.CurrentIndex = GlobalSetting.ImageFilenameList.IndexOf(initFile);
//Load thumnbnail
LoadThumbnails();
//Cannot find the index
if (GlobalSetting.CurrentIndex == -1)
{
//Mark as Image Error
GlobalSetting.IsImageError = true;
Text = "ImageGlass - " + initFile;
lblInfo.Text = ImageInfo.GetFileSize(initFile);
picMain.Text = GlobalSetting.LangPack.Items["frmMain.picMain._ErrorText"];
picMain.Image = null;
//Exit function
return;
}
//Start loading image
NextPic(0);
//Watch all changes of current path
sysWatch.Path = Path.GetDirectoryName(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex));
sysWatch.EnableRaisingEvents = true;
}