using System.Collections.ObjectModel;
using System.Diagnostics;
using Xamarin.Forms;
using Navigator.Views;
using Navigator.Core;
using System.Collections.Generic;

namespace Navigator.ViewModels
{
    public class ItemsViewModel : BaseViewModel 
    {
    private ReadOnlyCollection<CommandViewModel> commands=null;
    private INavigation navigation;

    public ItemsViewModel(INavigation navigation)
      {
        Title = "eNavigator";
        this.navigation=navigation;
    }
    public ReadOnlyCollection<CommandViewModel> Commands
    {
      get
      {
        if (null == commands)
        {
          List<CommandViewModel> commandList = this.CreateCommands();
          commands = new ReadOnlyCollection<CommandViewModel>(commandList);
        }
        return commands;

      }
    }
    private List<CommandViewModel> CreateCommands()
      {
        return new List<CommandViewModel>
        {
          new CommandViewModel("Premarket",new RelayCommand(ParamArrayAttribute=>this.ViewPremarket(navigation))),
          new CommandViewModel("Gain/Loss",new RelayCommand(ParamArrayAttribute=>this.ViewGainLoss(navigation))),
          new CommandViewModel("Gain/Loss Series",new RelayCommand(ParamArrayAttribute=>this.ViewGainLossSeries(navigation))),
          new CommandViewModel("Headlines",new RelayCommand(ParamArrayAttribute=>this.ViewHeadlines(navigation))),
          new CommandViewModel("View Bollinger Bands",new RelayCommand(ParamArrayAttribute=>this.ViewBollingerBands(navigation))),
          new CommandViewModel("View Consumer Price Index",new RelayCommand(ParamArrayAttribute=>this.ViewConsumerPriceIndex(navigation))),
          new CommandViewModel("Company Profile",new RelayCommand(ParamArrayAttribute=>this.ViewCompanyProfile(navigation)))
        };
      }
        // *****************************************************************************************************************************
      private void ViewPremarket(INavigation navigation)
      {
        Debug.WriteLine("ViewPremarket");
        navigation.PushAsync(new PreMarketPage());
      }
      private void ViewGainLoss(INavigation navigation)
      {
        Debug.WriteLine("ViewGainLoss");
			  navigation.PushAsync(new GainLossPage());
      }
      private void ViewGainLossSeries(INavigation navigation)
      {
        Debug.WriteLine("ViewGainLossSeries");
			  navigation.PushAsync(new GainLossSeriesPage());
      }
      private void ViewHeadlines(INavigation navigation)
      {
        Debug.WriteLine("ViewHeadlines");
			  navigation.PushAsync(new HeadlinesPage());
      }
      private void ViewBollingerBands(INavigation navigation)
      {
        Debug.WriteLine("ViewBollingerBands");
			  navigation.PushAsync(new BollingerBandPage());
      }
      private void ViewConsumerPriceIndex(INavigation navigation)
      {
        Debug.WriteLine("ViewConsumerPriceIndex");
			  navigation.PushAsync(new ConsumerPriceIndexPage());
      }
      private void ViewCompanyProfile(INavigation navigation)
      {
        Debug.WriteLine("ViewCompanyProfile");
			  navigation.PushAsync(new CompanyProfilePage());
      }
  }
}