Chronos Plugins 5.9.0
This documentation covers the plugin interfaces definitions and an example implementation.
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
MockPlugin.Consumables.CoffeeConsumableViewModel Class Reference

Viel 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

Viel 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 }
void RebuildLists(object sender, NotifyCollectionChangedEventArgs e)

References MockPlugin.Consumables.CoffeeConsumableViewModel.mManager, and MockPlugin.Consumables.CoffeeConsumableViewModel.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 }
ReadOnlyObservableCollection< IConsumablePool > Pools
List of all consumable pools you manage.
ObservableCollection< IngredientsForDevice > Ingredients

References MockPlugin.Consumables.CoffeeConsumableViewModel.Ingredients, MockPlugin.Consumables.CoffeeConsumableViewModel.mManager, and MockPlugin.Consumables.CoffeeConsumableManager.Pools.

Referenced by MockPlugin.Consumables.CoffeeConsumableViewModel.CoffeeConsumableViewModel().

Member Data Documentation

◆ mManager

readonly CoffeeConsumableManager MockPlugin.Consumables.CoffeeConsumableViewModel.mManager
private

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 MockPlugin.Consumables.CoffeeConsumableViewModel.RebuildLists().


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