/// <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(); }
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(); }