/// <summary> /// Load a current basket selection /// </summary> /// <param name="name"></param> public void LoadBasket(string name) { using var db = new ImageContext(); var watch = new Stopwatch("LoadBasket"); var basket = db.Baskets .Where(x => x.Name == name) .Include(x => x.BasketEntries) .ThenInclude(x => x.Image) .ThenInclude(x => x.Folder) .FirstOrDefault(); // TODO If basket not found, load default? // We can't used ThenInclude to pull in the image tags due to this // but in the EF framework: https://github.com/dotnet/efcore/issues/19418 // It's just too slow. So until they fix it (probably EF 5) we need // to manually explicitly load the tags for each image, which is // very quick. foreach (var img in basket.BasketEntries.Select(x => x.Image)) { db.LoadTags(img); } watch.Stop(); SelectedImages.Clear(); SelectedImages.AddRange(basket.BasketEntries.Select(x => x.Image)); NotifyStateChanged(); }
/// <summary> /// Invoked when the RemoveImage command is executed /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void RemoveImage_Executed(object sender, ExecutedRoutedEventArgs e) { // Store current image in the webcam BitmapSource bitmap = e.Parameter as BitmapSource; if (bitmap != null) { SelectedImages.Remove(bitmap); } }
/// <summary> /// Invoked when the CaptureImage command is executed /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void CaptureImage_Executed(object sender, ExecutedRoutedEventArgs e) { //// Store current image in the webcam BitmapSource bitmap = webcamPlayer.CurrentBitmap; if (bitmap != null) { SelectedImages.Add(bitmap); } }
private void ListboxSelectionChanged(object parameter) { SelectedImages.Clear(); var images = ((ListBox)parameter).SelectedItems; for (int i = 0; i < images.Count; i++) { SelectedImages.Add((ImageElement)images[i]); } }
private void clearSelectedElement() { selectedStrokes.Clear(); SelectedImages.Clear(); _mainPage.OperatePieMenu.Visibility = Visibility.Collapsed; if (SelectedImages.Count > 0) { foreach (MyImage myImage in SelectedImages) { myImage.Bound.Visibility = Visibility.Collapsed; } } if (SelectButtons.Count > 0) { foreach (MyButton myButton in SelectButtons) { myButton.TextBoxTime.Background = null; } } SelectButtons.Clear(); }
/// <summary> /// Invoked when the ClearAllImages command is executed /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void ClearAllImages_Executed(object sender, ExecutedRoutedEventArgs e) { // Clear all images SelectedImages.Clear(); }
private async Task DeleteImages() { List <string> imageIds = SelectedImages.Select(c => c.Id).ToList(); await service.DeleteImages(imageIds); }