VintaSoft Annotation .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions
private void LoadImagesFromFile() {
OpenFileDialog openImageDialog = GetOpenImageDialog();
openImageDialog.Multiselect = true;
if (openImageDialog.ShowDialog() == DialogResult.OK) {
foreach (string fileName in openImageDialog.FileNames) {
try {
//add image
thumbnailViewer1.Images.Add(fileName);
//focus on newly added image
thumbnailViewer1.FocusedIndex = thumbnailViewer1.Images.Count - 1;
if (acquireAnnotationsOnImageLoadToolStripMenuItem.Checked) {
//load annotations
LoadAnnotations(thumbnailViewer1.FocusedIndex, FilenameUtils.ChangeFileExtension(fileName, EXT_XMP));
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
}
}
private void LoadAnnotations(int imageIndex, string filePath) {
string xmpFile = FilenameUtils.ChangeFileExtension(filePath, EXT_XMP);
if (CheckImageSelected() && File.Exists(xmpFile)) {
int nextAnnoIndex = thumbnailViewer1.Annotations[imageIndex].Count;
//load annotations from file
XmlDocument doc = new XmlDocument();
doc.Load(xmpFile);
thumbnailViewer1.Annotations[imageIndex].Load(doc);
//update zOrder, adding number of annotations loaded
zOrder += numAnnotationsLoaded;
}
}
I've tried calling Refresh() on the ThumbnailViewer after adding images to try and redraw the control but it didn't do any good. Is it anything to do with how I'm trying to programatically focus on the next image in the ThumbnailViewer? What is the best way to do this when loading multiple images.
... thumbnailViewer1.Images.CollectionChanged += new ImageCollectionChangeEventHandler(thumbnailImages_CollectionChanged);
private void thumbnailImages_CollectionChanged(object sender, ImageCollectionChangeEventArgs e) {
if (e.Action == ImageCollectionChangeAction.ImageAdded && acquireAnnotationsOnImageLoadToolStripMenuItem.Checked) {
//load annotations
LoadAnnotations(e.Image, FilenameUtils.ChangeFileExtension(e.Image.ImageSourceFilename, EXT_XMP));
}
}
private void LoadImagesFromFile() {
OpenFileDialog openImageDialog = GetOpenImageDialog();
openImageDialog.Multiselect = true;
if (openImageDialog.ShowDialog() == DialogResult.OK) {
//clear images if required
if (chkClearImagesToolStripMenuItem.Checked) {
thumbnailViewer1.Images.Clear();
}
//load images
foreach (string fileName in openImageDialog.FileNames) {
try {
//add image
thumbnailViewer1.Images.Add(fileName);
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
}
}
private void LoadAnnotations(VintasoftImage img, string filePath) {
string xmpFile = FilenameUtils.ChangeFileExtension(filePath, EXT_XMP);
int imageIndex = GetImageIndex(img);
if (CheckImageSelected() && File.Exists(xmpFile) && imageIndex >= 0) {
int nextAnnoIndex = thumbnailViewer1.Annotations[imageIndex].Count;
//load annotations from file
XmlDocument doc = new XmlDocument();
doc.Load(xmpFile);
thumbnailViewer1.Annotations[imageIndex].Load(doc);
//update zOrder, adding number of annotations loaded
zOrder += numAnnotationsLoaded;
}
}
private int GetImageIndex(VintasoftImage image) {
int retVal = -1;
if (image != null && thumbnailViewer1.Images.Count > 0) {
retVal = thumbnailViewer1.Images.IndexOf(image);
}
return retVal;
}
Thanks very much,