using EyesAndEars.UWP.Models; using System.ComponentModel; namespace EyesAndEars.UWP.ViewModels { public class MainPageVM : INotifyPropertyChanged { /* Note: Why I did not use a collection of some sort and hard-coded the * objects instead. * ==================================================================== * Because the projects requirements are fixed in-place and this * program does not have long-term requirements, I decided to not worry * about long-term maintenance benefits. If something comes from this * projects afterwards, the duplicated nature of the code below will * probably need refacorting but I will leave that to the person * needing to make that call at that time. */ public MainPageVM() { } public MainPageVM(FactoryDevice f1, FactoryDevice f2, FactoryDevice f3, GalleryDevice g1, GalleryDevice g2, GalleryDevice g3) { FactoryDevice1 = f1; FactoryDevice2 = f2; FactoryDevice3 = f3; GalleryDevice1 = g1; GalleryDevice2 = g2; GalleryDevice3 = g3; } FactoryDevice _factoryDevice1; public FactoryDevice FactoryDevice1 { get { return _factoryDevice1; } set { if(value != _factoryDevice1) { _factoryDevice1 = value; NotifyPropertyChanged("FactoryDevice1"); } } } FactoryDevice _factoryDevice2; public FactoryDevice FactoryDevice2 { get { return _factoryDevice2; } set { if (value != _factoryDevice2) { _factoryDevice2 = value; NotifyPropertyChanged("FactoryDevice2"); } } } FactoryDevice _factoryDevice3; public FactoryDevice FactoryDevice3 { get { return _factoryDevice3; } set { if (value != _factoryDevice3) { _factoryDevice3 = value; NotifyPropertyChanged("FactoryDevice3"); } } } GalleryDevice _galleryDevice1; public GalleryDevice GalleryDevice1 { get { return _galleryDevice1; } set { if (value != _galleryDevice1) { _galleryDevice1 = value; NotifyPropertyChanged("GalleryDevice1"); } } } GalleryDevice _galleryDevice2; public GalleryDevice GalleryDevice2 { get { return _galleryDevice2; } set { if (value != _galleryDevice2) { _galleryDevice2 = value; NotifyPropertyChanged("GalleryDevice2"); } } } GalleryDevice _galleryDevice3; public GalleryDevice GalleryDevice3 { get { return _galleryDevice3; } set { if (value != _galleryDevice3) { _galleryDevice3 = value; NotifyPropertyChanged("GalleryDevice3"); } } } public event PropertyChangedEventHandler PropertyChanged; protected void NotifyPropertyChanged(string info) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info)); } } }