예제 #1
0
        public double GetDoubleValue(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.Upload: return(_account.Upload);

            case MailTagTypes.Download: return(_account.Download);

            case MailTagTypes.TotalCombinedRemaining: return(_account.CombinedRemaining);

            case MailTagTypes.TotalCombinedMax: return(_account.CombinedMaximum);

            case MailTagTypes.TotalCombined: return(_account.Combined);

            case MailTagTypes.SuggestDailyUsage: return(_account.SuggestCombined);

            case MailTagTypes.AverageCombined: return(_account.AverageCombined);

            case MailTagTypes.SuggestCombined: return(_account.SuggestCombined);

            case MailTagTypes.EstimateCombined: return(_account.EstimateCombined);

            case MailTagTypes.TheoryDailyCombined: return(_account.TheoryDailyCombined);

            case MailTagTypes.TheoryCombined: return(_account.TheoryCombined);

            case MailTagTypes.TheoryCombinedDifference: return(_account.TheoryCombinedVersusCombined);

            default: return(0.0);
            }
        }
예제 #2
0
        private string FormatDouble(MailTagTypes type, string param)
        {
            double      value = _factory.GetDoubleValue(type);
            SIUnitTypes unit  = ProgramSettings.Instance.ShowUnitType;

            Match paramMatch = Regex.Match(param, METHOD_PARAM, RegexOptions.IgnoreCase);

            while (paramMatch.Success)
            {
                if (paramMatch.Groups["method"].Value.ToUpper() == "ROUND")
                {
                    value = System.Math.Round(value, Int32.Parse(paramMatch.Groups["param"].Value));
                }
                else if (paramMatch.Groups["method"].Value.ToUpper() == "UNIT")
                {
                    switch (paramMatch.Groups["param"].Value.ToUpper())
                    {
                    case "G": unit = SIUnitTypes.Go; break;

                    case "M": unit = SIUnitTypes.Mo; break;

                    case "K": unit = SIUnitTypes.ko; break;
                    }
                }
                paramMatch = paramMatch.NextMatch();
            }

            return(UnitsConverter.SIUnitToString(value, unit));
        }
예제 #3
0
        public bool IsDouble(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.Upload: return(true);

            case MailTagTypes.Download: return(true);

            case MailTagTypes.TotalCombinedRemaining: return(true);

            case MailTagTypes.TotalCombinedMax: return(true);

            case MailTagTypes.TotalCombined: return(true);

            case MailTagTypes.SuggestDailyUsage: return(true);

            case MailTagTypes.AverageCombined: return(true);

            case MailTagTypes.SuggestCombined: return(true);

            case MailTagTypes.EstimateCombined: return(true);

            case MailTagTypes.TheoryDailyCombined: return(true);

            case MailTagTypes.TheoryCombined: return(true);

            case MailTagTypes.TheoryCombinedDifference: return(true);

            default: return(false);
            }
        }
예제 #4
0
 public int GetIntValue(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.DayRemaining: return _account.DayRemaining.Days;
         default: return 0;
     }
 }
예제 #5
0
 public double GetCurrencyValue(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.Overcharge: return _account.Overcharge;
         default: return 0.0;
     }
 }
예제 #6
0
        public int GetIntValue(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.DayRemaining: return(_account.DayRemaining.Days);

            default: return(0);
            }
        }
예제 #7
0
        public double GetCurrencyValue(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.Overcharge: return(_account.Overcharge);

            default: return(0.0);
            }
        }
예제 #8
0
        public string GetStringValue(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.Name: return(_account.DisplayName);

            case MailTagTypes.Username: return(_account.Username);

            default: return(String.Empty);
            }
        }
예제 #9
0
 public DateTime GetDateTimeValue(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.PeriodStart: return _account.PeriodStart;
         case MailTagTypes.PeriodEnd: return _account.PeriodEnd;
         case MailTagTypes.Now: return DateTime.Now;
         case MailTagTypes.LastUpdate: return _account.LastUpdate;
         default: return DateTime.MinValue;
     }
 }
