Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit a4e7f510 authored by Franz KOBER josef's avatar Franz KOBER josef
Browse files

added aridrag change dedection

parent ed373a05
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Ninject;
using VECTO3GUI.ViewModel.Adapter;
namespace VECTO3GUI.ViewModel.Impl {
namespace VECTO3GUI.ViewModel.Impl
{
public abstract class AbstractComponentViewModel : AbstractViewModel
{
private string _manufacturer;
......@@ -10,35 +13,55 @@ namespace VECTO3GUI.ViewModel.Impl {
private string _certificationNumber;
private DateTime? _date;
protected HashSet<string> _changedInput = new HashSet<string>();
[Inject] public IAdapterFactory AdapterFactory { set; protected get; }
#region Implementation of ICommonComponentParameters
public string Manufacturer
public virtual string Manufacturer
{
get { return _manufacturer; }
set { _manufacturer = value; }
set { SetProperty(ref _manufacturer, value); }
}
public string Model
public virtual string Model
{
get { return _model; }
set { _model = value; }
set { SetProperty(ref _model, value); }
}
public string CertificationNumber
public virtual string CertificationNumber
{
get { return _certificationNumber; }
set { _certificationNumber = value; }
set { SetProperty(ref _certificationNumber, value); }
}
public DateTime? Date
public virtual DateTime? Date
{
get { return _date; }
set { _date = value; }
set { SetProperty(ref _date, value); }
}
#endregion
protected void SetChangedProperty(bool changed, [CallerMemberName] string propertyName = "")
{
if (!changed) {
if (_changedInput.Contains(propertyName))
_changedInput.Remove(propertyName);
}
else {
if (!_changedInput.Contains(propertyName))
_changedInput.Add(propertyName);
}
}
public override bool AnyDataChanges()
{
return _changedInput.Count > 0;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils;
......@@ -8,11 +10,14 @@ namespace VECTO3GUI.ViewModel.Impl
{
public class AirdragViewModel : AbstractComponentViewModel, IAirdragViewModel
{
private SquareMeter _cdxA0;
private SquareMeter _transferredCdxA;
private string _manufacturer;
private string _model;
private string _certificationNumber;
private DateTime? _date;
private SquareMeter _declaredCdxA;
private bool _useStandardValues;
private string _appVersion;
private IAirdragDeclarationInputData _airdragData;
#region Implementation of IAirdragViewModel
......@@ -27,28 +32,93 @@ namespace VECTO3GUI.ViewModel.Impl
set { SetProperty(ref _useStandardValues, value); }
}
public SquareMeter CdxA_0
public SquareMeter CdxA_0 { get; set; }
public SquareMeter TransferredCdxA { get; set; }
public override string Manufacturer
{
get { return _manufacturer; }
set
{
if (SetProperty(ref _manufacturer, value)) {
var changed = _airdragData != null
? _airdragData.Manufacturer != value
: value != default(string);
SetChangedProperty(changed);
}
}
}
public override string Model
{
get { return _model; }
set
{
if (SetProperty(ref _model, value)) {
var changed = _airdragData != null
? _airdragData.Model != value
: value != default(string);
SetChangedProperty(changed);
}
}
}
public override string CertificationNumber
{
get { return _cdxA0; }
set { SetProperty(ref _cdxA0, value); }
get { return _certificationNumber; }
set
{
if (SetProperty(ref _certificationNumber, value)) {
var changed = _airdragData != null
? _airdragData.CertificationNumber != value
: value != default(string);
SetChangedProperty(changed);
}
}
}
public SquareMeter TransferredCdxA
public override DateTime? Date
{
get { return _transferredCdxA; }
set { SetProperty(ref _transferredCdxA, value); }
get { return _date; }
set
{
if (SetProperty(ref _date, value)) {
var changed = _airdragData != null
? _airdragData.Date != value
: value != default(DateTime?);
SetChangedProperty(changed);
}
}
}
public SquareMeter DeclaredCdxA
{
get { return _declaredCdxA; }
set { SetProperty(ref _declaredCdxA, value); }
set
{
if (SetProperty(ref _declaredCdxA, value)) {
var changed = _airdragData.AirDragArea != null
? _airdragData.AirDragArea != value
: value != default(SquareMeter);
if (changed)
SetAirdragArea();
SetChangedProperty(changed);
}
}
}
public string AppVersion
{
get { return _appVersion; }
set { SetProperty(ref _appVersion, value); }
set
{
if (SetProperty(ref _appVersion, value)) {
var changed = _airdragData.AppVersion != null
? _airdragData.AppVersion != value
: value != default(string);
SetChangedProperty(changed);
}
}
}
......@@ -56,12 +126,12 @@ namespace VECTO3GUI.ViewModel.Impl
protected override void InputDataChanged()
{
JobViewModel.InputDataProvider.Switch()
.If<IDeclarationInputDataProvider>(d => SetValues(d.JobInputData.Vehicle.Components.AirdragInputData))
.If<IEngineeringInputDataProvider>(e => SetValues(e.JobInputData.Vehicle.Components.AirdragInputData));
var inputData = JobViewModel.InputDataProvider as IDeclarationInputDataProvider;
_airdragData = inputData?.JobInputData.Vehicle.Components.AirdragInputData;
SetAirdragValues(_airdragData);
}
private void SetValues(IAirdragDeclarationInputData airdrag)
private void SetAirdragValues(IAirdragDeclarationInputData airdrag)
{
UseMeasuredValues = airdrag != null;
if (airdrag == null) {
......@@ -73,22 +143,20 @@ namespace VECTO3GUI.ViewModel.Impl
CertificationNumber = airdrag.CertificationNumber;
Date = airdrag.Date;
AppVersion = airdrag.AppVersion;
DeclaredCdxA = airdrag.AirDragArea;
SetAirdragArea();
}
public override bool AnyDataChanges()
private void SetAirdragArea()
{
if(_airdragData == null)
return base.AnyDataChanges();
var changed = _airdragData.Model != Model ||
_airdragData.Manufacturer != Manufacturer ||
_airdragData.CertificationNumber != CertificationNumber ||
_airdragData.Date != Date ||
_airdragData.AppVersion != AppVersion ||
_airdragData.AirDragArea != DeclaredCdxA;
DeclaredCdxA = _airdragData.AirDragArea;
CdxA_0 = DeclaredCdxA;
TransferredCdxA = DeclaredCdxA;
}
return changed;
public override bool AnyDataChanges()
{
return _changedInput.Count > 0;
}
}
}
......@@ -20,28 +20,25 @@
Caption="Use Measured Values" CaptionWidthGroup="lblWidth"
Value="{Binding UseMeasuredValues}" UnitWidthGroup="unitWidth"/>
<customControls:CommonDeclarationComponentData
Model="{Binding Model}"
Manufacturer="{Binding Manufacturer}"
Date="{Binding Date}"
CertificationNumber="{Binding CertificationNumber}"
IsEnabled="{Binding UseMeasuredValues}"/>
<customControls:VectoParameterControl
Caption="Manufacturer" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Manufacturer}" />
<customControls:VectoParameterControl
Caption="App Version" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding AppVersion}" />
Caption="Model" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Model}" />
<customControls:VectoParameterControl
Caption="Cd x A 0" CaptionWidthGroup="lblWidth"
Unit="{helper:SIUnit CdxA_0}" UnitWidthGroup="unitWidth"
Value="{Binding CdxA_0, Converter={helper:SIValueConverter}, ConverterParameter=int}"
IsEnabled="{Binding UseMeasuredValues}"/>
<customControls:VectoParameterControl
Caption="Date" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Date}" />
<customControls:VectoParameterControl
Caption="Transferred Cd x A 0" CaptionWidthGroup="lblWidth"
Unit="{helper:SIUnit TransferredCdxA}" UnitWidthGroup="unitWidth"
Value="{Binding TransferredCdxA, Converter={helper:SIValueConverter}, ConverterParameter=double}"
IsEnabled="{Binding UseMeasuredValues}"/>
<customControls:VectoParameterControl
Caption="Certification Number" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding CertificationNumber}" />
<customControls:VectoParameterControl
Caption="App Version" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding AppVersion}" />
<customControls:VectoParameterControl
Caption="DeclaredCd x A 0" CaptionWidthGroup="lblWidth"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment