using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace GenericAggregateFunction_Sum_Total
{
	class MyItem :INotifyPropertyChanged
	{
		private int number1;
		public int Number1
		{
			get
			{
				return this.number1;
			}
			set
			{
				if (this.number1 != value)
				{
					this.number1 = value;
					this.OnPropertyChanged("Number1");
				}
			}
		}

		private int number2;
		public int Number2
		{
			get
			{
				return this.number2;
			}
			set
			{
				if (this.number2 != value)
				{
					this.number2 = value;
					this.OnPropertyChanged("Number2");
				}
			}
		}

		private int number3;
		public int Number3
		{
			get
			{
				return this.number3;
			}
			set
			{
				if (this.number3 != value)
				{
					this.number3 = value;
					this.OnPropertyChanged("Number3");
				}
			}
		}
		
		public MyItem()
			{}

		public MyItem(int number1, int number2, int number3)
		{
			this.number1 = number1;
			this.number2 = number2;
			this.number3 = number3;

		}

		public static ObservableCollection<MyItem> GetItems()
		{
			ObservableCollection<MyItem> myItems = new ObservableCollection<MyItem>();
			Random rmd = new Random();
			for (int i = 0; i < 6; i++)
			{
				myItems.Add(new MyItem()
				{
					number1 = rmd.Next(1,10),
					number2 = rmd.Next(1, 10),
					number3 = rmd.Next(1, 10)
				});
			}
			return myItems;
		}


		public event PropertyChangedEventHandler PropertyChanged;
		protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
		{
			PropertyChangedEventHandler handler = this.PropertyChanged;
			if (handler != null)
			{
				handler(this, args);
			}
		}

		private void OnPropertyChanged(string propertyName)
		{
			this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
		}



	}
}
