Files
MoonPro.net/MP-Tablet/utility.cs
T
2016-11-14 11:10:03 +01:00

98 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SteamWare;
namespace MoonProTablet
{
public class utility
{
/// <summary>
/// determina se si debba usare CDN x scaricare librerie asp.net ajax
/// </summary>
public static bool EnableCdnAjax
{
get
{
bool answ = false;
try
{
answ = memLayer.ML.confReadBool("EnableCdnAjax");
}
catch
{
}
return answ;
}
}
/// <summary>
/// determina se si debba usare CDN x scaricare librerie jquery
/// </summary>
public static bool EnableCdnJQ
{
get
{
bool answ = false;
try
{
answ = memLayer.ML.confReadBool("EnableCdnJQ");
}
catch
{
}
return answ;
}
}
/// <summary>
/// formatta la durata in minuti in un modo "human readable" gg/min/ore
/// </summary>
/// <param name="min">minuti</param>
/// <returns></returns>
public static string formatDurata(object min)
{
string answ = "";
DateTime tempo = new DateTime();
double minuti = 0;
decimal ore = 0;
decimal gg = 0;
try
{
minuti = Convert.ToDouble(min);
tempo = tempo.AddMinutes(minuti);
}
catch
{ }
#if false
if (minuti < memLayer.ML.confReadInt("maxMinuti"))
{
answ = string.Format("{0:0.##} min", minuti);
}
else if (minuti < memLayer.ML.confReadInt("maxOre"))
{
ore = Math.Floor(minuti / 60);
answ = string.Format("{0} h {1:0} min", ore, minuti - 60 * ore);
}
else
{
gg = Math.Floor(minuti / (24 * 60));
ore = (minuti - (24 * 60 * gg)) / 60;
answ = string.Format("{0} gg {1:0.##} h", gg, ore);
}
#endif
if (minuti < memLayer.ML.confReadInt("maxMinuti"))
{
answ = string.Format("{0}m {1}s", tempo.Minute, tempo.Second);
}
else if (minuti < memLayer.ML.confReadInt("maxOre"))
{
answ = string.Format("{0}h {1}m",tempo.Hour, tempo.Minute);
}
else
{
answ = string.Format("{0}gg {1}h {2}m", tempo.DayOfYear, tempo.Hour, tempo.Minute);
}
return answ;
}
}
}