From 3fb08bedf6ff81c8058dd265ff4b9f3ed65f953a Mon Sep 17 00:00:00 2001 From: "harald.martini@student.tugraz.at" <harald.martini@student.tugraz.at> Date: Tue, 1 Jun 2021 08:39:33 +0200 Subject: [PATCH] Added Consolidated Heatpumpconfigurations --- .../Converter/NullToVisibilityConverter.cs | 6 +- .../InterimStageBusVehicleViewModel_v2_8.cs | 25 +- .../MultistageAuxiliariesViewModel.cs | 415 ++++++++---------- .../ManufacturingStageAuxiliariesView.xaml | 46 +- 4 files changed, 232 insertions(+), 260 deletions(-) diff --git a/VECTO3GUI2020/Helper/Converter/NullToVisibilityConverter.cs b/VECTO3GUI2020/Helper/Converter/NullToVisibilityConverter.cs index 8857067710..7458434d5d 100644 --- a/VECTO3GUI2020/Helper/Converter/NullToVisibilityConverter.cs +++ b/VECTO3GUI2020/Helper/Converter/NullToVisibilityConverter.cs @@ -17,7 +17,11 @@ namespace VECTO3GUI2020.Helper.Converter /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - bool invert = parameter as string == "invert"; + var invert = false; + if (parameter != null) { + invert = string.Equals("invert", (string) parameter, StringComparison.InvariantCultureIgnoreCase); + } + if (value == null) { if (invert) { diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs index 83841e44bd..5466cacdcb 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs @@ -162,13 +162,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation .BusAuxiliaries); _airdragModifiedEditingEnabled = false; - _editingEnabledDictionary = new IndexedStorage<bool>((identifier) => { - - OnPropertyChanged(identifier); - OnPropertyChanged(nameof(EditingEnabledDictionary)); - }); + CreateParameterViewModels(); + } + private void CreateParameterViewModels() + { _parameterViewModels = new Dictionary<string, MultistageParameterViewModel>(); var properties = this.GetType().GetProperties(); var backedUpParameters = new HashSet<string>() { @@ -200,7 +199,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation nameof(ATEcoRollReleaseLockupClutch), }; - foreach(var property in properties) { + foreach (var property in properties) { if (!backedUpParameters.Contains(property.Name)) { continue; } @@ -210,13 +209,13 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation try { previousInputData = ConsolidatedVehicleData?.GetType().GetProperty(property.Name)? .GetValue(ConsolidatedVehicleData); - } catch (Exception e) { Debug.WriteLine(e.Message); } - _parameterViewModels.Add(property.Name, new MultistageParameterViewModel(property.Name, previousInputData, this, resourceManagers:new ResourceManager[]{BusStrings.ResourceManager, Strings.ResourceManager} - )); + _parameterViewModels.Add(property.Name, new MultistageParameterViewModel(property.Name, previousInputData, this, + resourceManagers: new ResourceManager[] { BusStrings.ResourceManager, Strings.ResourceManager } + )); } _parameterViewModels[nameof(WidthInMm)].PreviousContent = ConsolidatedWidthInMm; @@ -271,10 +270,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation _parameterViewModels[nameof(VehicleCode)].AllowedItems = - EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, VehicleCode>((TUGraz.VectoCommon.Models.VehicleCode.NOT_APPLICABLE)); + EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, VehicleCode>((TUGraz.VectoCommon.Models.VehicleCode + .NOT_APPLICABLE)); _parameterViewModels[nameof(LegislativeClass)].AllowedItems = - EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, LegislativeClass>((TUGraz.VectoCommon.Models.LegislativeClass.Unknown)); + EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, LegislativeClass>((TUGraz.VectoCommon.Models + .LegislativeClass.Unknown)); _parameterViewModels[nameof(RegisteredClass)].AllowedItems = EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, RegistrationClass>(RegistrationClass.unknown); @@ -294,8 +295,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation _parameterViewModels[nameof(Manufacturer)].Mandatory = true; _parameterViewModels[nameof(ManufacturerAddress)].Mandatory = true; _parameterViewModels[nameof(VIN)].Mandatory = true; - - } #region Overrides of ViewModelBase diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs index a5ec17c67d..e431ae0674 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAuxiliariesViewModel.cs @@ -43,6 +43,186 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public class MultistageAuxiliariesViewModel : ViewModelBase, IMultistageAuxiliariesViewModel, IDataErrorInfo { + public MultistageAuxiliariesViewModel(IBusAuxiliariesDeclarationData consolidatedAuxiliariesInputData) + { + ConsolidatedInputData = consolidatedAuxiliariesInputData; + if (ConsolidatedInputData?.HVACAux?.HeatPumpPassengerCompartments != null) { + ConsolidatedHeatPumpConfigurationsPassenger = new ObservableCollection<HeatPumpConfiguration>(); + foreach (var (heatPumpType, heatPumpMode) in ConsolidatedInputData?.HVACAux?.HeatPumpPassengerCompartments) { + ConsolidatedHeatPumpConfigurationsPassenger.Add(new HeatPumpConfiguration() + { + HeatPumpMode = heatPumpMode, + HeatPumpType = heatPumpType + }); + } + } + + CreateParameterViewModels(); + } + + private void CreateParameterViewModels() + { + _parameterViewModels = new Dictionary<string, MultistageParameterViewModel>(); + var properties = this.GetType().GetProperties(); + var backedUpParameters = new HashSet<string>() { + nameof(InteriorLightsLED), + nameof(DayrunninglightsLED), + nameof(PositionlightsLED), + nameof(BrakelightsLED), + nameof(HeadlightsLED), + + nameof(SystemConfiguration), + nameof(HeatPumpModeDriverCompartment), + nameof(HeatPumpTypeDriverCompartment), + + nameof(AuxHeaterPower), + nameof(DoubleGlazing), + nameof(AirElectricHeater), + nameof(AdjustableAuxiliaryHeater), + nameof(SeparateAirDistributionDucts), + nameof(OtherHeatingTechnology), + nameof(WaterElectricHeater) + }; + + foreach (var property in properties) + { + if (!backedUpParameters.Contains(property.Name)) + { + continue; + } + + + object previousInputData = null; + try + { + previousInputData = ConsolidatedInputData?.GetType().GetProperty(nameof(property.Name))? + .GetValue(ConsolidatedInputData); + } + catch (Exception e) + { + Debug.WriteLine(e.Message); + } + + _parameterViewModels.Add(property.Name, new MultistageParameterViewModel(property.Name, previousInputData, this, + resourceManagers: new ResourceManager[] { BusStrings.ResourceManager, Strings.ResourceManager } + )); + } + + //Set consolidated Data + _parameterViewModels[nameof(InteriorLightsLED)].PreviousContent = + ConsolidatedInputData?.ElectricConsumers.InteriorLightsLED; + _parameterViewModels[nameof(DayrunninglightsLED)].PreviousContent = + ConsolidatedInputData?.ElectricConsumers.DayrunninglightsLED; + _parameterViewModels[nameof(PositionlightsLED)].PreviousContent = + ConsolidatedInputData?.ElectricConsumers.PositionlightsLED; + _parameterViewModels[nameof(BrakelightsLED)].PreviousContent = + ConsolidatedInputData?.ElectricConsumers.BrakelightsLED; + _parameterViewModels[nameof(HeadlightsLED)].PreviousContent = + ConsolidatedInputData?.ElectricConsumers.HeadlightsLED; + _parameterViewModels[nameof(SystemConfiguration)].PreviousContent = + ConsolidatedInputData?.HVACAux.SystemConfiguration; + _parameterViewModels[nameof(HeatPumpModeDriverCompartment)].PreviousContent = + ConsolidatedInputData?.HVACAux.HeatPumpModeDriverCompartment; + //_parameterViewModels[nameof(HeatPumpTypePassengerCompartment)].PreviousContent = + // ConsolidatedInputData?.HVACAux.HeatPumpTypePassengerCompartment; + _parameterViewModels[nameof(HeatPumpTypeDriverCompartment)].PreviousContent = + ConsolidatedInputData?.HVACAux.HeatPumpTypeDriverCompartment; + //_parameterViewModels[nameof(HeatPumpModePassengerCompartment)].PreviousContent = + // ConsolidatedInputData?.HVACAux.HeatPumpModePassengerCompartment; + _parameterViewModels[nameof(AuxHeaterPower)].PreviousContent = + ConsolidatedInputData?.HVACAux.AuxHeaterPower; + _parameterViewModels[nameof(DoubleGlazing)].PreviousContent = + ConsolidatedInputData?.HVACAux.DoubleGlazing; + _parameterViewModels[nameof(AdjustableAuxiliaryHeater)].PreviousContent = + ConsolidatedInputData?.HVACAux.AdjustableAuxiliaryHeater; + _parameterViewModels[nameof(SeparateAirDistributionDucts)].PreviousContent = + ConsolidatedInputData?.HVACAux.SeparateAirDistributionDucts; + _parameterViewModels[nameof(AirElectricHeater)].PreviousContent = + ConsolidatedInputData?.HVACAux.AirElectricHeater; + _parameterViewModels[nameof(OtherHeatingTechnology)].PreviousContent = + ConsolidatedInputData?.HVACAux.OtherHeatingTechnology; + + + //Set editinggroups + Action<MultistageParameterViewModel> HeatPumpGroupEditingEnabledCallback = model => { + HeatPumpGroupEditingEnabled = model.EditingEnabled; + }; + _parameterViewModels[nameof(SystemConfiguration)].EditingChangedCallback = + HeatPumpGroupEditingEnabledCallback; + _parameterViewModels[nameof(HeatPumpModeDriverCompartment)].EditingChangedCallback = + HeatPumpGroupEditingEnabledCallback; + _parameterViewModels[nameof(HeatPumpTypeDriverCompartment)].EditingChangedCallback = + HeatPumpGroupEditingEnabledCallback; + + //Setup AllowedValues + HeatPumpModeDriverCompartmentAllowedValues = + EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, HeatPumpMode>(HeatPumpMode.N_A); + + SystemConfigurationAllowedValues = + EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, BusHVACSystemConfiguration>( + BusHVACSystemConfiguration.Unknown); + } + + protected override bool SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null) + { + var propertyChanged = base.SetProperty(ref field, value, propertyName); + + if (propertyChanged && _parameterViewModels != null && _parameterViewModels.ContainsKey(propertyName)) + { + _parameterViewModels[propertyName].CurrentContent = value; + } + return propertyChanged; + } + + public void SetAuxiliariesInputData(IBusAuxiliariesDeclarationData componentsAuxiliaryInputData) + { + if (componentsAuxiliaryInputData == null) + { + return; + } + + HeatPumpGroupEditingEnabled = componentsAuxiliaryInputData.HVACAux != null; + SystemConfiguration = componentsAuxiliaryInputData.HVACAux?.SystemConfiguration; + HeatPumpTypeDriverCompartment = componentsAuxiliaryInputData.HVACAux?.HeatPumpTypeDriverCompartment; + HeatPumpModeDriverCompartment = componentsAuxiliaryInputData.HVACAux?.HeatPumpModeDriverCompartment; + HeatPumpConfigurationsPassenger.Clear(); + if (componentsAuxiliaryInputData.HVACAux?.HeatPumpPassengerCompartments != null) + { + foreach (var (heatPumpType, heatPumpMode) in componentsAuxiliaryInputData.HVACAux?.HeatPumpPassengerCompartments) + { + HeatPumpConfigurationsPassenger.Add(new HeatPumpConfiguration() + { + HeatPumpType = heatPumpType, + HeatPumpMode = heatPumpMode + }); + } + } + + + + AuxHeaterPower = componentsAuxiliaryInputData.HVACAux?.AuxHeaterPower; + DoubleGlazing = componentsAuxiliaryInputData.HVACAux?.DoubleGlazing; + AdjustableAuxiliaryHeater = componentsAuxiliaryInputData.HVACAux?.AdjustableAuxiliaryHeater; + SeparateAirDistributionDucts = componentsAuxiliaryInputData.HVACAux?.SeparateAirDistributionDucts; + WaterElectricHeater = componentsAuxiliaryInputData.HVACAux?.WaterElectricHeater; + AirElectricHeater = componentsAuxiliaryInputData.HVACAux?.AirElectricHeater; + OtherHeatingTechnology = componentsAuxiliaryInputData.HVACAux?.OtherHeatingTechnology; + + InteriorLightsLED = componentsAuxiliaryInputData.ElectricConsumers?.InteriorLightsLED; + DayrunninglightsLED = componentsAuxiliaryInputData.ElectricConsumers?.DayrunninglightsLED; + PositionlightsLED = componentsAuxiliaryInputData.ElectricConsumers?.PositionlightsLED; + HeadlightsLED = componentsAuxiliaryInputData.ElectricConsumers?.HeadlightsLED; + BrakelightsLED = componentsAuxiliaryInputData.ElectricConsumers?.BrakelightsLED; + + foreach (var multistageParameterViewModel in _parameterViewModels.Values) + { + multistageParameterViewModel.UpdateEditingEnabled(); + } + OnPropertyChanged(String.Empty); + } + + + private IBusAuxiliariesDeclarationData _consolidatedInputData; @@ -107,8 +287,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation private BusHVACSystemConfiguration? _systemConfiguration; private HeatPumpType? _heatPumpTypeDriverCompartment; private HeatPumpMode? _heatPumpModeDriverCompartment; - private HeatPumpType? _heatPumpTypePassengerCompartment; - private HeatPumpMode? _heatPumpModePassengerCompartment; @@ -183,7 +361,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ICommand AddPassengerHeatpumpCommand { get => _addPassengerHeatpumpCommand ?? - new RelayCommand(() => PassengerHeatPumps.Add(new HeatPumpConfiguration()), + new RelayCommand(() => HeatPumpConfigurationsPassenger.Add(new HeatPumpConfiguration()), () => true); } @@ -192,21 +370,23 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ICommand RemovePassengerHeatpumpCommand { get => _removePasssengerHeatpumpCommand ?? - new RelayCommand<HeatPumpConfiguration>(hp => PassengerHeatPumps.Remove(hp), (hp) => true); + new RelayCommand<HeatPumpConfiguration>(hp => HeatPumpConfigurationsPassenger.Remove(hp), (hp) => true); } public IList<Tuple<HeatPumpType, HeatPumpMode>> HeatPumpPassengerCompartments{ get { var list = new List<Tuple<HeatPumpType, HeatPumpMode>>(); - foreach (var heatPumpConfiguration in PassengerHeatPumps) { + foreach (var heatPumpConfiguration in HeatPumpConfigurationsPassenger) { list.Add(new Tuple<HeatPumpType, HeatPumpMode>((HeatPumpType)heatPumpConfiguration.HeatPumpType, (HeatPumpMode)heatPumpConfiguration.HeatPumpMode)); } return list; } } + public ObservableCollection<HeatPumpConfiguration> ConsolidatedHeatPumpConfigurationsPassenger { get; } + - public ObservableCollection<HeatPumpConfiguration> PassengerHeatPumps { get; } = + public ObservableCollection<HeatPumpConfiguration> HeatPumpConfigurationsPassenger { get; } = new ObservableCollection<HeatPumpConfiguration>(); public class HeatPumpConfiguration : ViewModelBase, ITuple, IDataErrorInfo @@ -324,8 +504,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation if (SetProperty(ref _heatPumpGroupEditingEnabled, value)) { _parameterViewModels[nameof(HeatPumpModeDriverCompartment)].EditingEnabled = value; _parameterViewModels[nameof(HeatPumpTypeDriverCompartment)].EditingEnabled = value; - _parameterViewModels[nameof(HeatPumpTypePassengerCompartment)].EditingEnabled = value; - _parameterViewModels[nameof(HeatPumpModePassengerCompartment)].EditingEnabled = value; _parameterViewModels[nameof(SystemConfiguration)].EditingEnabled = value; } } @@ -374,7 +552,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } } - public HeatPumpMode? HeatPumpModeDriverCompartment { get => _heatPumpModeDriverCompartment; @@ -397,48 +574,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } } - - - - public HeatPumpType? HeatPumpTypePassengerCompartment - { - get => _heatPumpTypePassengerCompartment; - set - { - if (SetProperty(ref _heatPumpTypePassengerCompartment, value)) { - if (value == HeatPumpType.none) { - HeatPumpModePassengerCompartmentAllowedValues = - EnumHelper.GetValuesAsObservableCollectionIncluding<Enum, HeatPumpMode>( - items: HeatPumpMode.N_A); - } else { - HeatPumpModePassengerCompartmentAllowedValues = - EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, HeatPumpMode>( - items: HeatPumpMode.N_A); - } - } - } - } - - public HeatPumpMode? HeatPumpModePassengerCompartment - { - get => _heatPumpModePassengerCompartment; - set => SetProperty(ref _heatPumpModePassengerCompartment, value); - } - - private ObservableCollection<Enum> _heatPumpModePassengerCompartmentAllowedValues; - public ObservableCollection<Enum> HeatPumpModePassengerCompartmentAllowedValues - { - get - { - return _heatPumpModePassengerCompartmentAllowedValues; - } - private set - { - if (SetProperty(ref _heatPumpModePassengerCompartmentAllowedValues, value)) { - _parameterViewModels[nameof(HeatPumpModePassengerCompartment)].AllowedItems = value; - } - } - } #endregion #endregion @@ -545,182 +680,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation #endregion - public void SetAuxiliariesInputData(IBusAuxiliariesDeclarationData componentsAuxiliaryInputData) - { - if (componentsAuxiliaryInputData == null) { - return; - } - - HeatPumpGroupEditingEnabled = componentsAuxiliaryInputData.HVACAux != null; - SystemConfiguration = componentsAuxiliaryInputData.HVACAux?.SystemConfiguration; - HeatPumpTypeDriverCompartment = componentsAuxiliaryInputData.HVACAux?.HeatPumpTypeDriverCompartment; - HeatPumpModeDriverCompartment = componentsAuxiliaryInputData.HVACAux?.HeatPumpModeDriverCompartment; - PassengerHeatPumps.Clear(); - if (componentsAuxiliaryInputData.HVACAux?.HeatPumpPassengerCompartments != null) { - foreach (var (heatPumpType, heatPumpMode) in componentsAuxiliaryInputData.HVACAux?.HeatPumpPassengerCompartments) - { - PassengerHeatPumps.Add(new HeatPumpConfiguration() { - HeatPumpType = heatPumpType, - HeatPumpMode = heatPumpMode - }); - } - } - - - - AuxHeaterPower = componentsAuxiliaryInputData.HVACAux?.AuxHeaterPower; - DoubleGlazing = componentsAuxiliaryInputData.HVACAux?.DoubleGlazing; - AdjustableAuxiliaryHeater = componentsAuxiliaryInputData.HVACAux?.AdjustableAuxiliaryHeater; - SeparateAirDistributionDucts = componentsAuxiliaryInputData.HVACAux?.SeparateAirDistributionDucts; - WaterElectricHeater = componentsAuxiliaryInputData.HVACAux?.WaterElectricHeater; - AirElectricHeater = componentsAuxiliaryInputData.HVACAux?.AirElectricHeater; - OtherHeatingTechnology = componentsAuxiliaryInputData.HVACAux?.OtherHeatingTechnology; - - InteriorLightsLED = componentsAuxiliaryInputData.ElectricConsumers?.InteriorLightsLED; - DayrunninglightsLED = componentsAuxiliaryInputData.ElectricConsumers?.DayrunninglightsLED; - PositionlightsLED = componentsAuxiliaryInputData.ElectricConsumers?.PositionlightsLED; - HeadlightsLED = componentsAuxiliaryInputData.ElectricConsumers?.HeadlightsLED; - BrakelightsLED = componentsAuxiliaryInputData.ElectricConsumers?.BrakelightsLED; - - foreach (var multistageParameterViewModel in _parameterViewModels.Values) { - multistageParameterViewModel.UpdateEditingEnabled(); - } - OnPropertyChanged(String.Empty); - } - - public MultistageAuxiliariesViewModel(IBusAuxiliariesDeclarationData consolidatedAuxiliariesInputData) - { - ConsolidatedInputData = consolidatedAuxiliariesInputData; - _editingEnabledDictionary = new IndexedStorage<bool>((identifier) => { - OnPropertyChanged(nameof(EditingEnabledDictionary)); - OnPropertyChanged(nameof(identifier)); - }); - - - _parameterViewModels = new Dictionary<string, MultistageParameterViewModel>(); - var properties = this.GetType().GetProperties(); - var backedUpParameters = new HashSet<string>() { - nameof(InteriorLightsLED), - nameof(DayrunninglightsLED), - nameof(PositionlightsLED), - nameof(BrakelightsLED), - nameof(HeadlightsLED), - - nameof(SystemConfiguration), - nameof(HeatPumpModeDriverCompartment), - nameof(HeatPumpModePassengerCompartment), - nameof(HeatPumpTypePassengerCompartment), - nameof(HeatPumpTypeDriverCompartment), - - - nameof(AuxHeaterPower), - nameof(DoubleGlazing), - nameof(AirElectricHeater), - nameof(AdjustableAuxiliaryHeater), - nameof(SeparateAirDistributionDucts), - nameof(OtherHeatingTechnology), - nameof(WaterElectricHeater) - - - - }; - - foreach (var property in properties) - { - if (!backedUpParameters.Contains(property.Name)) - { - continue; - } - - - object previousInputData = null; - try - { - previousInputData = ConsolidatedInputData?.GetType().GetProperty(nameof(property.Name))? - .GetValue(ConsolidatedInputData); - - } - catch (Exception e) - { - Debug.WriteLine(e.Message); - } - - _parameterViewModels.Add(property.Name, new MultistageParameterViewModel(property.Name, previousInputData, this, resourceManagers: new ResourceManager[] { BusStrings.ResourceManager, Strings.ResourceManager } - )); - } - - //Set consolidated Data - _parameterViewModels[nameof(InteriorLightsLED)].PreviousContent = - ConsolidatedInputData?.ElectricConsumers.InteriorLightsLED; - _parameterViewModels[nameof(DayrunninglightsLED)].PreviousContent = - ConsolidatedInputData?.ElectricConsumers.DayrunninglightsLED; - _parameterViewModels[nameof(PositionlightsLED)].PreviousContent = - ConsolidatedInputData?.ElectricConsumers.PositionlightsLED; - _parameterViewModels[nameof(BrakelightsLED)].PreviousContent = - ConsolidatedInputData?.ElectricConsumers.BrakelightsLED; - _parameterViewModels[nameof(HeadlightsLED)].PreviousContent = - ConsolidatedInputData?.ElectricConsumers.HeadlightsLED; - _parameterViewModels[nameof(SystemConfiguration)].PreviousContent = - ConsolidatedInputData?.HVACAux.SystemConfiguration; - _parameterViewModels[nameof(HeatPumpModeDriverCompartment)].PreviousContent = - ConsolidatedInputData?.HVACAux.HeatPumpModeDriverCompartment; - //_parameterViewModels[nameof(HeatPumpTypePassengerCompartment)].PreviousContent = - // ConsolidatedInputData?.HVACAux.HeatPumpTypePassengerCompartment; - _parameterViewModels[nameof(HeatPumpTypeDriverCompartment)].PreviousContent = - ConsolidatedInputData?.HVACAux.HeatPumpTypeDriverCompartment; - //_parameterViewModels[nameof(HeatPumpModePassengerCompartment)].PreviousContent = - // ConsolidatedInputData?.HVACAux.HeatPumpModePassengerCompartment; - _parameterViewModels[nameof(AuxHeaterPower)].PreviousContent = - ConsolidatedInputData?.HVACAux.AuxHeaterPower; - _parameterViewModels[nameof(DoubleGlazing)].PreviousContent = - ConsolidatedInputData?.HVACAux.DoubleGlazing; - _parameterViewModels[nameof(AdjustableAuxiliaryHeater)].PreviousContent = - ConsolidatedInputData?.HVACAux.AdjustableAuxiliaryHeater; - _parameterViewModels[nameof(SeparateAirDistributionDucts)].PreviousContent = - ConsolidatedInputData?.HVACAux.SeparateAirDistributionDucts; - _parameterViewModels[nameof(AirElectricHeater)].PreviousContent = - ConsolidatedInputData?.HVACAux.AirElectricHeater; - _parameterViewModels[nameof(OtherHeatingTechnology)].PreviousContent = - ConsolidatedInputData?.HVACAux.OtherHeatingTechnology; - - - - //Set editinggroups - Action<MultistageParameterViewModel> HeatPumpGroupEditingEnabledCallback = model => - { - HeatPumpGroupEditingEnabled = model.EditingEnabled; - }; - _parameterViewModels[nameof(SystemConfiguration)].EditingChangedCallback = - HeatPumpGroupEditingEnabledCallback; - _parameterViewModels[nameof(HeatPumpModeDriverCompartment)].EditingChangedCallback = - HeatPumpGroupEditingEnabledCallback; - _parameterViewModels[nameof(HeatPumpTypePassengerCompartment)].EditingChangedCallback = - HeatPumpGroupEditingEnabledCallback; - _parameterViewModels[nameof(HeatPumpTypeDriverCompartment)].EditingChangedCallback = - HeatPumpGroupEditingEnabledCallback; - _parameterViewModels[nameof(HeatPumpModePassengerCompartment)].EditingChangedCallback = - HeatPumpGroupEditingEnabledCallback; - - //Setup AllowedValues - HeatPumpModeDriverCompartmentAllowedValues = EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, HeatPumpMode>(HeatPumpMode.N_A); - HeatPumpModePassengerCompartmentAllowedValues = - EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, HeatPumpMode>(HeatPumpMode.N_A); - - SystemConfigurationAllowedValues = - EnumHelper.GetValuesAsObservableCollectionExcluding<Enum, BusHVACSystemConfiguration>( - BusHVACSystemConfiguration.Unknown); - - } - - protected override bool SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null) - { - var propertyChanged = base.SetProperty(ref field, value, propertyName); - - if (propertyChanged && _parameterViewModels != null && _parameterViewModels.ContainsKey(propertyName)) { - _parameterViewModels[propertyName].CurrentContent = value; - } - return propertyChanged; - } #region Implementation of IElectricSupplyDeclarationData @@ -774,8 +733,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation { case nameof(HeatPumpTypeDriverCompartment): case nameof(HeatPumpModeDriverCompartment): - case nameof(HeatPumpModePassengerCompartment): - case nameof(HeatPumpTypePassengerCompartment): case nameof(SystemConfiguration): if (HeatPumpGroupEditingEnabled == true && this.GetType().GetProperty(propertyName).GetValue(this) == null) { diff --git a/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml b/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml index c89491ce0a..637a42d957 100644 --- a/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml +++ b/VECTO3GUI2020/Views/Multistage/ManufacturingStageAuxiliariesView.xaml @@ -39,15 +39,28 @@ <ContentControl Content="{Binding ParameterViewModels[HeatPumpTypeDriverCompartment]}"/> <ContentControl Content="{Binding ParameterViewModels[HeatPumpModeDriverCompartment]}"/> <Label Padding="10 4 0 4" Style="{DynamicResource LabelStyle1}">Consolidated Data</Label> - <ListView> - <ListView.ItemsSource> - <Binding Path="ConsolidatedInputData.HVACAux.HeatPumpPassengerCompartments" FallbackValue="null"/> - </ListView.ItemsSource> - <ListView.Visibility> - <Binding Path="ConsolidatedInputData.HVACAux.HeatPumpPassengerCompartments" FallbackValue="Collapsed" Converter="{StaticResource NullToVisibilityConverter}"/> - </ListView.Visibility> - </ListView> - <Separator></Separator> + <ItemsControl + Visibility="{Binding ConsolidatedHeatPumpConfigurationsPassenger, Converter={StaticResource NullToVisibilityConverter}}" + ItemsSource="{Binding ConsolidatedHeatPumpConfigurationsPassenger}" + HorizontalContentAlignment="Stretch" + Padding="5 5 29 5 " > + <ItemsControl.ItemTemplate> + <DataTemplate> + <Border BorderThickness="1"> + <DockPanel LastChildFill="true"> + <UniformGrid DockPanel.Dock="Left" Columns="2"> + <ContentControl Grid.Column="0" DockPanel.Dock="Top" Content="{Binding Path=HeatPumpTypeVM}"/> + <ContentControl Grid.Column="1" DockPanel.Dock="Top" Content="{Binding Path=HeatPumpModeVM}"/> + </UniformGrid> + </DockPanel> + </Border> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + <Label Visibility="{Binding ConsolidatedHeatPumpConfigurationsPassenger, + Converter={StaticResource NullToVisibilityConverter}, + ConverterParameter=invert}" + HorizontalAlignment="Center"> No consolidated data available </Label> <DockPanel LastChildFill="true"> <Button DockPanel.Dock="right" ContentTemplate="{DynamicResource AddIcon}" Command="{Binding AddPassengerHeatpumpCommand}"> @@ -55,14 +68,15 @@ <Label Style="{DynamicResource LabelStyle1}" Padding="10 4 0 4">Current Stage</Label> </DockPanel> - <ListView ItemsSource="{Binding PassengerHeatPumps}" HorizontalContentAlignment="Stretch"> - <ListView.ItemTemplate> + <ItemsControl ItemsSource="{Binding HeatPumpConfigurationsPassenger}" HorizontalContentAlignment="Stretch" + Padding="5"> + <ItemsControl.ItemTemplate> <DataTemplate> <Border BorderThickness="1"> <DockPanel LastChildFill="true"> - <Button DockPanel.Dock="Right" + <Button DockPanel.Dock="Right" Height="24" ContentTemplate="{DynamicResource TrashIcon}" - Command="{Binding RelativeSource={RelativeSource AncestorType=ListView}, + Command="{Binding RelativeSource={RelativeSource AncestorType=ItemsControl}, Path=DataContext.RemovePassengerHeatpumpCommand}" CommandParameter="{Binding }"/> <UniformGrid DockPanel.Dock="Left" Columns="2"> @@ -72,11 +86,9 @@ </DockPanel> </Border> </DataTemplate> - </ListView.ItemTemplate> - </ListView> + </ItemsControl.ItemTemplate> + </ItemsControl> - - <Separator/> <ContentControl Content="{Binding ParameterViewModels[AuxHeaterPower]}"/> <ContentControl Content="{Binding ParameterViewModels[DoubleGlazing]}"/> -- GitLab