コード例 #1
0
        void GetUnit(XmlNode node)
        {
            String unitStr = GetAttr(node, "unit", "millimeter");

            switch (unitStr)
            {
            default:
            case "millimeter":
                m_unit        = eUnit.Millimeter;
                m_scaleFactor = 1.0f;
                break;

            case "inch":
                m_unit        = eUnit.Inch;
                m_scaleFactor = 25.4f;
                break;

            case "meter":
                m_unit        = eUnit.Meter;
                m_scaleFactor = 1000.0f;
                break;

            case "micron":
                m_unit        = eUnit.Micron;
                m_scaleFactor = 1.0f / 1000.0f;
                break;

            case "feet":
                m_unit        = eUnit.Feet;
                m_scaleFactor = 12.0f * 2.54f;
                break;
            }
        }
コード例 #2
0
 private static void CheckUnitEqualityAndThrowException(eUnit UnitA, eUnit UnitB)
 {
     if (UnitA != UnitB)
     {
         throw new UnitIncorrectException();
     }
 }
コード例 #3
0
        public static ConfigFile Load(string filename)
        {
            var result = new ConfigFile();
            var list   = result.SizeList;

            using (var sr = new System.IO.StreamReader(filename))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    if (line.Trim().StartsWith("#"))
                    {
                        continue;
                    }
                    string[] parts = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length < 4)
                    {
                        continue;
                    }

                    float  w    = float.Parse(parts[0]);
                    float  h    = float.Parse(parts[1]);
                    eUnit  u    = (eUnit)Enum.Parse(typeof(eUnit), parts[2]);
                    string n    = parts[3];
                    var    item = new CanvasSize()
                    {
                        name = n, width = w, height = h, unit = u
                    };
                    list.Add(item);
                }
            }

            return(result);
        }
コード例 #4
0
 public static eUnit Get(eUnitOperator TheOperation, eUnit A, eUnit B)
 {
     if (TheOperation == eUnitOperator.Division)
     {
         return(DivisionLUT[(int)A, (int)B]);
     }
     else
     {
         return(MultiplicationLUT[(int)A, (int)B]);
     }
 }
コード例 #5
0
 public Distance(double value, eUnit unit)
 {
     if (unit == eUnit.Kilometres)
     {
         Kilometres = value;
     }
     else if (unit == eUnit.Metres)
     {
         Metres = value;
     }
     else
     {
         Miles = value;
     }
 }
コード例 #6
0
ファイル: PressureInfo.cs プロジェクト: Engin1980/METAR.NET
 /// <summary>
 /// Sets pressure value.
 /// </summary>
 /// <param name="value">Pressure value.</param>
 /// <param name="unit">Pressure unit.</param>
 public void Set(double value, eUnit unit)
 {
     Unit = unit;
     if (value <= 0)
     {
         throw new ArgumentException("Pressure value cannot be less or equal 0.", "value");
     }
     if (unit == eUnit.hPa)
     {
         QNH = (int)value;
     }
     else
     {
         mmHq = value;
     }
 }
コード例 #7
0
 public Unit GetUnit(eUnit unit)
 {
     return(m_listunits[(int)unit]);
 }
コード例 #8
0
 /// <summary>Initializes a new instance of the <see cref="WDItemEntity"/> class.</summary>
 /// <param name="path">The path.</param>
 /// <param name="file">The file.</param>
 /// <param name="size">The size.</param>
 /// <param name="unit">The unit.</param>
 public WDItemEntity(string file, int size, eUnit unit)
 {
     File = file;
     Size = size;
     Unit = unit;
 }
コード例 #9
0
 public CNumberWithUnit(double TheValue, eUnit TheUnit)
 {
     Value = Value;
     Unit  = TheUnit;
 }
コード例 #10
0
        void GetUnit(XmlNode node)
        {
            String unitStr = GetAttr(node, "unit", "millimeter");
            switch (unitStr)
            {
                default:
                case "millimeter":
                    m_unit = eUnit.Millimeter;
                    m_scaleFactor = 1.0f;
                    break;

                case "inch":
                    m_unit = eUnit.Inch;
                    m_scaleFactor = 25.4f;
                    break;

                case "meter":
                    m_unit = eUnit.Meter;
                    m_scaleFactor = 1000.0f;
                    break;

                case "micron":
                    m_unit = eUnit.Micron;
                    m_scaleFactor = 1.0f / 1000.0f;
                    break;

                case "feet":
                    m_unit = eUnit.Feet;
                    m_scaleFactor = 12.0f * 2.54f;
                    break;
            }
        }