Пример #1
0
        private TyreCompoundProperties CreateTyreCompoundProperties(SectionData tyreSectionDataFront, SectionData tyreThermalDataFront, SectionData tyreSectionDataRear, SectionData tyreThermalDataRear)
        {
            TyreCompoundProperties newCompoundProperties = new TyreCompoundProperties();
            string shortName = tyreSectionDataFront.Keys.ContainsKey("SHORT_NAME") ? tyreSectionDataFront.Keys.GetKeyData("SHORT_NAME").Value : string.Empty;

            newCompoundProperties.CompoundName = Trim($"{tyreSectionDataFront.Keys.GetKeyData("NAME").Value}");
            if (!string.IsNullOrEmpty(shortName))
            {
                newCompoundProperties.CompoundName += $" ({shortName})";
            }
            newCompoundProperties.FrontIdealPressureWindow = Pressure.FromKiloPascals(10);
            newCompoundProperties.FrontIdealPressure       = ExtractPressureFromKeyData(tyreSectionDataFront.Keys.GetKeyData("PRESSURE_IDEAL"));

            newCompoundProperties.RearIdealPressureWindow = Pressure.FromKiloPascals(10);
            newCompoundProperties.RearIdealPressure       = ExtractPressureFromKeyData(tyreSectionDataRear.Keys.GetKeyData("PRESSURE_IDEAL"));

            var temperatureCurveFront = GetTemperatureCurve(tyreThermalDataFront.Keys.GetKeyData("PERFORMANCE_CURVE").Value);
            var temperatureCurveRear  = GetTemperatureCurve(tyreThermalDataRear.Keys.GetKeyData("PERFORMANCE_CURVE").Value);

            (Temperature idealTemperature, Temperature window)temperatureRange = GetTemperatureProperties(temperatureCurveFront);
            if (temperatureRange.idealTemperature != null && temperatureRange.window != null)
            {
                newCompoundProperties.FrontIdealTemperature       = temperatureRange.idealTemperature;
                newCompoundProperties.FrontIdealTemperatureWindow = temperatureRange.window;
            }

            temperatureRange = GetTemperatureProperties(temperatureCurveRear);
            if (temperatureRange.idealTemperature != null && temperatureRange.window != null)
            {
                newCompoundProperties.RearIdealTemperature       = temperatureRange.idealTemperature;
                newCompoundProperties.RearIdealTemperatureWindow = temperatureRange.window;
            }

            return(newCompoundProperties);
        }
        private void UpdateCarSettingsWindowViewModel()
        {
            CarModelProperties          playersCarProperties = _simSettingAdapter.LastUsedCarProperties;
            CarModelPropertiesViewModel playerCarsViewModel  = new CarModelPropertiesViewModel();

            playerCarsViewModel.FromModel(playersCarProperties);

            _carSettingsWindowViewModel.CarModelPropertiesViewModel = playerCarsViewModel;

            TyreCompoundProperties lastUsedTyre = _simSettingAdapter.LastUsedCompound;
            ObservableCollection <TyreCompoundPropertiesViewModel> tyreSettingsViewModels = new ObservableCollection <TyreCompoundPropertiesViewModel>();

            playerCarsViewModel.TyreCompoundsProperties.ForEach(x => tyreSettingsViewModels.Add(x));
            foreach (TyreCompoundProperties globalTyreCompoundsProperty in _simSettingAdapter.GlobalTyreCompoundsProperties)
            {
                TyreCompoundPropertiesViewModel viewModel = new TyreCompoundPropertiesViewModel();
                viewModel.FromModel(globalTyreCompoundsProperty);
                viewModel.IsGlobalCompound = true;
                tyreSettingsViewModels.Add(viewModel);
            }

            _carSettingsWindowViewModel.TyreSettingsViewModels        = tyreSettingsViewModels;
            _carSettingsWindowViewModel.SelectedTyreSettingsViewModel = tyreSettingsViewModels.First(x => x.CompoundName == lastUsedTyre.CompoundName);
        }