Esempio n. 1
0
		public static List<WeatherDetail> GetDetails (WuLocation location, TemperatureUnits temp, SpeedUnits speed, LengthUnits length, DistanceUnits distance, PressureUnits pressure)
		{
			var list = new List<WeatherDetail> ();

			for (int i = 0; i < Count; i++) list.Add (GetDetail (i, location, temp, speed, length, distance, pressure));

			return list;
		}
Esempio n. 2
0
		public static WeatherDetail GetDetail (int row, WuLocation location, TemperatureUnits temp, SpeedUnits speed, LengthUnits length, DistanceUnits distance, PressureUnits pressure)
		{
			return new WeatherDetail {
				DetailLabel = GetLabel (row),
				DetailValue = GetValue (row, location, temp, speed, length, distance, pressure),
				IsSectionTop = IsSectionTop (row)
			};
		}
Esempio n. 3
0
		public static string GetValue (int row, WuLocation location, TemperatureUnits temp, SpeedUnits speed, LengthUnits length, DistanceUnits distance, PressureUnits pressure)
		{
			var conditions = location?.Conditions;

			if (conditions == null) return string.Empty;

			switch (row) {
				case 0: return conditions.FeelsLikeString (temp, true, true);
				case 1: return location.SunriseString ();
				case 2: return location.SunsetString ();
				case 3: return location.ProbabilityPercipString ();
				case 4: return conditions.relative_humidity;
				case 5: return conditions.WindString (speed);
				case 6: return conditions.GustString (speed);
				case 7: return conditions.PrecipTodayString (length);
				case 8: return conditions.PressureString (pressure);
				case 9: return conditions.VisibilityString (distance);
				case 10: return location.Conditions.UV.ToString ();
				default: return string.Empty;
			}
		}
Esempio n. 4
0
        public CalibrationHelper()
        {
            PreferencesManager prefManager = PreferencesManager.Instance();

            m_CurrentSpeedUnit = prefManager.SpeedUnit;
        }
Esempio n. 5
0
        private void ParseConfigFile(string filePath)
        {
            // Fill the local variables with infos found in the XML file.
            XmlReader PreferencesReader = new XmlTextReader(filePath);

            if (PreferencesReader != null)
            {
                try
                {
                    while (PreferencesReader.Read())
                    {
                        if ((PreferencesReader.IsStartElement()) && (PreferencesReader.Name == "KinoveaPreferences"))
                        {
                            while (PreferencesReader.Read())
                            {
                                if (PreferencesReader.IsStartElement())
                                {
                                    switch (PreferencesReader.Name)
                                    {
                                    case "HistoryCount":
                                        m_iFilesToSave = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Language":
                                        m_UICultureName = PreferencesReader.ReadString();
                                        break;

                                    case "TimeCodeFormat":
                                        m_TimeCodeFormat = ParseTimeCodeFormat(PreferencesReader.ReadString());
                                        break;

                                    case "SpeedUnit":
                                        m_SpeedUnit = ParseSpeedUnit(PreferencesReader.ReadString());
                                        break;

                                    case "ImageAspectRatio":
                                        m_AspectRatio = ParseImageAspectRatio(PreferencesReader.ReadString());
                                        break;

                                    case "DeinterlaceByDefault":
                                        m_bDeinterlaceByDefault = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "GridColorRGB":
                                        m_GridColor = XmlHelper.ColorParse(PreferencesReader.ReadString(), ';');
                                        break;

                                    case "Plane3DColorRGB":
                                        m_Plane3DColor = XmlHelper.ColorParse(PreferencesReader.ReadString(), ';');
                                        break;

                                    case "WorkingZoneSeconds":
                                        m_iWorkingZoneSeconds = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "WorkingZoneMemory":
                                        m_iWorkingZoneMemory = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "InfosFading":
                                        m_DefaultFading.FromXml(PreferencesReader);
                                        break;

                                    case "DrawOnPlay":
                                        m_bDrawOnPlay = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerThumbnailsSize":
                                        m_iExplorerThumbsSize = (ExplorerThumbSizes)ExplorerThumbSizes.Parse(m_iExplorerThumbsSize.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerVisible":
                                        m_bIsExplorerVisible = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerSplitterDistance":
                                        m_iExplorerSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ActiveFileBrowserTab":
                                        m_ActiveFileBrowserTab = (ActiveFileBrowserTab)ActiveFileBrowserTab.Parse(m_ActiveFileBrowserTab.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerFilesSplitterDistance":
                                        m_iExplorerFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ShortcutsFilesSplitterDistance":
                                        m_iShortcutsFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Shortcuts":
                                        ParseShortcuts(PreferencesReader);
                                        break;

                                    case "CaptureImageDirectory":
                                        m_CaptureImageDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureVideoDirectory":
                                        m_CaptureVideoDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "RecentColors":
                                        ParseRecentColors(PreferencesReader);
                                        break;

                                    case "SURFParameters":
                                        ParseSurfParameters(PreferencesReader);
                                        break;

                                    default:
                                        // Preference from a newer file format...
                                        // We don't have a holder variable for it.
                                        break;
                                    }
                                }
                                else if (PreferencesReader.Name == "KinoveaPreferences")
                                {
                                    break;
                                }
                                else
                                {
                                    // Fermeture d'un tag interne.
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    log.Error("Error happenned while parsing preferences. We'll keep the default values.");
                }
                finally
                {
                    PreferencesReader.Close();
                }
            }
        }
Esempio n. 6
0
        private double ConvertLengthForSpeedUnit(double _fLength, LengthUnits _lengthUnit, SpeedUnits _speedUnits)
        {
            // Convert from one length unit to another.
            // For example: user calibrated the screen using centimeters and wants a speed in km/h.
            // We get a distance in centimeters, we convert it to kilometers.

            // http://en.wikipedia.org/wiki/Conversion_of_units
            // 1 inch           = 0.0254 m.
            // 1 foot			= 0.3048 m.
            // 1 yard           = 0.9144 m.
            // 1 mile           = 1 609.344 m.
            // 1 nautical mile  = 1 852 m.

            double fLength2 = 0;

            switch (_lengthUnit)
            {
            case LengthUnits.Centimeters:
                switch (_speedUnits)
                {
                case SpeedUnits.FeetPerSecond:
                    //  Centimeters to feet.
                    fLength2 = _fLength / 30.48;
                    break;

                case SpeedUnits.MetersPerSecond:
                    //  Centimeters to meters.
                    fLength2 = _fLength / 100;
                    break;

                case SpeedUnits.KilometersPerHour:
                    // Centimeters to kilometers.
                    fLength2 = _fLength / 100000;
                    break;

                case SpeedUnits.MilesPerHour:
                    // Centimeters to miles
                    fLength2 = _fLength / 160934.4;
                    break;

                case SpeedUnits.Knots:
                    // Centimeters to nautical miles
                    fLength2 = _fLength / 185200;
                    break;

                case SpeedUnits.PixelsPerFrame:
                default:
                    // Centimeters to Pixels. (?)
                    // User has calibrated the image but now wants the speed in px/f.
                    fLength2 = _fLength / m_fPixelToUnit;
                    break;
                }
                break;

            case LengthUnits.Meters:
                switch (_speedUnits)
                {
                case SpeedUnits.FeetPerSecond:
                    // Meters to feet.
                    fLength2 = _fLength / 0.3048;
                    break;

                case SpeedUnits.MetersPerSecond:
                    // Meters to meters.
                    fLength2 = _fLength;
                    break;

                case SpeedUnits.KilometersPerHour:
                    // Meters to kilometers.
                    fLength2 = _fLength / 1000;
                    break;

                case SpeedUnits.MilesPerHour:
                    // Meters to miles.
                    fLength2 = _fLength / 1609.344;
                    break;

                case SpeedUnits.Knots:
                    // Meters to nautical miles.
                    fLength2 = _fLength / 1852;
                    break;

                case SpeedUnits.PixelsPerFrame:
                default:
                    // Meters to Pixels. (revert)
                    fLength2 = _fLength / m_fPixelToUnit;
                    break;
                }
                break;

            case LengthUnits.Inches:
                switch (_speedUnits)
                {
                case SpeedUnits.FeetPerSecond:
                    // Inches to feet.
                    fLength2 = _fLength / 12;
                    break;

                case SpeedUnits.MetersPerSecond:
                    // Inches to meters.
                    fLength2 = _fLength / 39.3700787;
                    break;

                case SpeedUnits.KilometersPerHour:
                    // Inches to kilometers.
                    fLength2 = _fLength / 39370.0787;
                    break;

                case SpeedUnits.MilesPerHour:
                    // Inches to miles.
                    fLength2 = _fLength / 63360;
                    break;

                case SpeedUnits.Knots:
                    // Inches to nautical miles.
                    fLength2 = _fLength / 72913.3858;
                    break;

                case SpeedUnits.PixelsPerFrame:
                default:
                    // Inches to Pixels. (revert)
                    fLength2 = _fLength / m_fPixelToUnit;
                    break;
                }
                break;

            case LengthUnits.Feet:
                switch (_speedUnits)
                {
                case SpeedUnits.FeetPerSecond:
                    // Feet to feet.
                    fLength2 = _fLength;
                    break;

                case SpeedUnits.MetersPerSecond:
                    // Feet to meters.
                    fLength2 = _fLength / 3.2808399;
                    break;

                case SpeedUnits.KilometersPerHour:
                    // Feet to kilometers.
                    fLength2 = _fLength / 3280.8399;
                    break;

                case SpeedUnits.MilesPerHour:
                    // Feet to miles.
                    fLength2 = _fLength / 5280;
                    break;

                case SpeedUnits.Knots:
                    // Feet to nautical miles.
                    fLength2 = _fLength / 6076.11549;
                    break;

                case SpeedUnits.PixelsPerFrame:
                default:
                    // Feet to Pixels. (revert)
                    fLength2 = _fLength / m_fPixelToUnit;
                    break;
                }
                break;

            case LengthUnits.Yards:
                switch (_speedUnits)
                {
                case SpeedUnits.FeetPerSecond:
                    // Yards to feet.
                    fLength2 = _fLength * 3;
                    break;

                case SpeedUnits.MetersPerSecond:
                    // Yards to meters.
                    fLength2 = _fLength / 1.0936133;
                    break;

                case SpeedUnits.KilometersPerHour:
                    // Yards to kilometers.
                    fLength2 = _fLength / 1093.6133;
                    break;

                case SpeedUnits.MilesPerHour:
                    // Yards to miles.
                    fLength2 = _fLength / 1760;
                    break;

                case SpeedUnits.Knots:
                    // Yards to nautical miles.
                    fLength2 = _fLength / 2025.37183;
                    break;

                case SpeedUnits.PixelsPerFrame:
                default:
                    // Yards to Pixels. (revert)
                    fLength2 = _fLength / m_fPixelToUnit;
                    break;
                }
                break;

            case LengthUnits.Pixels:
            default:
                // If input length is in pixel, this means the image is not calibrated.
                // Unless the target speed unit is pixel per frame, we can't compute the speed.
                if (_speedUnits != SpeedUnits.PixelsPerFrame)
                {
                    fLength2 = 0;
                    log.Error("Can't compute speed : image is not calibrated and speed is required in real world units.");
                }
                else
                {
                    fLength2 = _fLength;
                }
                break;
            }

            return(fLength2);
        }
Esempio n. 7
0
 static string getWindString(double value, string direction, SpeedUnits unit)
 => $"{direction} {value} {unit.getUnitString ()}";
Esempio n. 8
0
        //Method for laoding units into combo boxes
        private void UnitsLoading(string SelectedOp)
        {
            try
            {
                if (units == null)
                {
                }
                else
                {
                    units.Clear();
                    if (unitsMults == null)
                    {
                    }
                    else
                    {
                        unitsMults.Clear();
                    }
                }
                units      = new List <string>();
                unitsMults = new List <string>();

                switch (SelectedOp)
                {
                case "Length":
                {
                    LengthUnits unit      = new LengthUnits();
                    MetersMults mults     = new MetersMults();
                    var         units2    = Enum.GetValues(unit.GetType());
                    var         multiples = Enum.GetValues(mults.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Mass and Weight":
                {
                    MassUnits  unit      = new MassUnits();
                    KilogMults mults     = new KilogMults();
                    var        multiples = Enum.GetValues(mults.GetType());
                    var        units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Power":
                {
                    PowerUnits unit      = new PowerUnits();
                    WattMults  mults     = new WattMults();
                    var        multiples = Enum.GetValues(mults.GetType());
                    var        units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Pressure":
                {
                    PressureUnits unit      = new PressureUnits();
                    PascaMults    mults     = new PascaMults();
                    var           multiples = Enum.GetValues(mults.GetType());
                    var           units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Energy":
                {
                    EnergyUnits unit      = new EnergyUnits();
                    JouleMults  mults     = new JouleMults();
                    var         multiples = Enum.GetValues(mults.GetType());
                    var         units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Temperature":
                {
                    TemperatureUnits unit = new TemperatureUnits();
                    var units2            = Enum.GetValues(unit.GetType());

                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    unitsMults.Add("Temperature doesn't have Multiples\n Please choose other option");
                    break;
                }

                case "Volume":
                {
                    VolumeUnits unit      = new VolumeUnits();
                    M3Mults     mults     = new M3Mults();
                    var         multiples = Enum.GetValues(mults.GetType());
                    var         units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Angle":
                {
                    AngleUnits unit   = new AngleUnits();
                    var        units2 = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    unitsMults.Add("Angle doesn't have Multiples\n Please choose other option");
                    break;
                }

                case "Area":
                {
                    AreaUnits     unit      = new AreaUnits();
                    MetersqrMults mults     = new MetersqrMults();
                    var           multiples = Enum.GetValues(mults.GetType());
                    var           units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Speed":
                {
                    SpeedUnits unit      = new SpeedUnits();
                    MPSMults   mults     = new MPSMults();
                    var        multiples = Enum.GetValues(mults.GetType());
                    var        units2    = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    foreach (var item in multiples)
                    {
                        unitsMults.Add(item.ToString());
                    }
                    break;
                }

                case "Time":
                {
                    TimeUnits unit   = new TimeUnits();
                    var       units2 = Enum.GetValues(unit.GetType());
                    foreach (var item in units2)
                    {
                        units.Add(item.ToString());
                    }
                    unitsMults.Add("Time doesn't have Multiples\n Please choose other option");
                    break;
                }
                }

                Fromcombo.Items.Clear();
                ToCombo.Items.Clear();
                MultsFromcombo.Items.Clear();
                MultsTocombo.Items.Clear();


                foreach (var v in units)
                {
                    ComboBoxItem boxItem = new ComboBoxItem();
                    boxItem.Background      = new SolidColorBrush(Color.FromArgb(System.Convert.ToByte(255), System.Convert.ToByte(40), System.Convert.ToByte(40), System.Convert.ToByte(40)));
                    boxItem.Foreground      = Brushes.Beige;
                    boxItem.Opacity         = 0.8;
                    boxItem.BorderThickness = new Thickness(0.0);
                    boxItem.Content         = v;
                    Fromcombo.Items.Add(boxItem);
                }

                foreach (var v in units)
                {
                    ComboBoxItem boxItem = new ComboBoxItem();
                    boxItem.Background      = new SolidColorBrush(Color.FromArgb(System.Convert.ToByte(255), System.Convert.ToByte(40), System.Convert.ToByte(40), System.Convert.ToByte(40)));
                    boxItem.Foreground      = Brushes.Beige;
                    boxItem.Opacity         = 0.8;
                    boxItem.BorderThickness = new Thickness(0.0);
                    boxItem.Content         = v;
                    ToCombo.Items.Add(boxItem);
                }

                foreach (var v in unitsMults)
                {
                    ComboBoxItem boxItem = new ComboBoxItem();
                    boxItem.Background      = new SolidColorBrush(Color.FromArgb(System.Convert.ToByte(255), System.Convert.ToByte(40), System.Convert.ToByte(40), System.Convert.ToByte(40)));
                    boxItem.Foreground      = Brushes.Beige;
                    boxItem.Opacity         = 0.8;
                    boxItem.BorderThickness = new Thickness(0.0);
                    boxItem.Content         = v;
                    MultsFromcombo.Items.Add(boxItem);
                }

                foreach (var v in unitsMults)
                {
                    ComboBoxItem boxItem = new ComboBoxItem();
                    boxItem.Background      = new SolidColorBrush(Color.FromArgb(System.Convert.ToByte(255), System.Convert.ToByte(40), System.Convert.ToByte(40), System.Convert.ToByte(40)));
                    boxItem.Foreground      = Brushes.Beige;
                    boxItem.Opacity         = 0.8;
                    boxItem.BorderThickness = new Thickness(0.0);
                    boxItem.Content         = v;
                    MultsTocombo.Items.Add(boxItem);
                }


                Fromcombo.SelectedIndex      = 0;
                ToCombo.SelectedIndex        = 0;
                MultsFromcombo.SelectedIndex = 0;
                MultsTocombo.SelectedIndex   = 0;
                SelectedFrom = Fromcombo.SelectedItem.ToString().Remove(0, 38);
                SelectedTo   = ToCombo.SelectedItem.ToString().Remove(0, 38);
                SelMultsFrom = MultsFromcombo.SelectedItem.ToString().Remove(0, 38);
                SelMultsTo   = MultsTocombo.SelectedItem.ToString().Remove(0, 38);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message + "\nPlease Retry", "Loading-Content-Error");
            }
        }
Esempio n. 9
0
 public static string GustString(this CurrentObservation observation, SpeedUnits units, bool round = false)
 => getWindString(observation.Gust(units, round), observation.wind_dir, units);
Esempio n. 10
0
 static double getValueInUnits(SpeedUnits units, double?imperial, double?metric, bool round = false)
 => getValueInUnits(units.IsImperial(), imperial, metric, round);
Esempio n. 11
0
 public TransRouting(IWorkspace outworkspace, IFeatureClass facility, IFeatureClass roads, string roadsSpeedField, IFunctionRasterDataset DEM, float onRoadMachRate, float onRoadMachPayLoad, float offRoadSpeed, float offRoadMachRate, float offRoadPayLoad, IFeatureClass Barriers = null, float operationsCost = 0, float otherCosts = 0, SpeedUnits spUnits = SpeedUnits.KPH)
 {
     FacilityFeatureClass = facility;
     RoadFeatureClass     = roads;
     BarriersFeatureClass = Barriers;
     RoadsSpeedField      = roadsSpeedField;
     Dem = DEM;
     sp  = DEM.RasterInfo.SpatialReference;
     OnRoadMachineRate  = onRoadMachRate;
     OnRoadPayLoad      = onRoadMachPayLoad;
     OffRoadSpeed       = offRoadSpeed;
     OffRoadMachineRate = offRoadMachRate;
     OffRoadPayLoad     = offRoadPayLoad;
     OperationsCost     = operationsCost;
     OtherCost          = otherCosts;
     OutWorkspace       = outworkspace;
     Units = spUnits;
     getConversionFactor();
 }
Esempio n. 12
0
 private void drawSpeedSelectWindow(int id)
 {
     SpeedRef tempRef = (SpeedRef)GUILayout.SelectionGrid((int)speedRef, speedRefLabels, 3);
     if (tempRef != speedRef)
         ChangeSpeedRef(tempRef);
     SpeedUnits tempUnits = (SpeedUnits)GUILayout.SelectionGrid((int)units, speedUnitLabels, 5);
     if (tempUnits != units)
     {
         units = tempUnits;
         throttleModeChanged(CurrentThrottleMode, ThrtActive, false);
     }
 }
		public static double Gust (this CurrentObservation observation, SpeedUnits units, bool round = false)
			=> getValueInUnits (units, observation?.wind_gust_mph, observation?.wind_gust_kph, round);
 public static double Gust(this CurrentObservation observation, SpeedUnits units, bool round = false)
 => getValueInUnits(units, observation?.wind_gust_mph, observation?.wind_gust_kph, round);
		static string getWindString (double value, string direction, SpeedUnits unit)
			=> $"{direction} {value} {unit.getUnitString ()}";
		static double getValueInUnits (SpeedUnits units, double? imperial, double? metric, bool round = false)
			=> getValueInUnits (units.IsImperial (), imperial, metric, round);
		public static string GustString (this CurrentObservation observation, SpeedUnits units, bool round = false)
			=> getWindString (observation.Gust (units, round), observation.wind_dir, units);
 public void ChangeSpeedUnit(SpeedUnits unit)
 {
     units = unit;
     throttleModeChanged(CurrentThrottleMode, ThrtActive, false);
 }
Esempio n. 19
0
        public void SetSpeed(decimal amount, string unitsString)
        {
            SpeedUnits speedUnits = ChooseSpeedUnits(unitsString);

            _car.SetSpeed(new Speed(amount, speedUnits));
        }
Esempio n. 20
0
 public Speed(decimal amount, SpeedUnits speedUnits)
 {
     Amount     = amount;
     SpeedUnits = speedUnits;
 }
Esempio n. 21
0
 public static double speedUnitTransform(SpeedUnits units, double soundSpeed)
 {
     switch (units)
     {
         case SpeedUnits.mSec:
             return 1;
         case SpeedUnits.knots:
             return 1.943844492440604768413343347219;
         case SpeedUnits.kmph:
             return 3.6;
         case SpeedUnits.mph:
             return 2.236936;
         case SpeedUnits.mach:
             return 1 / soundSpeed;
     }
     return 1;
 }
Esempio n. 22
0
 static bool IsImperial(this SpeedUnits unit) => unit == SpeedUnits.MilesPerHour;
Esempio n. 23
0
        public static List <WeatherDetail> GetDetails(WuLocation location, TemperatureUnits temp, SpeedUnits speed, LengthUnits length, DistanceUnits distance, PressureUnits pressure)
        {
            var list = new List <WeatherDetail> ();

            for (int i = 0; i < Count; i++)
            {
                list.Add(GetDetail(i, location, temp, speed, length, distance, pressure));
            }

            return(list);
        }
Esempio n. 24
0
 static string getUnitString(this SpeedUnits unit) => unit.IsImperial() ? "mph" : "kph";
Esempio n. 25
0
        public static string GetValue(int row, WuLocation location, TemperatureUnits temp, SpeedUnits speed, LengthUnits length, DistanceUnits distance, PressureUnits pressure)
        {
            var conditions = location?.Conditions;

            if (conditions == null)
            {
                return(string.Empty);
            }

            switch (row)
            {
            case 0: return(conditions.FeelsLikeString(temp, true, true));

            case 1: return(location.SunriseString());

            case 2: return(location.SunsetString());

            case 3: return(location.ProbabilityPercipString());

            case 4: return(conditions.relative_humidity);

            case 5: return(conditions.WindString(speed));

            case 6: return(conditions.GustString(speed));

            case 7: return(conditions.PrecipTodayString(length));

            case 8: return(conditions.PressureString(pressure));

            case 9: return(conditions.VisibilityString(distance));

            case 10: return(location.Conditions.UV.ToString());

            default: return(string.Empty);
            }
        }
Esempio n. 26
0
 public static double SpeedUnitToMSec(this double speedUnit, SpeedMode mode, SpeedUnits units, Vessel vessel)
 {
     if (mode == SpeedMode.Mach)
         return speedUnit * vessel.speedOfSound;
     else
     {
         double speed = speedUnit / speedUnitTransform(units, vessel.speedOfSound);
         switch (mode)
         {
             case SpeedMode.True:
                 return speed;
             case SpeedMode.Indicated:
                 return speed * Math.Sqrt(vessel.atmDensity / 1.225) * calcStagnationPres(vessel);
             case SpeedMode.Equivalent:
                 return speed / Math.Sqrt(vessel.atmDensity / 1.225);
         }
         return 0;
     }
 }
Esempio n. 27
0
 private void cmbSpeedUnit_SelectedIndexChanged(object sender, EventArgs e)
 {
     // the combo box items have been filled in the order of the enum.
     m_SpeedUnit = (SpeedUnits)cmbSpeedUnit.SelectedIndex;
 }
Esempio n. 28
0
 public static string unitString(SpeedUnits unit)
 {
     switch (unit)
     {
         case SpeedUnits.mSec:
             return "m/s";
         case SpeedUnits.mach:
             return "mach";
         case SpeedUnits.knots:
             return "knots";
         case SpeedUnits.kmph:
             return "km/h";
         case SpeedUnits.mph:
             return "mph";
     }
     return "";
 }
Esempio n. 29
0
 public static WeatherDetail GetDetail(int row, WuLocation location, TemperatureUnits temp, SpeedUnits speed, LengthUnits length, DistanceUnits distance, PressureUnits pressure)
 {
     return(new WeatherDetail {
         DetailLabel = GetLabel(row),
         DetailValue = GetValue(row, location, temp, speed, length, distance, pressure),
         IsSectionTop = IsSectionTop(row)
     });
 }