예제 #10
0
 public double GetPercentValue(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.UploadPercent: return _account.UploadPercent;
         case MailTagTypes.DownloadPercent: return _account.DownloadPercent;
         case MailTagTypes.TotalCombinedPercent: return _account.CombinedPercent;
         case MailTagTypes.SuggestCombinedPercent: return _account.SuggestCombinedPercent;
         case MailTagTypes.TheoryDailyCombinedPercent: return _account.TheoryDailyCombinedPercent;
         default: return 0.0;
     }
 }
예제 #11
0
        public DateTime GetDateTimeValue(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.PeriodStart: return(_account.PeriodStart);

            case MailTagTypes.PeriodEnd: return(_account.PeriodEnd);

            case MailTagTypes.Now: return(DateTime.Now);

            case MailTagTypes.LastUpdate: return(_account.LastUpdate);

            default: return(DateTime.MinValue);
            }
        }
예제 #12
0
        public bool IsDateTime(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.PeriodStart: return(true);

            case MailTagTypes.PeriodEnd: return(true);

            case MailTagTypes.Now: return(true);

            case MailTagTypes.LastUpdate: return(true);

            default: return(false);
            }
        }
예제 #13
0
        /// <summary>
        /// Converti un tag de format DateTime en une valeur string
        /// </summary>
        /// <param name="type">Le nom du tag</param>
        /// <param name="param">Les méthodes</param>
        /// <returns>La valeur à insérer dans le texte</returns>
        private string FormatDateTime(MailTagTypes type, string param)
        {
            Match paramMatch = Regex.Match(param, METHOD_PARAM, RegexOptions.IgnoreCase);

            while (paramMatch.Success)
            {
                if (paramMatch.Groups["method"].Value.ToUpper() == "FORMAT")
                {
                    return(_factory.GetDateTimeValue(type).ToString(paramMatch.Groups["param"].Value));
                }
                paramMatch = paramMatch.NextMatch();
            }

            return(_factory.GetDateTimeValue(type).ToShortDateString());
        }
예제 #14
0
        /// <summary>
        /// Format une valeur en fonction des paramètres défini
        /// </summary>
        /// <param name="tag">Le tag trouvé dans le texte</param>
        /// <param name="param">Chaine de caractère représentant les fonctions à appliquer</param>
        /// <returns>Le nouvelle valeur</returns>
        private string Format(string tag, string param)
        {
            MailTagTypes type = _factory.GetType(tag);

            if (type != MailTagTypes.None)
            {
                try
                {
                    // Si c'est une date
                    if (_factory.IsDateTime(type))
                    {
                        return(FormatDateTime(type, param));
                    }
                    // Si c'est un double
                    else if (_factory.IsDouble(type))
                    {
                        return(FormatDouble(type, param));
                    }
                    // Si c'est un pourcentage
                    else if (_factory.IsPercent(type))
                    {
                        return(FormatPercent(type, param));
                    }
                    // Si c'est un integer
                    else if (_factory.IsInt(type))
                    {
                        return(_factory.GetIntValue(type).ToString());
                    }
                    // Si c'est de la monnaie
                    else if (_factory.IsCurrency(type))
                    {
                        return(FormatCurrency(type, param));
                    }
                    // Si c'est du texte
                    else
                    {
                        return(_factory.GetStringValue(type));
                    }
                }
                catch (Exception formatExcep)
                {
                    return(String.Format("({0})", formatExcep.Message));
                }
            }

            return(string.Empty);
        }
예제 #15
0
        public bool IsPercent(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.UploadPercent: return(true);

            case MailTagTypes.DownloadPercent: return(true);

            case MailTagTypes.TotalCombinedPercent: return(true);

            case MailTagTypes.SuggestCombinedPercent: return(true);

            case MailTagTypes.TheoryDailyCombinedPercent: return(true);

            default: return(false);
            }
        }
예제 #16
0
        public double GetPercentValue(MailTagTypes type)
        {
            switch (type)
            {
            case MailTagTypes.UploadPercent: return(_account.UploadPercent);

            case MailTagTypes.DownloadPercent: return(_account.DownloadPercent);

            case MailTagTypes.TotalCombinedPercent: return(_account.CombinedPercent);

            case MailTagTypes.SuggestCombinedPercent: return(_account.SuggestCombinedPercent);

            case MailTagTypes.TheoryDailyCombinedPercent: return(_account.TheoryDailyCombinedPercent);

            default: return(0.0);
            }
        }
