Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

Airdarg GUI update

parent c3839286
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace VECTO3GUI.Helper.Converter
{
public class BoolVisibilityConverter : BaseConverter , IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool) {
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using VECTO3GUI.ViewModel.Impl;
namespace VECTO3GUI.Helper.Converter
{
public class EnumConverter : BaseConverter , IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is AirdragConfig) {
return ((AirdragConfig)value).GetLabel();
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
......@@ -158,7 +158,9 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Helper\AvalonEditBehaviour.cs" />
<Compile Include="Helper\Converter\BoolVisibilityConverter.cs" />
<Compile Include="Helper\Converter\ComponentTitleConverter.cs" />
<Compile Include="Helper\Converter\EnumConverter.cs" />
<Compile Include="Helper\Extension.cs" />
<Compile Include="Helper\FileDialogHelper.cs" />
<Compile Include="Helper\OutputWindowHelper.cs" />
......
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Input;
using System.Xml;
using Ninject;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.XML;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader;
using TUGraz.VectoCore.Utils;
using VECTO3GUI.Helper;
using VECTO3GUI.Model.TempDataObject;
using VECTO3GUI.Util;
using VECTO3GUI.ViewModel.Interfaces;
namespace VECTO3GUI.ViewModel.Impl
{
public enum AirdragConfig
{
WithoutAirdrag,
UseMeasurementData,
Unknown
}
public static class AirdragConfigHelper
{
public static string GetLabel(this AirdragConfig airdrag)
{
switch (airdrag)
{
case AirdragConfig.WithoutAirdrag:
return "Without Airdrag";
case AirdragConfig.UseMeasurementData:
return "Use Measurement Data";
}
return string.Empty;
}
public static AirdragConfig GetAirdragConfig(string name)
{
switch (name)
{
case "Without Airdrag":
return AirdragConfig.WithoutAirdrag;
case "Use Measurement Data":
return AirdragConfig.UseMeasurementData;
}
return AirdragConfig.Unknown;
}
}
public class AirdragViewModel : AbstractComponentViewModel, IAirdragViewModel
{
private string _manufacturer;
......@@ -21,6 +64,11 @@ namespace VECTO3GUI.ViewModel.Impl
private IAirdragDeclarationInputData _airdragData;
private AirdragComponentData _componentData;
private bool _isEditable;
private ICommand _airdragConfig;
private ICommand _loadFileCommand;
#region Implementation of IAirdragViewModel
......@@ -110,17 +158,26 @@ namespace VECTO3GUI.ViewModel.Impl
#endregion
public bool IsEditable
{
get { return _isEditable; }
set { SetProperty(ref _isEditable, value); }
}
protected override void InputDataChanged()
{
var inputData = JobViewModel.InputDataProvider as IDeclarationInputDataProvider;
_airdragData = inputData?.JobInputData.Vehicle.Components.AirdragInputData;
SetAirdragValues(_airdragData);
IsEditable = true;
}
private void SetAirdragValues(IAirdragDeclarationInputData airdrag)
{
UseMeasuredValues = airdrag != null;
if (airdrag == null) {
if (airdrag == null)
{
_componentData = new AirdragComponentData(this, true);
return;
}
......@@ -136,6 +193,44 @@ namespace VECTO3GUI.ViewModel.Impl
ClearChangedProperties();
}
#region Commands
public ICommand AirdragConfigCommand
{
get
{
return _airdragConfig ?? (_airdragConfig = new RelayCommand<AirdragConfig>(DoAirdragConfig));
}
}
private void DoAirdragConfig(AirdragConfig config)
{
IsEditable = config == AirdragConfig.UseMeasurementData;
}
public ICommand LoadFileCommand
{
get
{
return _loadFileCommand ?? (_loadFileCommand = new RelayCommand(DoLoadFile, CanLoadFile));
}
}
private bool CanLoadFile()
{
return IsEditable;
}
private void DoLoadFile()
{
var filePath = FileDialogHelper.ShowSelectFilesDialog(false)?.FirstOrDefault();
ReadSelectedXml(null);
}
#endregion
private void SetAirdragArea(IAirdragDeclarationInputData airdrag)
{
DeclaredCdxA = airdrag.AirDragArea;
......@@ -154,5 +249,11 @@ namespace VECTO3GUI.ViewModel.Impl
ClearChangedProperties();
return _componentData;
}
private void ReadSelectedXml(string filePath)
{
if (filePath == null)
return;
}
}
}
using TUGraz.VectoCommon.InputData;
using System.Windows.Input;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
namespace VECTO3GUI.ViewModel.Interfaces
......@@ -6,5 +7,9 @@ namespace VECTO3GUI.ViewModel.Interfaces
public interface IAirdragViewModel : IAirdrag, IComponentViewModel
{
IAirdragDeclarationInputData ModelData { get; }
bool IsEditable { get; }
ICommand LoadFileCommand { get; }
ICommand AirdragConfigCommand { get; }
}
}
......@@ -6,8 +6,8 @@
xmlns:interfaces="clr-namespace:VECTO3GUI.ViewModel.Interfaces"
xmlns:customControls="clr-namespace:VECTO3GUI.Views.CustomControls"
xmlns:helper="clr-namespace:VECTO3GUI.Helper"
xmlns:impl="clr-namespace:VECTO3GUI.ViewModel.Impl"
xmlns:converter="clr-namespace:VECTO3GUI.Helper.Converter"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800">
......@@ -16,44 +16,80 @@
</d:AirdragDeclarationView.DataContext>
<Grid>
<StackPanel Orientation="Vertical" Width="400" HorizontalAlignment="Left" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="150"/>
<RowDefinition />
</Grid.RowDefinitions>
<customControls:CheckboxParameter
Caption="Use Measured Values" CaptionWidthGroup="lblWidth"
Value="{Binding UseMeasuredValues}" UnitWidthGroup="unitWidth"/>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<customControls:VectoParameterControl
Caption="Manufacturer" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Manufacturer}" />
<GroupBox Header="Aridrag Configuration" Grid.Row="1" Grid.Column="1" Width="500" HorizontalAlignment="Left" VerticalAlignment="Top">
<customControls:VectoParameterControl
Caption="Model" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Model}" />
<StackPanel Orientation="Vertical">
<RadioButton GroupName="AirdragConfig" Margin="5"
Content="{Binding Source={x:Static impl:AirdragConfig.WithoutAirdrag}, Converter={converter:EnumConverter}}"
Command="{Binding AirdragConfigCommand}" CommandParameter="{Binding Source={x:Static impl:AirdragConfig.WithoutAirdrag}}"/>
<RadioButton GroupName="AirdragConfig" Margin="5"
Content="{Binding Source={x:Static impl:AirdragConfig.UseMeasurementData}, Converter={converter:EnumConverter}}"
Command="{Binding AirdragConfigCommand}" CommandParameter="{ Binding Source={x:Static impl:AirdragConfig.UseMeasurementData}}"
IsChecked="{Binding IsEditable}"/>
<!-- <mah:DateTimePicker -->
<!-- SelectedDate="{Binding Date}" -->
<!-- Culture="en-In" -->
<!-- SelectedTimeFormat="Short" -->
<!-- SelectedDateFormat="Short"/> -->
<StackPanel Orientation="Horizontal" Margin="30,10,10,10">
<Label Content="Load Component File:"/>
<Button Content="Load File" Width="80" Margin="10,0,0,0"
Command="{Binding LoadFileCommand}"/>
</StackPanel>
<customControls:VectoParameterControl
Caption="Date" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Date}" />
</StackPanel>
<customControls:VectoParameterControl
Caption="Certification Number" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding CertificationNumber}" />
<customControls:VectoParameterControl
</GroupBox>
<GroupBox Header="Aridrag Data" Width="500" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="1" Height="250" VerticalAlignment="Top"
Visibility="{Binding IsEditable, Converter={converter:BoolVisibilityConverter}}">
<StackPanel Orientation="Vertical" Width="450" HorizontalAlignment="Left" Grid.IsSharedSizeScope="True">
<customControls:VectoParameterControl
Caption="Manufacturer" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Manufacturer}" IsEnabled="{Binding IsEditable}" />
<customControls:VectoParameterControl
Caption="Model" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Model}" IsEnabled="{Binding IsEditable}" />
<!-- <mah:DateTimePicker -->
<!-- SelectedDate="{Binding Date}" -->
<!-- Culture="en-In" -->
<!-- SelectedTimeFormat="Short" -->
<!-- SelectedDateFormat="Short"/> -->
<customControls:VectoParameterControl
Caption="Date" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding Date}" IsEnabled="{Binding IsEditable}"/>
<customControls:VectoParameterControl
Caption="Certification Number" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding CertificationNumber}" IsEnabled="{Binding IsEditable}" />
<customControls:VectoParameterControl
Caption="App Version" Unit="" CaptionWidthGroup="vehicleLbl" UnitWidthGroup="unitWidth"
Value="{Binding AppVersion}" />
Value="{Binding AppVersion}" IsEnabled="{Binding IsEditable}" />
<customControls:VectoParameterControl
<customControls:VectoParameterControl
Caption="DeclaredCd x A 0" CaptionWidthGroup="lblWidth"
Unit="{helper:SIUnit DeclaredCdxA}" UnitWidthGroup="unitWidth"
Value="{Binding DeclaredCdxA, Converter={converter:SIValueConverter}, ConverterParameter=double}"
IsEnabled="{Binding UseMeasuredValues}"/>
IsEnabled="{Binding IsEditable}"/>
</StackPanel>
</StackPanel>
</GroupBox>
</Grid>
</UserControl>
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