﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Nargi
{
  static class Program
  {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      var res = Program.verificarMSChart();
      if (!res)
        return;
      var m = new Modelo();
      var frmLogin = new FrmLogin(m);
      if (frmLogin.ShowDialog() == DialogResult.OK)
      {
        Application.Run(new FrmPrincipal(m));
      }
      else
      {
        Application.Exit();
      }
    }

    private static bool verificarMSChart()
    {
      bool iniciar = false;
      try
      {
        var chart = new System.Windows.Forms.DataVisualization.Charting.Chart();
        iniciar = true;
      }
      catch (Exception es)
      {
        iniciar = false;
        Modelo.HandleError(es);
        System.Diagnostics.Process.Start("mschart.exe");
      }
      return iniciar;
    }
  }
}
