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

Skip to content
Snippets Groups Projects
Commit f7c89a09 authored by Harald MARTINI's avatar Harald MARTINI
Browse files

Added Possibilty to create a new empty (exempted) stage input

parent f5167aff
No related branches found
No related tags found
No related merge requests found
Showing
with 220 additions and 45 deletions
......@@ -268,8 +268,6 @@ namespace VECTO3GUI.ViewModel.Impl
#region Commands
public ICommand RunSimulation
{
get { return _runSimulationCommand ?? (_runSimulationCommand = new RelayCommand(DoRunSimulation, CanRunSimulationCmd)); }
......
using System.Windows;
using System.Windows.Controls.Primitives;
using Microsoft.Xaml.Behaviors;
namespace VECTO3GUI2020.Behaviours
{
public class PopUpHorizontalAlignmentBehavior : Behavior<Popup>
{
private FrameworkElement _placementTarget;
private double _initialHorizontalOffset;
private double _popUpWidth;
private void _placementTarget_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.WidthChanged) {
SetHorizontalAlignment(e.NewSize.Width, this.AssociatedObject.ActualWidth);
}
}
private void SetHorizontalAlignment(double placeMentTargetActualWidth, double popUpActualWidth)
{
if (popUpActualWidth > placeMentTargetActualWidth) {
this.AssociatedObject.HorizontalOffset = placeMentTargetActualWidth - popUpActualWidth;
}
}
#region Overrides of Behavior
protected override void OnAttached()
{
_placementTarget = this.AssociatedObject.PlacementTarget as FrameworkElement;
_popUpWidth = this.AssociatedObject.MinWidth;
_initialHorizontalOffset = this.AssociatedObject.HorizontalOffset;
_placementTarget.SizeChanged += _placementTarget_SizeChanged;
this.AssociatedObject.SizeChanged += AssociatedObject_SizeChanged;
SetHorizontalAlignment(_placementTarget.ActualWidth, this.AssociatedObject.ActualWidth);
base.OnAttached();
}
private void AssociatedObject_SizeChanged(object sender, SizeChangedEventArgs e)
{
_popUpWidth = e.NewSize.Width;
SetHorizontalAlignment(_placementTarget.ActualWidth, e.NewSize.Width);
}
protected override void OnDetaching()
{
_placementTarget.SizeChanged -= _placementTarget_SizeChanged;
this.AssociatedObject.HorizontalOffset = _initialHorizontalOffset;
base.OnDetaching();
}
#endregion
}
}
\ No newline at end of file
......@@ -18,6 +18,8 @@ namespace VECTO3GUI2020.Ninject
Bind<IDocumentViewModel>().To<DeclarationJobViewModel>().Named(XmlDocumentType.DeclarationJobData.ToString());
Bind<IDocumentViewModel>().To<MultiStageJobViewModel_v0_1>()
.Named(XmlDocumentType.MultistageOutputData.ToString());
//Bind<IDocumentViewModel>().To<MultistageJobViewModel>().Named(XmlDocumentType.MultistageOutputData.ToString());
//Bind<IDocumentViewModel>().To<DeclarationTrailerJobDocumentViewModel>().Named(XmlDocumentType.DeclarationTrailerJobData.ToString());
......
......@@ -27,9 +27,14 @@ namespace VECTO3GUI2020.Ninject
() => new UseFirstArgumentTypeAsNameInstanceProvider(true));
Bind<IMultiStageViewModelFactory>().To<MultiStageViewModelFactory>().InSingletonScope();
Bind<IMultiStageViewModelFactoryDefaultInstanceProvider>().ToFactory();
Bind<IMultiStageViewModelFactoryTypeAsNameInstanceProvider>().ToFactory(() => new UseFirstArgumentTypeAsNameInstanceProvider());
Bind<IMultiStageViewModelFactory>().To<MultiStageViewModelFactory>().
InSingletonScope();
Bind<IMultiStageViewModelFactoryDefaultInstanceProvider>().
ToFactory();
Bind<IMultiStageViewModelFactoryTypeAsNameInstanceProvider>().
ToFactory(() => new UseFirstArgumentTypeAsNameInstanceProvider());
Bind<IMultistageViewModelFactoryFirstParameterAsNameInstanceProvider>().ToFactory(() =>
new UseFirstArgumentAsNameInstanceProvider(skipFirstArgument: false));
}
}
......
......@@ -11,17 +11,27 @@ namespace VECTO3GUI2020.Ninject
public class MultiStageViewModelFactory : IMultiStageViewModelFactory
{
private IMultiStageViewModelFactoryDefaultInstanceProvider _multiStageVmFactoryDefaultInstanceProvider;
private IMultiStageViewModelFactoryTypeAsNameInstanceProvider _multiStageViewModelFactoryImplementation;
private IMultiStageViewModelFactoryTypeAsNameInstanceProvider _multiStageViewModelFactoryTypeAsNameInstanceProvider;
private IMultistageViewModelFactoryFirstParameterAsNameInstanceProvider
_multistageViewModelFactoryFirstParameterAsNameInstanceProvider;
public MultiStageViewModelFactory(IMultiStageViewModelFactoryDefaultInstanceProvider multiStageVmFactoryDefaultInstanceProvider, IMultiStageViewModelFactoryTypeAsNameInstanceProvider multiStageViewModelFactoryImplementation1)
public MultiStageViewModelFactory(IMultiStageViewModelFactoryDefaultInstanceProvider multiStageVmFactoryDefaultInstanceProvider,
IMultiStageViewModelFactoryTypeAsNameInstanceProvider multiStageViewModelFactoryTypeAsNameInstanceProvider, IMultistageViewModelFactoryFirstParameterAsNameInstanceProvider multistageViewModelFactoryFirstParameterAsNameInstanceProvider)
{
_multiStageVmFactoryDefaultInstanceProvider = multiStageVmFactoryDefaultInstanceProvider;
_multiStageViewModelFactoryImplementation = multiStageViewModelFactoryImplementation1;
_multiStageViewModelFactoryTypeAsNameInstanceProvider = multiStageViewModelFactoryTypeAsNameInstanceProvider;
_multistageViewModelFactoryFirstParameterAsNameInstanceProvider = multistageViewModelFactoryFirstParameterAsNameInstanceProvider;
}
#region Implementation of IMultiStageViewModelFactoryDefaultInstanceProvider
public IDocumentViewModel GetStageInputViewModel(bool exemptedVehicle)
{
return _multiStageVmFactoryDefaultInstanceProvider.GetStageInputViewModel(exemptedVehicle);
}
public IViewModelBase GetNewMultistageJobViewModel()
{
return _multiStageVmFactoryDefaultInstanceProvider.GetNewMultistageJobViewModel();
......@@ -69,9 +79,9 @@ namespace VECTO3GUI2020.Ninject
return _multiStageVmFactoryDefaultInstanceProvider.GetAuxiliariesViewModel(consolidatedAuxiliariesInputData);
}
public ICreateVifViewModel GetCreateVifViewModel()
public ICreateVifViewModel GetCreateNewVifViewModel()
{
return _multiStageVmFactoryDefaultInstanceProvider.GetCreateVifViewModel();
return _multiStageVmFactoryDefaultInstanceProvider.GetCreateNewVifViewModel();
}
#endregion
......@@ -80,12 +90,22 @@ namespace VECTO3GUI2020.Ninject
public IDocumentViewModel CreateDocumentViewModel(IDeclarationInputDataProvider inputData)
{
return _multiStageViewModelFactoryImplementation.CreateDocumentViewModel(inputData);
return _multiStageViewModelFactoryTypeAsNameInstanceProvider.CreateDocumentViewModel(inputData);
}
public IVehicleViewModel CreateStageInputVehicleViewModel(IVehicleDeclarationInputData inputData)
{
return _multiStageViewModelFactoryImplementation.CreateStageInputVehicleViewModel(inputData);
return _multiStageViewModelFactoryTypeAsNameInstanceProvider.CreateStageInputVehicleViewModel(inputData);
}
#endregion
#region Implementation of IMultistageViewModelFactoryFirstParameterAsNameInstanceProvider
public IVehicleViewModel CreateStageInputVehicleViewModel(string inputProviderType)
{
return _multistageViewModelFactoryFirstParameterAsNameInstanceProvider.CreateStageInputVehicleViewModel(inputProviderType);
}
#endregion
......
......@@ -45,14 +45,15 @@ namespace VECTO3GUI2020.Ninject
Bind<IMultistageDependencies>().To<MultistageLazyDependencies>();
Bind<ICreateVifViewModel>().To<CreateVifViewModel>().
NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetCreateVifViewModel());
NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetCreateNewVifViewModel());
Bind<IDocumentViewModel>().To<StageInputViewModel>()
.Named(typeof(XMLDeclarationInputDataProviderV20).ToString());
Bind<IDocumentViewModel>().To<StageInputViewModel>()
.NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetStageInputViewModel(default(bool)));
Bind<IDocumentViewModel>().To<StageInputViewModel>()
.Named(typeof(XMLDeclarationInputDataProviderV20).ToString());
}
}
......
......@@ -155,6 +155,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Behaviours\AutoScrollDataGridBehaviour.cs" />
<Compile Include="Behaviours\PopUpHorizontalAlignmentBehavior.cs" />
<Compile Include="Helper\ConvertedSIDummyCreator.cs" />
<Compile Include="Helper\Converter\AlwaysVisibleConverter.cs" />
<Compile Include="Helper\Converter\BoolToVisibilityConverter.cs" />
......@@ -329,7 +330,7 @@
<Compile Include="ViewModel\MultiStage\Implementation\StageInputViewModel.cs" />
<Compile Include="ViewModel\MultiStage\Implementation\StageViewModelBase.cs" />
<Compile Include="ViewModel\MultiStage\Interfaces\IMultistageAirdragViewModel.cs" />
<Compile Include="ViewModel\MultiStage\Interfaces\IMultiStageViewModelFactoryDefaultInstanceProvider.cs" />
<Compile Include="ViewModel\MultiStage\Interfaces\IMultiStageViewModelFactory.cs" />
<Compile Include="ViewModel\Implementation\OutputViewModel.cs" />
<Compile Include="Views\AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
......
......@@ -203,6 +203,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation
#endregion
private bool _newFilePopUpIsOpen = false;
public bool NewFilePopUpIsOpen
{
get => _newFilePopUpIsOpen;
set => SetProperty(ref _newFilePopUpIsOpen, value);
}
#region Simulation
......@@ -604,6 +612,19 @@ namespace VECTO3GUI2020.ViewModel.Implementation
private IAsyncRelayCommand _simulationCommand;
private IRelayCommand _newVifCommand;
private ICommand _newMultiStageFileCommand;
private ICommand _openNewFilePopUpCommand;
private ICommand _newCompletedInputCommand;
private ICommand _newExemptedCompletedInputCommand;
public ICommand OpenPopUpCommand
{
get => _openNewFilePopUpCommand ??
(_openNewFilePopUpCommand = new RelayCommand(() => {
NewFilePopUpIsOpen = true;
}));
}
public ICommand CancelSimulation
......@@ -621,12 +642,32 @@ namespace VECTO3GUI2020.ViewModel.Implementation
}
}
public ICommand NewCompletedInputCommand
{
get
{
return _newCompletedInputCommand ?? (_newCompletedInputCommand = new RelayCommand(() => {
_windowHelper.ShowWindow(_multiStageViewModelFactory.GetStageInputViewModel(false));
}));
}
}
public ICommand NewExemptedCompletedInputCommand
{
get
{
return _newExemptedCompletedInputCommand ?? (_newExemptedCompletedInputCommand = new RelayCommand(() => {
_windowHelper.ShowWindow(_multiStageViewModelFactory.GetStageInputViewModel(true));
}));
}
}
public IRelayCommand NewVifCommand
{
get
{
return _newVifCommand ?? (_newVifCommand = new Microsoft.Toolkit.Mvvm.Input.RelayCommand(() => {
_windowHelper.ShowWindow(_multiStageViewModelFactory.GetCreateVifViewModel());
_windowHelper.ShowWindow(_multiStageViewModelFactory.GetCreateNewVifViewModel());
}));
}
}
......@@ -642,7 +683,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
public ICommand NewManufacturingStageFile
public ICommand NewManufacturingStageFileCommand
{
get
{
......
......@@ -132,7 +132,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
#region newMultiStage
public ICommand NewInterimFile => _jobListVm.NewManufacturingStageFile;
public ICommand NewInterimFile => _jobListVm.NewManufacturingStageFileCommand;
......
......@@ -9,7 +9,7 @@ namespace VECTO3GUI2020.ViewModel.Interfaces
public interface IJobListViewModel : IMainViewModel
{
ObservableCollection<IDocumentViewModel> Jobs { get; }
ICommand NewManufacturingStageFile { get; }
ICommand NewManufacturingStageFileCommand { get; }
Task<IDocumentViewModel> AddJobAsync(string fileName);
}
}
......@@ -84,9 +84,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
public class InterimStageBusVehicleViewModel_v2_8 : ViewModelBase, IMultistageVehicleViewModel,
IVehicleComponentsDeclaration, IAdvancedDriverAssistantSystemDeclarationInputData, IDataErrorInfo
{
public static readonly Type INPUTPROVIDERTYPE = typeof(XMLDeclarationInterimStageBusDataProviderV28);
public static readonly Type INPUTPROVIDERTYPEEXEMPTED = typeof(XMLDeclarationExemptedInterimStageBusDataProviderV28);
public static string VERSION = INPUTPROVIDERTYPE.ToString();
public static string VERSION_EXEMPTED = INPUTPROVIDERTYPEEXEMPTED.ToString();
public static string VERSION = typeof(XMLDeclarationInterimStageBusDataProviderV28).ToString();
public static string VERSION_EXEMPTED = typeof(XMLDeclarationExemptedInterimStageBusDataProviderV28).ToString();
private readonly IMultiStageViewModelFactory _multiStageViewModelFactory;
......@@ -125,8 +127,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
#endregion
public static readonly string INPUTPROVIDERTYPE =
typeof(XMLDeclarationInterimStageBusDataProviderV28).ToString();
public string Name => "Vehicle";
......@@ -163,26 +164,28 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
}
}
public InterimStageBusVehicleViewModel_v2_8(IVehicleDeclarationInputData inputData, IMultiStageViewModelFactory multistageViewModelFactory)
public InterimStageBusVehicleViewModel_v2_8(string inputProviderType, IMultiStageViewModelFactory multiStageViewModelFactory)
{
if (inputData.GetType().ToString() == VERSION_EXEMPTED) {
if (inputProviderType == VERSION_EXEMPTED)
{
_exemptedVehicle = true;
Debug.Assert(inputData.ExemptedVehicle);
}
_multiStageViewModelFactory = multistageViewModelFactory;
_multiStageViewModelFactory = multiStageViewModelFactory;
if (!_exemptedVehicle) {
if (!_exemptedVehicle)
{
MultistageAirdragViewModel = _multiStageViewModelFactory.GetMultistageAirdragViewModel();
MultistageAuxiliariesViewModel = _multiStageViewModelFactory.GetAuxiliariesViewModel();
}
CreateParameterViewModels();
SetVehicleInputData(inputData);
ShowConsolidatedData = false;
}
public InterimStageBusVehicleViewModel_v2_8(IVehicleDeclarationInputData inputData, IMultiStageViewModelFactory multiStageViewModelFactory) :
this(inputData.GetType().ToString(), multiStageViewModelFactory)
{
SetVehicleInputData(inputData);
}
public InterimStageBusVehicleViewModel_v2_8(IVehicleDeclarationInputData consolidatedVehicleData,
......
using System.IO;
using System.Diagnostics;
using System.IO;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Utils;
......@@ -21,11 +22,21 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
private readonly string _documentName;
private bool _selected;
public StageInputViewModel(bool exemptedVehicle, IMultiStageViewModelFactory multiStageViewModelFactory) : base(multiStageViewModelFactory)
{
_vehicleViewModel = _viewModelFactory.CreateStageInputVehicleViewModel(
exemptedVehicle
? InterimStageBusVehicleViewModel_v2_8.VERSION_EXEMPTED
: InterimStageBusVehicleViewModel_v2_8.VERSION) as IMultistageVehicleViewModel;
Debug.Assert(_vehicleViewModel != null);
Init();
}
public StageInputViewModel(IDeclarationInputDataProvider inputData, IMultiStageViewModelFactory multiStageViewModelFactory) : base(multiStageViewModelFactory)
{
_documentName = inputData.JobInputData.JobName;
_viewModelFactory = multiStageViewModelFactory;
_vehicleViewModel =
_viewModelFactory.CreateStageInputVehicleViewModel(inputData.JobInputData.Vehicle) as IMultistageVehicleViewModel;
(_vehicleViewModel as InterimStageBusVehicleViewModel_v2_8).ShowConsolidatedData = false;
......@@ -33,6 +44,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
_documentType = XmlDocumentType.DeclarationJobData;
Title = $"Edit Stage Input - {Path.GetFileNameWithoutExtension(_dataSource.SourceFile)}";
Init();
}
private void Init()
{
Components.Add("vehicle", VehicleViewModel as IViewModelBase);
Components.Add("auxiliaries", VehicleViewModel.MultistageAuxiliariesViewModel as IViewModelBase);
Components.Add("airdrag", VehicleViewModel.MultistageAirdragViewModel as IViewModelBase);
......
......@@ -15,7 +15,10 @@ using VECTO3GUI2020.ViewModel.MultiStage.Implementation;
namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces
{
public interface IMultiStageViewModelFactory : IMultiStageViewModelFactoryDefaultInstanceProvider, IMultiStageViewModelFactoryTypeAsNameInstanceProvider
public interface IMultiStageViewModelFactory :
IMultiStageViewModelFactoryDefaultInstanceProvider,
IMultiStageViewModelFactoryTypeAsNameInstanceProvider,
IMultistageViewModelFactoryFirstParameterAsNameInstanceProvider
{
}
......@@ -27,10 +30,16 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces
IVehicleViewModel CreateStageInputVehicleViewModel(IVehicleDeclarationInputData inputData);
}
public interface IMultistageViewModelFactoryFirstParameterAsNameInstanceProvider
{
IVehicleViewModel CreateStageInputVehicleViewModel(string inputProviderType);
}
public interface IMultiStageViewModelFactoryDefaultInstanceProvider
{
IDocumentViewModel GetStageInputViewModel(bool exemptedVehicle);
IViewModelBase GetNewMultistageJobViewModel();
IMultiStageJobViewModel GetMultiStageJobViewModel(IMultistageBusInputDataProvider inputData);
......@@ -49,7 +58,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces
IMultistageAuxiliariesViewModel GetAuxiliariesViewModel(
IBusAuxiliariesDeclarationData consolidatedAuxiliariesInputData);
ICreateVifViewModel GetCreateVifViewModel();
ICreateVifViewModel GetCreateNewVifViewModel();
//IViewModelBase CreateNewMultiStageJobViewModel();
......
......@@ -106,21 +106,40 @@
<Button x:Name="button3" Margin="4" HorizontalAlignment="Stretch"
Style="{StaticResource MultiStageButtonStyle1}"
Command="{Binding AddJobAsyncCommand, IsAsync=True}" Background="#FFDDDDDD">
Add Job</Button>
Load File</Button>
<Button x:Name="button4" Margin ="4" HorizontalAlignment="Stretch"
Style="{StaticResource MultiStageButtonStyle1}"
Command="{Binding EditDocument}"
CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Edit Job</Button>
<Button x:Name="button5" Margin="4" HorizontalAlignment="Stretch"
<Button x:Name="newFileButton" Margin="4" HorizontalAlignment="Stretch"
Style="{StaticResource MultiStageButtonStyle1}"
Command="{Binding NewManufacturingStageFile}">New Multistage Job</Button>
<Button Margin="4" HorizontalAlignment="Stretch"
Style="{StaticResource MultiStageButtonStyle1}"
Command="{Binding NewVifCommand}">Create VIF</Button>
Command="{Binding OpenPopUpCommand}">New File</Button>
<Popup HorizontalAlignment="Center"
x:Name="newFilePopup"
PlacementTarget="{Binding ElementName=newFileButton, Path=.}"
Margin="{Binding ElementName=newFileButton, Path=Margin}"
MinWidth="{Binding ElementName=newFileButton, Path=ActualWidth}"
IsOpen="{Binding NewFilePopUpIsOpen, Mode=TwoWay}"
StaysOpen="False">
<!--<i:Interaction.Behaviors>
<behavior:PopUpHorizontalAlignmentBehavior/>
</i:Interaction.Behaviors>-->
<Border BorderThickness="1px" BorderBrush="{StaticResource AccentColorButton}">
<StackPanel Background="White">
<Button Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding NewManufacturingStageFileCommand}">New Manufacturing Stage</Button>
<Button Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding NewVifCommand}">New VIF</Button>
<Button Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding NewCompletedInputCommand}">New Completed Input</Button>
<Button Style="{StaticResource MultiStageButtonStyle1}" Command="{Binding NewExemptedCompletedInputCommand}">New Exempted Completed Input</Button>
</StackPanel>
</Border>
</Popup>
<Button x:Name="button6" Margin="4" HorizontalAlignment="Stretch"
Style="{StaticResource MultiStageButtonStyle1}"
Command="{Binding RemoveJob, IsAsync=True}"
CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Remove Job</Button>
</StackPanel>
</Border>
</Grid>
......
......@@ -3,7 +3,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using VECTO3GUI2020.ViewModel.Implementation;
using VECTO3GUI2020.ViewModel.Interfaces;
namespace VECTO3GUI2020.Views
{
......
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