diff --git a/.gitignore b/.gitignore index 0f4bd7bb9eb175ec9e68009448ae79a99b7038fd..0f6e6ab57cf9b8b246b9e2d1b043dc98c6921f85 100644 --- a/.gitignore +++ b/.gitignore @@ -218,3 +218,4 @@ Documentation/VehiclesReleaseComparisonDeclarationMode/tmp/ /VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/test.VIF_Report_5.xml /VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/tests.xml /VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/finalGroup41.VIF_Report_4.xml +/VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/output diff --git a/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs b/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs index 1656da5d2dc5b74ceb4a609ec74a9f137e00311c..7c3413d7539e46b06491da6c9b66f20a25ece57c 100644 --- a/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs +++ b/VECTO3GUI2020/Helper/MultistageParameterViewModel.cs @@ -77,10 +77,12 @@ namespace VECTO3GUI2020.Helper Action<MultistageParameterViewModel> propertyChangedCallback = null, params ResourceManager[] resourceManagers) { + _propertyName = propertyName; PreviousContent = previousContent; _propertyChangedCallback = propertyChangedCallback; _parentViewModel = parentViewModel; + //_parentViewModel.PropertyChanged += ParentViewModelPropertyChanged; _propertyInfo = parentViewModel.GetType().GetProperty(propertyName); _viewMode = viewMode; @@ -110,6 +112,20 @@ namespace VECTO3GUI2020.Helper CurrentContent = _propertyInfo.GetValue(parentViewModel); } + private void ParentViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) + { + Debug.Assert((IViewModelBase)sender == _parentViewModel); + if (e.PropertyName != _propertyName) { + return; + } + + var valueFromParent = _propertyInfo.GetValue(sender); + if (valueFromParent != CurrentContent) { + CurrentContent = valueFromParent; + } + } + + private object CreateDummyContent() { var type = _type; @@ -278,6 +294,7 @@ namespace VECTO3GUI2020.Helper _propertyInfo.SetValue(_parentViewModel, _currentContent); _propertyChangedCallback?.Invoke(this); }; + OnPropertyChanged(nameof(CurrentContent)); } } diff --git a/VECTO3GUI2020/ViewModel/Interfaces/Common/IViewModelBase.cs b/VECTO3GUI2020/ViewModel/Interfaces/Common/IViewModelBase.cs index dff379d33bc1c544aa8b9360da5d2108869a4eb7..39808350ec312e252e4fee1d1df3624f39f19ff1 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/Common/IViewModelBase.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/Common/IViewModelBase.cs @@ -1,6 +1,8 @@ -namespace VECTO3GUI2020.ViewModel.Interfaces.Common +using System.ComponentModel; + +namespace VECTO3GUI2020.ViewModel.Interfaces.Common { - public interface IViewModelBase + public interface IViewModelBase : INotifyPropertyChanged { string Title { get; set; } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs index b739a88820f6b767a920fb4a605dd12d899a2bde..f28774411e936b911c6f7b40fb8ec0315bef62d7 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs @@ -614,11 +614,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation { get { - if (AirdragModifiedMultistageEditingEnabled) { - return _airdragModifiedMultistage.toAirdragModifiedEnum(); - } else { - return null; - } + return _airdragModifiedMultistage.toAirdragModifiedEnum(); } set { @@ -626,10 +622,10 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation var newVal = value?.toNullableBool(); if (prevVal != newVal) { AirdragModifiedMultistage = value?.toNullableBool(); - if (_parameterViewModels.ContainsKey(nameof(AirdragModifiedEnum))) - { - _parameterViewModels[nameof(AirdragModifiedEnum)].CurrentContent = value; - } + } + if (_parameterViewModels.ContainsKey(nameof(AirdragModifiedEnum))) + { + _parameterViewModels[nameof(AirdragModifiedEnum)].CurrentContent = value; } } } @@ -654,6 +650,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set { if (SetProperty(ref _airdragModifiedMultistage, value)) { + if(value == false){ + MultistageAirdragViewModel.AirDragViewModel = null; + } AirdragModifiedEnum = value.toAirdragModifiedEnum(); }; } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs index cb78e564ef31bb63fb71bb344bc1f47e19492f3c..34d5ce70380e58cfef39eadecfe48bf192fca9ed 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageAirdragViewModel.cs @@ -120,7 +120,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } - internal bool LoadAirdragFile(string fileName) + public bool LoadAirdragFile(string fileName) { var success = true; var errorStringBuilder = new StringBuilder(); diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultistageAirdragViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultistageAirdragViewModel.cs index b88d8fbb8aa84e91310262a597d4e40ee8b4f841..f56fe95e90896abf983f539a514c5cbc990ce5b8 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultistageAirdragViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultistageAirdragViewModel.cs @@ -10,5 +10,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces IAirDragViewModel AirDragViewModel { get; set; } void SetAirdragInputData(IAirdragDeclarationInputData airdragInputData); + bool LoadAirdragFile(string fileName); } } \ No newline at end of file diff --git a/Vecto3GUI2020Test/ViewModelTests/LoadAndSaveVehicleData.cs b/Vecto3GUI2020Test/ViewModelTests/LoadAndSaveVehicleData.cs index 99e19a515b7d1ce6458e4da226af17d35c521d51..a551fdf6720f3c701be3e605234be565333efb90 100644 --- a/Vecto3GUI2020Test/ViewModelTests/LoadAndSaveVehicleData.cs +++ b/Vecto3GUI2020Test/ViewModelTests/LoadAndSaveVehicleData.cs @@ -211,11 +211,12 @@ namespace Vecto3GUI2020Test Assert.IsNull(vehicleViewModel_v2_8.AirdragModifiedMultistage); Assert.IsNull(vehicleViewModel_v2_8.ConsolidatedAirdragModifiedEnum); - Assert.IsNull(vehicleViewModel_v2_8.AirdragModifiedEnum); + Assert.IsTrue(vehicleViewModel_v2_8.AirdragModifiedEnum == AIRDRAGMODIFIED.UNKNOWN || vehicleViewModel_v2_8.AirdragModifiedEnum == null); Assert.AreEqual(vehicleViewModel_v2_8.AirdragModifiedMultistageEditingEnabled, false); + Assert.Null(vehicleViewModel_v2_8.BusAuxiliaries); @@ -294,6 +295,8 @@ namespace Vecto3GUI2020Test Assert.AreEqual(500, vehicleViewModel.CurbMassChassis.Value());//CorrectedActualMass Assert.AreEqual(3500, vehicleViewModel.GrossVehicleMassRating.Value());//TechnicalPermissibleMaximumLadenMass Assert.AreEqual(false, vehicleViewModel.AirdragModifiedMultistage); + Assert.AreEqual(AIRDRAGMODIFIED.FALSE, vehicleViewModel.AirdragModifiedEnum); + Assert.AreEqual(AIRDRAGMODIFIED.FALSE, vehicleViewModel.ParameterViewModels[nameof(vehicleViewModel.AirdragModifiedEnum)].CurrentContent); Assert.AreEqual(TankSystem.Compressed, vehicleViewModel.TankSystem);//NgTankSystem Assert.AreEqual(RegistrationClass.II_III, vehicleViewModel.RegisteredClass);//ClassBus Assert.AreEqual(1, vehicleViewModel.NumberPassengerSeatsLowerDeck); diff --git a/Vecto3GUI2020Test/ViewModelTests/MultistageAuxiliariesViewModelTests.cs b/Vecto3GUI2020Test/ViewModelTests/MultistageAuxiliariesViewModelTests.cs index 09a3943e4895014ea28827ebba934952a20aa533..07c2f96cb70c838b6c2e0afb2353d3f83328556b 100644 --- a/Vecto3GUI2020Test/ViewModelTests/MultistageAuxiliariesViewModelTests.cs +++ b/Vecto3GUI2020Test/ViewModelTests/MultistageAuxiliariesViewModelTests.cs @@ -57,11 +57,11 @@ namespace Vecto3GUI2020Test.ViewModelTests Assert.IsTrue(auxVm.HeatPumpGroupEditingEnabled); auxVm.HeatPumpGroupEditingEnabled = false; - auxVm.ParameterViewModels[nameof(auxVm.HeatPumpModeDriverCompartment)].CurrentContent = + auxVm.ParameterViewModels[nameof(auxVm.HeatPumpTypeDriverCompartment)].CurrentContent = HeatPumpType.R_744; Assert.IsTrue(auxVm.HeatPumpGroupEditingEnabled); - auxVm.ParameterViewModels[nameof(auxVm.HeatPumpModeDriverCompartment)].CurrentContent = + auxVm.ParameterViewModels[nameof(auxVm.HeatPumpTypeDriverCompartment)].CurrentContent = HeatPumpType.none; diff --git a/Vecto3GUI2020Test/ViewModelTests/VehicleViewModelTests.cs b/Vecto3GUI2020Test/ViewModelTests/VehicleViewModelTests.cs index 51fa2cdc749365299dcfb1a39575b18a815a70e1..d978425dfc1bc730c2a06bef75af7e3e60dad9e5 100644 --- a/Vecto3GUI2020Test/ViewModelTests/VehicleViewModelTests.cs +++ b/Vecto3GUI2020Test/ViewModelTests/VehicleViewModelTests.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Utils; using VECTO3GUI2020.Annotations; +using VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components; using VECTO3GUI2020.ViewModel.MultiStage.Implementation; namespace Vecto3GUI2020Test.ViewModelTests @@ -71,6 +72,8 @@ namespace Vecto3GUI2020Test.ViewModelTests vehicleVM.AirdragModifiedMultistageEditingEnabled = true; Assert.IsFalse(vehicleVM.AirdragModifiedMultistageEditingEnabled); + Assert.IsNull(vehicleVM.AirdragModifiedMultistage); + //Set Mandatory Fields vehicleVM.Manufacturer = "testManufacturer"; vehicleVM.ManufacturerAddress = "Address"; @@ -95,7 +98,6 @@ namespace Vecto3GUI2020Test.ViewModelTests //try to disable AirdragModified secondStageVehicleVM.AirdragModifiedMultistageEditingEnabled = false; Assert.IsTrue(secondStageVehicleVM.AirdragModifiedMultistageEditingEnabled); - } /// <summary> /// no airdrag component set in VIF => AirdragModifiedMultistage is disabled @@ -139,6 +141,42 @@ namespace Vecto3GUI2020Test.ViewModelTests } + [Test] + public void airdragModifiedSetToTrueWhenComponentIsLoaded() + { + var vm = loadFile(consolidated_multiple_stages_airdrag); + + var vehicleViewModel = vm.MultiStageJobViewModel.ManufacturingStageViewModel.VehicleViewModel as DeclarationInterimStageBusVehicleViewModel_v2_8; + + Assert.IsNull(vehicleViewModel.AirdragModifiedMultistage); + + + //Load airdrag file + var airdragLoaded = vehicleViewModel.MultistageAirdragViewModel.LoadAirdragFile(GetFullPath(airdragComponent)); + Assert.IsTrue(airdragLoaded, "Airdrag file was not loaded"); + + //Airdrag modified set to true if a component is loaded and the field is mandatory + Assert.IsTrue(vehicleViewModel.AirdragModifiedMultistage); + Assert.IsTrue(vehicleViewModel.AirdragModifiedMultistageMandatory); + Assert.AreEqual( + AIRDRAGMODIFIED.TRUE, + vehicleViewModel.ParameterViewModels[nameof(vehicleViewModel.AirdragModifiedEnum)].CurrentContent); + + //Airdrag modified set to false if the component is removed + vehicleViewModel.MultistageAirdragViewModel.AirDragViewModel = null; + Assert.IsFalse(vehicleViewModel.AirdragModifiedMultistage); + + //AirdragComponent is removed when airdragmodified is set to false; + //Load airdrag file + airdragLoaded = vehicleViewModel.MultistageAirdragViewModel.LoadAirdragFile(GetFullPath(airdragComponent)); + Assert.IsTrue(airdragLoaded, "Airdrag file was not loaded"); + + vehicleViewModel.AirdragModifiedMultistage = false; + Assert.IsNull(vehicleViewModel.MultistageAirdragViewModel.AirDragViewModel); + + + } +