using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;

namespace ContextMenuColumnChooser
{
    public class MyBusinessObjects
    {
        string[] names = new string[] { "Côte de Blaye", "Boston Crab Meat", 
            "Singaporean Hokkien Fried Mee", "Gula Malacca", "Rogede sild", 
            "Spegesild", "Zaanse koeken", "Chocolade", "Maxilaku", "Valkoinen suklaa" };
        double[] prizes = new double[] { 23.2500, 9.0000, 45.6000, 32.0000, 
            14.0000, 19.0000, 263.5000, 18.4000, 3.0000, 14.0000 };
        DateTime[] dates = new DateTime[] { new DateTime(2010, 5, 10), new DateTime(2008, 9, 13), 
            new DateTime(2009, 2, 22), new DateTime(2009, 1, 2), new DateTime(2007, 4, 13), 
            new DateTime(2008, 5, 12), new DateTime(2008, 1, 19), new DateTime(2008, 8, 26), 
            new DateTime(2012, 7, 31), new DateTime(2011, 7, 16) };
        bool[] bools = new bool[] { true, false, true, false, true, false, true, false, true, false };

        public IEnumerable<MyBusinessObject> GetData(int maxItems)
        {
            Random rnd = new Random();

            return from i in Enumerable.Range(0, maxItems)
                   select new MyBusinessObject()
                   {
                       ID = i,
                       Name = names[rnd.Next(9)],
                       UnitPrice = prizes[rnd.Next(9)],
                       Date = dates[rnd.Next(9)],
                       Discontinued = bools[rnd.Next(9)],
                       Items = from j in Enumerable.Range(0, maxItems)
                               select new MyBusinessObject()
                               {
                                   ID = j,
                                   Name = names[rnd.Next(9)],
                                   UnitPrice = prizes[rnd.Next(9)],
                                   Date = dates[rnd.Next(9)],
                                   Discontinued = bools[rnd.Next(9)],
                               }
                   };
        }
    }

    public class MyBusinessObject
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public double UnitPrice { get; set; }
        public DateTime Date { get; set; }
        public bool Discontinued { get; set; }
        public IEnumerable<MyBusinessObject> Items { get; set; }
    }
}
