/// <summary> /// Set the file index variable and perform all other behaviour such as loading file. /// </summary> /// <param name="newFileIndex"></param> public bool UpdateFileIndex(int newFileIndex) { bool wasInRange = true; // Clamp value int clampedNewFileIndex; if (files.Count == 0) { clampedNewFileIndex = 0; } else { clampedNewFileIndex = (newFileIndex >= files.Count) ? files.Count - 1 : newFileIndex; clampedNewFileIndex = (clampedNewFileIndex < 0) ? 0 : clampedNewFileIndex; } if (newFileIndex != clampedNewFileIndex) { wasInRange = false; } fileIndex = clampedNewFileIndex; // Update labels in view. form.ChangeFileIndexTextBoxTextSilently((fileIndex + (files.Count > 0 ? 1 : 0)).ToString()); //Load new file. if (files.Count > 0) { form.mediaViewer.LoadMedia(Path.Combine(directory, files[fileIndex])); } //TODO: Textboxes aren't updating when file index is changed. This is temporary (and slow) fix. Find out why. form.ValidateChildren(); return(wasInRange); }