예제 #17
0
 public double GetDoubleValue(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.Upload: return _account.Upload;
         case MailTagTypes.Download: return _account.Download;
         case MailTagTypes.TotalCombinedRemaining: return _account.CombinedRemaining;
         case MailTagTypes.TotalCombinedMax: return _account.CombinedMaximum;
         case MailTagTypes.TotalCombined: return _account.Combined;
         case MailTagTypes.SuggestDailyUsage: return _account.SuggestCombined;
         case MailTagTypes.AverageCombined: return _account.AverageCombined;
         case MailTagTypes.SuggestCombined: return _account.SuggestCombined;
         case MailTagTypes.EstimateCombined: return _account.EstimateCombined;
         case MailTagTypes.TheoryDailyCombined: return _account.TheoryDailyCombined;
         case MailTagTypes.TheoryCombined: return _account.TheoryCombined;
         case MailTagTypes.TheoryCombinedDifference: return _account.TheoryCombinedVersusCombined;
         default: return 0.0;
     }
 }
예제 #18
0
        private string FormatPercent(MailTagTypes type, string param)
        {
            double value = _factory.GetPercentValue(type) * 100;
            int    round = 2;

            Match paramMatch = Regex.Match(param, METHOD_PARAM, RegexOptions.IgnoreCase);

            while (paramMatch.Success)
            {
                if (paramMatch.Groups["method"].Value.ToUpper() == "ROUND")
                {
                    round = Int32.Parse(paramMatch.Groups["param"].Value);
                }
                paramMatch = paramMatch.NextMatch();
            }

            value = System.Math.Round(value, round);

            return(value.ToString());
        }
예제 #19
0
 public bool IsDouble(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.Upload: return true;
         case MailTagTypes.Download: return true;
         case MailTagTypes.TotalCombinedRemaining: return true;
         case MailTagTypes.TotalCombinedMax: return true;
         case MailTagTypes.TotalCombined: return true;
         case MailTagTypes.SuggestDailyUsage: return true;
         case MailTagTypes.AverageCombined: return true;
         case MailTagTypes.SuggestCombined: return true;
         case MailTagTypes.EstimateCombined: return true;
         case MailTagTypes.TheoryDailyCombined: return true;
         case MailTagTypes.TheoryCombined: return true;
         case MailTagTypes.TheoryCombinedDifference: return true;
         default: return false;
     }
 }
예제 #20
0
 public bool IsCurrency(MailTagTypes type)
 {
     return type == MailTagTypes.Overcharge;
 }
예제 #21
0
 public bool IsPercent(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.UploadPercent: return true;
         case MailTagTypes.DownloadPercent: return true;
         case MailTagTypes.TotalCombinedPercent: return true;
         case MailTagTypes.SuggestCombinedPercent: return true;
         case MailTagTypes.TheoryDailyCombinedPercent: return true;
         default: return false;
     }
 }
예제 #22
0
 public bool IsInt(MailTagTypes type)
 {
     return type == MailTagTypes.DayRemaining;
 }
예제 #23
0
 public bool IsCurrency(MailTagTypes type)
 {
     return(type == MailTagTypes.Overcharge);
 }
예제 #24
0
 public string GetStringValue(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.Name: return _account.DisplayName;
         case MailTagTypes.Username: return _account.Username;
         default: return String.Empty;
     }
 }
예제 #25
0
 public bool IsDateTime(MailTagTypes type)
 {
     switch (type)
     {
         case MailTagTypes.PeriodStart: return true;
         case MailTagTypes.PeriodEnd: return true;
         case MailTagTypes.Now: return true;
         case MailTagTypes.LastUpdate: return true;
         default: return false;
     }
 }
예제 #26
0
        private string FormatCurrency(MailTagTypes type, string param)
        {
            double value = _factory.GetCurrencyValue(type);

            return(value.ToString("C"));
        }
예제 #27
0
 public bool IsInt(MailTagTypes type)
 {
     return(type == MailTagTypes.DayRemaining);
 }