using System;
using System.Linq;
using System.Windows.Forms;

namespace IOB_WIN
{
  public class utils : IOB_UT.baseUtils
  {
    /// <summary>
    /// folder archiviazione dati configurazione (DATA\CONF)
    /// </summary>
    public static string resxDir
    {
      get
      {
        return string.Format(@"{0}\{1}", Application.StartupPath, CRS("resxPath"));
      }
    }
    /// <summary>
    /// folder archiviazione dati configurazione (DATA\CONF)
    /// </summary>
    public static string confDir
    {
      get
      {
        return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath"));
      }
    }
    /// <summary>
    /// folder archiviazione dati storici giornalieri (DATA\DAT)
    /// </summary>
    public static string dataDatDir
    {
      get
      {
        return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataDatPath"));
      }
    }
    /// <summary>
    /// folder archiviazione dati (DATA)
    /// </summary>
    public static string dataDir
    {
      get
      {
        return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath"));
      }
    }
    /// <summary>
    /// File configurazione default x MAIN
    /// </summary>
    public static string mainConfFilePath
    {
      get
      {
        return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("mainConfFile"));
      }
    }
    /// <summary>
    /// File SimData x simulazione deterministica
    /// </summary>
    public static string simDataFile
    {
      get
      {
        return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("simDataFile"));
      }
    }
    /// <summary>
    /// File persistenza generale
    /// </summary>
    public static string defPersLayerFile
    {
      get
      {
        return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile"));
      }
    }
    /// <summary>
    /// file persistenza generale
    /// </summary>
    public static string histPersLayerFile
    {
      get
      {
        return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now);
      }
    }
    /// <summary>
    /// file persistenza generale data attuale ANTICIPATA di xx giorni
    /// </summary>
    /// <param name="numDD">num DD di anticipo</param>
    /// <returns></returns>
    public static string prevPersLayerFile(int numDD)
    {
      return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD));
    }
    /// <summary>
    /// File icona default
    /// </summary>
    public static string defIconFilePath
    {
      get
      {
        return string.Format(@"{0}\SteamWare.ico", utils.resxDir);
      }
    }
    /// <summary>
    /// Converte un array di caratteri in una stringa valida (ovvero SOLO numeri/lettere)
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public static string purgedChar2String(char[] input)
    {
      string answ = new string(input.Where(c => char.IsLetter(c) || char.IsDigit(c)).ToArray());
      return answ;
    }
  }
}
