Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
CoffeeConsumableViewModel.cs
Go to the documentation of this file.
1using System.Collections.ObjectModel;
2using System.Collections.Specialized;
3using System.Linq;
4
6{
15 {
17
21 // ReSharper disable once UnusedMember.Global
23 {
24
25 }
26
28 {
29 mManager = value;
30 if (value?.Pools is INotifyCollectionChanged incs)
31 {
32 incs.CollectionChanged += RebuildLists;
33 }
34 RebuildLists(null, null);
35 }
36
37 private void RebuildLists(object sender, NotifyCollectionChangedEventArgs e)
38 {
39 Ingredients.Clear();
40 var allIngredients = mManager.Pools.OfType<CoffeeIngredient>().ToArray();
41 foreach (var dev in allIngredients.Select(somePool => somePool.ForDevice).Distinct())
42 {
43 var newBundle = new IngredientsForDevice() {DeviceName = dev.Name};
44 foreach (var someIng in allIngredients.Where(someIng => someIng.ForDevice == dev))
45 {
46 newBundle.Ingredients.Add(someIng);
47 }
48 Ingredients.Add(newBundle);
49 }
50 }
51
52 public ObservableCollection<IngredientsForDevice> Ingredients { get; } = new ObservableCollection<IngredientsForDevice>();
53 }
54
56 {
57 public string DeviceName { get; set; }
58 public ObservableCollection<CoffeeIngredient> Ingredients { get; } = new ObservableCollection<CoffeeIngredient>();
59 }
60}
Keeps track of all consumables that are associated to our mock coffee machine.
ReadOnlyObservableCollection< IConsumablePool > Pools
List of all consumable pools you manage.
Viel model for coffee machine related consumables.
void RebuildLists(object sender, NotifyCollectionChangedEventArgs e)
ObservableCollection< IngredientsForDevice > Ingredients
ObservableCollection< CoffeeIngredient > Ingredients
Base class for all used mock coffee ingredients.