/// <summary> /// Load images in background thread /// </summary> /// <param name="dirInfoObj"></param> private void ShowImageThread(object dirInfoObj) { IDirectoryInfo dirInfo = (IDirectoryInfo)dirInfoObj; lock (_showDirLock) { _loading = true; //Start loading //Create Grid foreach (IFileInfo fileInfo in dirInfo.Files) { if (fileInfo.Extension != ".jpg") continue; ImageBox imgBox = new ImageBox(fileInfo, _boxSize); _thumbnail.Add(imgBox); } //Update UpdateImage(false); //SetVScrollMaximum(_thumbnail.Size.Height - Size.Height); //Load image foreach (ImageBox box in _thumbnail.Sprites) { if (_cancel) break; box.LoadImage(); UpdateImage(true); } _loading = false; //End loading _cancel = false; //Reset cancel flag } }
public void Remove(ImageBox imageBox) { lock (_spriteCln) _spriteCln.Remove(imageBox); }
/// <summary> /// Load images in background thread /// </summary> /// <param name="dirInfoObj"></param> private void ShowImageThread(object dirInfoObj) { IDirectoryInfo dirInfo = (IDirectoryInfo)dirInfoObj; lock (_showDirLock) { _loading = true; //Start loading //Create Grid foreach (IFileInfo fileInfo in dirInfo.Files) { if (fileInfo.Extension != ".jpg") continue; ImageBox imgBox = new ImageBox(fileInfo, _boxSize); _thumbnail.Add(imgBox); } //Show Grid UpdateImage(false); //Load image foreach (ImageBox box in _thumbnail.Sprites) { if (_cancel) break; box.LoadImage(); Image oldImage = this.Image; UpdateImage(true); oldImage.Dispose(); //Clean old image memory } _loading = false; //End loading _cancel = false; //Reset cancel flag } }
public void Add(ImageBox imageBox) { lock (_spriteCln) _spriteCln.Add(imageBox); }