using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using IStation.Formula;
|
|
namespace IStation.Unit
|
{
|
/// <summary>
|
/// 扬程单位辅助类
|
/// </summary>
|
public class UnitHHelper : IUnitHelper
|
{
|
|
#region 静态
|
|
public static double Convert(eUnitH fromUnit, eUnitH toUnit, double fromValue)
|
{
|
var toValue = fromValue;
|
switch (fromUnit)
|
{
|
case eUnitH.M:
|
{
|
switch (toUnit)
|
{
|
case eUnitH.M: break;
|
case eUnitH.MPa:toValue=CalcuHelper.M2Mpa(fromValue); break;
|
default: break;
|
}
|
}
|
break;
|
case eUnitH.MPa:
|
{
|
switch (toUnit)
|
{
|
case eUnitH.M: toValue =CalcuHelper.Mpa2M(fromValue); break;
|
case eUnitH.MPa: break;
|
default: break;
|
}
|
}
|
break;
|
default: break;
|
}
|
return toValue;
|
}
|
|
public static string GetCnUnitName(eUnitH unit)
|
{
|
switch (unit)
|
{
|
case eUnitH.M: return "米";
|
case eUnitH.MPa: return "兆帕";
|
default: return string.Empty;
|
}
|
|
}
|
|
public static List<string> GetCnUnitNameList()
|
{
|
var list = new List<string>();
|
foreach (eUnitH item in Enum.GetValues(typeof(eUnitH)))
|
{
|
list.Add(GetCnUnitName(item));
|
}
|
return list;
|
}
|
|
public static Dictionary<eUnitH, string> GetCnUnitDict()
|
{
|
var dic = new Dictionary<eUnitH, string>();
|
foreach (eUnitH item in Enum.GetValues(typeof(eUnitH)))
|
{
|
dic.Add(item, GetCnUnitName(item));
|
}
|
return dic;
|
}
|
|
public static string GetEnUnitName(eUnitH unit)
|
{
|
switch (unit)
|
{
|
case eUnitH.M: return "m";
|
case eUnitH.MPa: return "MPa";
|
default: return string.Empty;
|
}
|
}
|
|
public static List<string> GetEnUnitNameList()
|
{
|
var list = new List<string>();
|
foreach (eUnitH item in Enum.GetValues(typeof(eUnitH)))
|
{
|
list.Add(GetEnUnitName(item));
|
}
|
return list;
|
}
|
|
public static Dictionary<eUnitH, string> GetEnUnitDict()
|
{
|
var dic = new Dictionary<eUnitH, string>();
|
foreach (eUnitH item in Enum.GetValues(typeof(eUnitH)))
|
{
|
dic.Add(item, GetEnUnitName(item));
|
}
|
return dic;
|
}
|
|
|
|
|
#endregion
|
|
#region 显示接口
|
|
|
double IUnitHelper.Convert(int fromUnit, int toUnit, double fromValue)
|
{
|
return Convert((eUnitH)fromUnit, (eUnitH)toUnit, fromValue);
|
}
|
|
string IUnitHelper.GetCnUnitName(int unit)
|
{
|
return GetCnUnitName((eUnitH)unit);
|
}
|
|
List<string> IUnitHelper.GetCnUnitNameList()
|
{
|
return GetCnUnitNameList();
|
}
|
|
Dictionary<int, string> IUnitHelper.GetCnUnitDict()
|
{
|
var dic = new Dictionary<int, string>();
|
foreach (var item in GetCnUnitDict())
|
{
|
dic.Add((int)item.Key, item.Value);
|
}
|
return dic;
|
}
|
|
string IUnitHelper.GetEnUnitName(int unit)
|
{
|
return GetEnUnitName((eUnitH)unit);
|
}
|
|
List<string> IUnitHelper.GetEnUnitNameList()
|
{
|
return GetEnUnitNameList();
|
}
|
|
Dictionary<int, string> IUnitHelper.GetEnUnitDict()
|
{
|
var dic = new Dictionary<int, string>();
|
foreach (var item in GetEnUnitDict())
|
{
|
dic.Add((int)item.Key, item.Value);
|
}
|
return dic;
|
}
|
|
|
|
|
#endregion
|
}
|
}
|