using ArcGIS.Desktop.Framework.Contracts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; namespace OliviaAddInPro { public abstract class PanelViewModelBase : PropertyChangedBase { #region Properties public abstract string DisplayName { get; } #endregion Properties } //****************************************************** public static class PanelGlobal { public static bool IsValid(string str, int ini, int fin) { int i; return int.TryParse(str, out i) && i >= ini && i <= fin; } /** * Dado un tiempo en minutos devuelve las horas modulo 60 y los minutos restantes */ /*public static string Hm_int2str(double t) { int[] hm = { 0, 0 }; hm[0] = (int)(t / 60); hm[1] = (int)(t - hm[0] * 60); return String.Format("%dd h %dd m", hm[0], hm[1]); } public static int Hm_str2int(string hm) { int h = 0; int m = 0; int t = 0; Match match = Regex.Match(hm, "^([0-9]+).([0-9]+).([0-9]+) ([0-9]+):([0-9]+):([0-9]+)"); if (match.Success) { h = int.Parse(match.Groups[4].Value); m = int.Parse(match.Groups[5].Value); t = h * 60 + m; } return t; }*/ public static DateTime Hm_int2DateTime(double t) { int[] hm = { 0, 0 }; hm[0] = (int)(t / 60); hm[1] = (int)(t - hm[0] * 60); DateTime dt=new DateTime(2021, 01, 01, hm[0], hm[1], 0); return dt; } public static int Hm_DateTime2int(DateTime dt) { int h = 0; int m = 0; int t = 0; h = dt.Hour; m = dt.Minute; t = h * 60 + m; return t; } } }