Exemple #1
0
        void SetClouds()
        {
            if (metar == null || metar.Clouds == null)
            {
                return;
            }

            StringBuilder sb     = new StringBuilder();
            List <Clouds> clouds = metar.Clouds;

            foreach (Clouds c in clouds)
            {
                if (sb.Length > 0)
                {
                    sb.Append("\n");
                }

                if (c.Coverage == CloudsCoverage.Clear)
                {
                    skyConditions.Text = "Clear sky";
                    return;
                }

                switch (c.Coverage)
                {
                case CloudsCoverage.Few:
                case CloudsCoverage.Scatterred:
                case CloudsCoverage.Broken:
                case CloudsCoverage.Overcast:
                    sb.Append(c.Coverage.ToString());
                    break;
                }

                switch (c.Kind)
                {
                case CloudsKind.Cumulus:
                case CloudsKind.Cumulonimbus:
                case CloudsKind.Cirrus:
                    sb.AppendFormat(" {0}", c.Kind.ToString().ToLower(CultureInfo.InvariantCulture));
                    break;

                case CloudsKind.ToweringCumulus:
                    sb.Append(" towering cumulus");
                    break;
                }
                sb.Append(" clouds");

                bool showHeight = true;
                switch (c.Accuracy)
                {
                case CloudsAccuracy.LessThan:
                    sb.Append(" at less than");
                    break;

                case CloudsAccuracy.Exactly:
                    sb.Append(" at");
                    break;

                default:
                    showHeight = false;
                    break;
                }

                if (showHeight)
                {
                    double height = 0.0;
                    switch (cloudsUnits)
                    {
                    case CloudsUnits.Feet:
                        height = c.Feet;
                        break;

                    case CloudsUnits.Meters:
                        height = c.Meters;
                        break;

                    case CloudsUnits.Kilometers:
                        height = c.Kilometers;
                        break;
                    }

                    sb.AppendFormat(" {0} {1}", height, cloudsUnits.ToString().ToLower(CultureInfo.InvariantCulture));
                }
            }

            skyConditions.Text = sb.ToString();
        }