public void MarkPhotoAsCompleted(CategoryListViewItem categoryListViewItem, int photoIndex) { //Create a new PhotoListView Item and replace the old one (Since updating newItem.Spinning isnt reflected in the ListView) PhotoListViewItem oldItem = categoryListViewItem.PhotoListViewItems.ElementAt(photoIndex); PhotoListViewItem newItem = new PhotoListViewItem(); newItem.Photo = oldItem.Photo; newItem.Filename = oldItem.Filename; newItem.Enabled = true; newItem.Thumbnail = oldItem.Thumbnail; newItem.Spinning = ProgressRing.OFF; categoryListViewItem.PhotoListViewItems[photoIndex] = newItem; PopulatePhotoDetails(newItem); /*if (ProgressBarControl.Visibility == Visibility.Visible) * { * ProgressBarControl.Value += 1; * this.PhotoStatus.Text = Properties.Resources.ProcessingPhoto + " " +(int)(ProgressBarControl.Value + 1) + " " + Properties.Resources.Of + " " + (int)ProgressBarControl.Maximum; * }*/ if (OverallProgressRing.Visibility == Visibility.Visible) { count++; this.PhotoStatus.Text = Properties.Resources.ProcessingPhoto + " " + (count + 1) + " " + Properties.Resources.Of + " " + photoCount; } }
public void MarkPhotoAsBusy(CategoryListViewItem categoryListViewItem, int photoIndex) { //Create a new PhotoListView Item and replace the old one (Since updating newItem.Spinning isnt reflected in the ListView) PhotoListViewItem oldItem = categoryListViewItem.PhotoListViewItems.ElementAt(photoIndex); PhotoListViewItem newItem = new PhotoListViewItem(); newItem.Photo = oldItem.Photo; newItem.Filename = oldItem.Filename; newItem.Enabled = false; newItem.Thumbnail = oldItem.Thumbnail; newItem.Spinning = ProgressRing.ON; categoryListViewItem.PhotoListViewItems[photoIndex] = newItem; }
private int PopulateCategories(List <Category> categoryList) { PhotoListViewItem firstPhotoListViewItem = null; int photoCount = 0; if (categoryList.Count > 0) { //Put the different categories into different listViews foreach (Category category in categoryList) { CategoryListViewItem categoryListViewItem = new CategoryListViewItem(); categoryListViewItem.Name = category.Name; this.categoryListViewItems.Add(categoryListViewItem); if (category.PhotoList.Count > 0) { foreach (Photo photo in category.PhotoList) { PhotoListViewItem photoListViewItem = CreatePhotoListViewItem(photo, true); categoryListViewItem.PhotoListViewItems.Add(photoListViewItem); if (!photo.Analyzed) { photoListViewItem.Enabled = false; } //Save the first photo item to display if (firstPhotoListViewItem == null) { firstPhotoListViewItem = photoListViewItem; } } photoCount += category.PhotoList.Count; } } //Display the details of the first Photo PopulatePhotoDetails(firstPhotoListViewItem); } return(photoCount); }
public void MarkPhotoAsCompleted(CategoryListViewItem categoryListViewItem, int photoIndex) { //Create a new PhotoListView Item and replace the old one (Since updating newItem.Spinning isnt reflected in the ListView) PhotoListViewItem oldItem = categoryListViewItem.PhotoListViewItems.ElementAt(photoIndex); PhotoListViewItem newItem = new PhotoListViewItem(); newItem.Photo = oldItem.Photo; newItem.Filename = oldItem.Filename; newItem.Enabled = true; newItem.Thumbnail = oldItem.Thumbnail; newItem.Spinning = ProgressRing.OFF; categoryListViewItem.PhotoListViewItems[photoIndex] = newItem; PopulatePhotoDetails(newItem); }
public async Task<bool> Analyze(ObservableCollection<CategoryListViewItem> categoryListViewItems, String deviceName, CancellationToken cancellationToken) { //Delete the Temp Folder Directory.Delete(Constants.TempDirectory, true); PhotoInspector photoInspector = new PhotoInspector(); for(int categoryIndex = 0; categoryIndex < categoryListViewItems.Count; categoryIndex++) { Category category = new Category(); category.Name = categoryListViewItems[categoryIndex].Name; //Expand the category CategoryListViewItem newItem = new CategoryListViewItem(); newItem.Name = categoryListViewItems[categoryIndex].Name; newItem.PhotoListViewItems = categoryListViewItems[categoryIndex].PhotoListViewItems; newItem.IsExpanded = true; categoryListViewItems[categoryIndex] = newItem; //Using for loop instead of foreach because we edit the listview for (int index = 0; index < categoryListViewItems[categoryIndex].PhotoListViewItems.Count; index++) { MarkPhotoAsBusy(categoryListViewItems[categoryIndex], index); Task analysisTask = new Task(() => { Photo photo = categoryListViewItems[categoryIndex].PhotoListViewItems[index].Photo; string categoryName = categoryListViewItems[categoryIndex].Name; //Check if the photo has been analyzed before if (photo.PhotoDetails.Count == 0) { photoInspector.InspectAndUpdatePhoto(photo, categoryName); } }); analysisTask.Start(); await analysisTask; MarkPhotoAsCompleted(categoryListViewItems[categoryIndex], index); if (cancellationToken.IsCancellationRequested) break; } //Collapse the category newItem = new CategoryListViewItem(); newItem.Name = categoryListViewItems[categoryIndex].Name; newItem.PhotoListViewItems = categoryListViewItems[categoryIndex].PhotoListViewItems; newItem.IsExpanded = false; categoryListViewItems[categoryIndex] = newItem; } if (!cancellationToken.IsCancellationRequested) { return true; } else { return false; } }
private int PopulateCategories(List<Category> categoryList) { PhotoListViewItem firstPhotoListViewItem = null; int photoCount = 0; if (categoryList.Count > 0) { //Put the different categories into different listViews foreach (Category category in categoryList) { CategoryListViewItem categoryListViewItem = new CategoryListViewItem(); categoryListViewItem.Name = category.Name; this.categoryListViewItems.Add(categoryListViewItem); if (category.PhotoList.Count > 0) { foreach (Photo photo in category.PhotoList) { PhotoListViewItem photoListViewItem = CreatePhotoListViewItem(photo, true); categoryListViewItem.PhotoListViewItems.Add(photoListViewItem); if (!photo.Analyzed) { photoListViewItem.Enabled = false; } //Save the first photo item to display if (firstPhotoListViewItem == null) { firstPhotoListViewItem = photoListViewItem; } } photoCount += category.PhotoList.Count; } } //Display the details of the first Photo PopulatePhotoDetails(firstPhotoListViewItem); } return photoCount; }
public async Task <bool> Analyze(ObservableCollection <CategoryListViewItem> categoryListViewItems, String deviceName, CancellationToken cancellationToken) { //Delete the Temp Folder Directory.Delete(Constants.TempDirectory, true); PhotoInspector photoInspector = new PhotoInspector(); for (int categoryIndex = 0; categoryIndex < categoryListViewItems.Count; categoryIndex++) { if (cancellationToken.IsCancellationRequested) { break; } Category category = new Category(); category.Name = categoryListViewItems[categoryIndex].Name; //Expand the category CategoryListViewItem newItem = new CategoryListViewItem(); newItem.Name = categoryListViewItems[categoryIndex].Name; newItem.PhotoListViewItems = categoryListViewItems[categoryIndex].PhotoListViewItems; newItem.IsExpanded = true; categoryListViewItems[categoryIndex] = newItem; //Using for loop instead of foreach because we edit the listview for (int index = 0; index < categoryListViewItems[categoryIndex].PhotoListViewItems.Count; index++) { MarkPhotoAsBusy(categoryListViewItems[categoryIndex], index); Task analysisTask = new Task(() => { Photo photo = categoryListViewItems[categoryIndex].PhotoListViewItems[index].Photo; string categoryName = categoryListViewItems[categoryIndex].Name; //Check if the photo has been analyzed before if (photo.PhotoDetails.Count == 0) { photoInspector.InspectAndUpdatePhoto(photo, categoryName); } }); analysisTask.Start(); await analysisTask; MarkPhotoAsCompleted(categoryListViewItems[categoryIndex], index); if (cancellationToken.IsCancellationRequested) { break; } } //Collapse the category newItem = new CategoryListViewItem(); newItem.Name = categoryListViewItems[categoryIndex].Name; newItem.PhotoListViewItems = categoryListViewItems[categoryIndex].PhotoListViewItems; newItem.IsExpanded = false; categoryListViewItems[categoryIndex] = newItem; if (cancellationToken.IsCancellationRequested) { break; } } if (!cancellationToken.IsCancellationRequested) { return(true); } else { return(false); } }
public void MarkPhotoAsCompleted(CategoryListViewItem categoryListViewItem, int photoIndex) { //Create a new PhotoListView Item and replace the old one (Since updating newItem.Spinning isnt reflected in the ListView) PhotoListViewItem oldItem = categoryListViewItem.PhotoListViewItems.ElementAt(photoIndex); PhotoListViewItem newItem = new PhotoListViewItem(); newItem.Photo = oldItem.Photo; newItem.Filename = oldItem.Filename; newItem.Enabled = true; newItem.Thumbnail = oldItem.Thumbnail; newItem.Spinning = ProgressRing.OFF; categoryListViewItem.PhotoListViewItems[photoIndex] = newItem; PopulatePhotoDetails(newItem); /*if (ProgressBarControl.Visibility == Visibility.Visible) { ProgressBarControl.Value += 1; this.PhotoStatus.Text = Properties.Resources.ProcessingPhoto + " " +(int)(ProgressBarControl.Value + 1) + " " + Properties.Resources.Of + " " + (int)ProgressBarControl.Maximum; }*/ if(OverallProgressRing.Visibility == Visibility.Visible) { count++; this.PhotoStatus.Text = Properties.Resources.ProcessingPhoto + " " + (count+1) + " " + Properties.Resources.Of + " " + photoCount ; } }