using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Windows.ApplicationModel.Resources.Core;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;

// The data model defined by this file serves as a representative example of a strongly-typed
// model that supports notification when members are added, removed, or modified.  The property
// names chosen coincide with data bindings in the standard item templates.
//
// Applications may use this model as a starting point and build on it, or discard it entirely and
// replace it with something appropriate to their needs.

namespace GaugeSamples.Data
{
    /// <summary>
    /// Generic group data model.
    /// </summary>
    public class GaugeSampleItem
    {
        public string Name { get; set; }

        public DataTemplate Icon
        {
            get
            {
                return (DataTemplate)App.Current.Resources["IconC1" + Name.Replace(" ", "")] ?? (DataTemplate)App.Current.Resources["IconC1Gray"];
            }
        }
            
        public UserControl Control { get; set; }

    }

    /// <summary>
    /// Creates a collection of groups and items with hard-coded content.
    /// </summary>
    public sealed class SampleDataSource
    {
        private ObservableCollection<GaugeSampleItem> _items = new ObservableCollection<GaugeSampleItem>();
        public ObservableCollection<GaugeSampleItem> Items
        {
            get { return this._items; }
        }

        public SampleDataSource()
        {
            var linearGauge = new GaugeSampleItem() { Name = "Linear Gauge", Control = new LinearGauge() };
            var rulerGauge = new GaugeSampleItem() { Name = "Ruler Gauge", Control = new RulerGauge() };
            var thermometer = new GaugeSampleItem() { Name = "Thermometer", Control = new Thermometer() };
            var radialGauge = new GaugeSampleItem() { Name = "Radial Gauge", Control = new RadialGauge() };
            var speedometerGauge = new GaugeSampleItem() { Name = "Speedometer", Control = new SpeedometerGauge() };
            var volumeGauge = new GaugeSampleItem() { Name = "Volume Gauge", Control = new VolumeGauge() };
            var knob = new GaugeSampleItem() { Name = "Knob", Control = new Knob() };
            var regionKnob = new GaugeSampleItem() { Name = "Region Knob", Control = new RegionKnob() };
            var clock = new GaugeSampleItem() { Name = "Clock", Control = new Clock() };
            var ruler = new GaugeSampleItem() { Name = "Rule", Control = new Rule() };
            var automobile = new GaugeSampleItem() { Name = "Automobile", Control = new Automobile() };

            this.Items.Add(linearGauge);
            this.Items.Add(rulerGauge);
            this.Items.Add(radialGauge);
            this.Items.Add(speedometerGauge);
            this.Items.Add(volumeGauge);
            this.Items.Add(thermometer);
            this.Items.Add(knob);
            this.Items.Add(regionKnob);
            this.Items.Add(clock);
            this.Items.Add(ruler);
            this.Items.Add(automobile);
        }
    }
}
