Chronos Plugins 5.11.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockPlugin.Consumables.CoffeeConsumableViewModel Class Reference

View model for coffee machine related consumables. More...

Collaboration diagram for MockPlugin.Consumables.CoffeeConsumableViewModel:

Public Member Functions

 CoffeeConsumableViewModel ()
 For the XAML Designer.
 CoffeeConsumableViewModel (CoffeeConsumableManager value)

Properties

ObservableCollection< IngredientsForDeviceIngredients = new ObservableCollection<IngredientsForDevice>() [get]

Private Member Functions

void RebuildLists (object sender, NotifyCollectionChangedEventArgs e)

Private Attributes

readonly CoffeeConsumableManager mManager

Detailed Description

View model for coffee machine related consumables.

This is a bit more complicated than strictly necessary. The idea is to show that you don't have to follow the predefined model of consumables pools/puddles strictly. In this case the consumabels get re-arranged and ordered by device by the view model.

Definition at line 14 of file CoffeeConsumableViewModel.cs.

Constructor & Destructor Documentation

◆ CoffeeConsumableViewModel() [1/2]

MockPlugin.Consumables.CoffeeConsumableViewModel.CoffeeConsumableViewModel ( )

For the XAML Designer.

Definition at line 22 of file CoffeeConsumableViewModel.cs.

22 : this(new CoffeeConsumableManager())
23 {
24
25 }

◆ CoffeeConsumableViewModel() [2/2]

MockPlugin.Consumables.CoffeeConsumableViewModel.CoffeeConsumableViewModel ( CoffeeConsumableManager value)

Definition at line 27 of file CoffeeConsumableViewModel.cs.

28 {
29 mManager = value;
30 if (value?.Pools is INotifyCollectionChanged incs)
31 {
32 incs.CollectionChanged += RebuildLists;
33 }
34 RebuildLists(null, null);
35 }

References mManager, and RebuildLists().

Member Function Documentation

◆ RebuildLists()

void MockPlugin.Consumables.CoffeeConsumableViewModel.RebuildLists ( object sender,
NotifyCollectionChangedEventArgs e )
private

Definition at line 37 of file CoffeeConsumableViewModel.cs.

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 }

References Ingredients, and mManager.

Referenced by CoffeeConsumableViewModel().

Member Data Documentation

◆ mManager

readonly CoffeeConsumableManager MockPlugin.Consumables.CoffeeConsumableViewModel.mManager
private

Definition at line 16 of file CoffeeConsumableViewModel.cs.

Referenced by CoffeeConsumableViewModel(), and RebuildLists().

Property Documentation

◆ Ingredients

ObservableCollection<IngredientsForDevice> MockPlugin.Consumables.CoffeeConsumableViewModel.Ingredients = new ObservableCollection<IngredientsForDevice>()
get

Definition at line 52 of file CoffeeConsumableViewModel.cs.

52{ get; } = new ObservableCollection<IngredientsForDevice>();

Referenced by RebuildLists().


The documentation for this class was generated from the following file: