diff --git a/VECTO3GUI2020/Ninject/MultistageModule.cs b/VECTO3GUI2020/Ninject/MultistageModule.cs index 2037ace01228a9de8c2ab60bd99f5fb89b22e5e7..b36625f535680ca5786c22f3295f9414334c7fe2 100644 --- a/VECTO3GUI2020/Ninject/MultistageModule.cs +++ b/VECTO3GUI2020/Ninject/MultistageModule.cs @@ -8,6 +8,7 @@ using Ninject.Extensions.Factory; using Ninject.Modules; using TUGraz.VectoCore.Models.SimulationComponent; using VECTO3GUI2020.Ninject.Util; +using VECTO3GUI2020.ViewModel.Implementation; using VECTO3GUI2020.ViewModel.Interfaces.Common; using VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle; using VECTO3GUI2020.ViewModel.MultiStage.Implementation; @@ -39,6 +40,9 @@ namespace VECTO3GUI2020.Ninject NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetAuxiliariesViewModel(null)); Bind<IMultistageDependencies>().To<MultistageLazyDependencies>(); + + Bind<ICreateVifViewModel>().To<CreateVifViewModel>(). + NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetCreateVifViewModel()); } } } diff --git a/VECTO3GUI2020/Resources/ViewModelBindings.xaml b/VECTO3GUI2020/Resources/ViewModelBindings.xaml index cec55212745831db57222664144969ca8ead0e11..c6fffd8363fe677d167f8462d2d7494a329f9ac1 100644 --- a/VECTO3GUI2020/Resources/ViewModelBindings.xaml +++ b/VECTO3GUI2020/Resources/ViewModelBindings.xaml @@ -227,10 +227,16 @@ <DataTemplate x:Shared="False" DataType="{x:Type multistageimpl:MultistageAuxiliariesViewModel}"> <multistageviews:ManufacturingStageAuxiliariesView/> </DataTemplate> + + + <DataTemplate DataType="{x:Type impl:CreateVifViewModel}"> + <multistageviews:CreateVifView></multistageviews:CreateVifView> + </DataTemplate> <!--#endregion--> <DataTemplate DataType="{x:Type local:TestViewModel}"> <local:Test></local:Test> </DataTemplate> + </ResourceDictionary> \ No newline at end of file diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index 1d81fd210b8a7d0cab2550d89d4b6313ad5d190c..fd0b9695e3262611c2880b3e1cbed9b19e917af2 100644 --- a/VECTO3GUI2020/VECTO3GUI2020.csproj +++ b/VECTO3GUI2020/VECTO3GUI2020.csproj @@ -210,6 +210,7 @@ <Compile Include="Util\XML\Implementation\ComponentWriter\XMLBusAuxiliariesWriter.cs" /> <Compile Include="Util\XML\Implementation\ComponentWriter\XMLPTOWriter.cs" /> <Compile Include="ViewModel\Implementation\AboutViewModel.cs" /> + <Compile Include="ViewModel\Implementation\CreateVifViewModel.cs" /> <Compile Include="ViewModel\Implementation\Document\DeclarationJobViewModel.cs" /> <Compile Include="ViewModel\Implementation\Document\DeclarationTrailerJobDocumentViewModel.cs" /> <Compile Include="Model\Interfaces\IAuxiliaryModelFactory.cs" /> @@ -422,6 +423,9 @@ <Compile Include="Views\Multistage\AirDragView_v2_8.xaml.cs"> <DependentUpon>AirDragView_v2_8.xaml</DependentUpon> </Compile> + <Compile Include="Views\Multistage\CreateVifView.xaml.cs"> + <DependentUpon>CreateVifView.xaml</DependentUpon> + </Compile> <Compile Include="Views\Multistage\CustomControls\FilePicker.xaml.cs"> <DependentUpon>FilePicker.xaml</DependentUpon> </Compile> @@ -676,6 +680,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\Multistage\CreateVifView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\Multistage\CustomControls\FilePicker.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..dcb781f6349a70a5f3ab21b60724c054f73b2b0c --- /dev/null +++ b/VECTO3GUI2020/ViewModel/Implementation/CreateVifViewModel.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using Microsoft.Toolkit.Mvvm.Input; +using TUGraz.VectoCore.InputData.FileIO.XML; +using TUGraz.VectoCore.Utils; +using VECTO3GUI2020.Helper; +using VECTO3GUI2020.ViewModel.Implementation.Common; + +namespace VECTO3GUI2020.ViewModel.Implementation +{ + public interface ICreateVifViewModel + { + + } + public class CreateVifViewModel : ViewModelBase, ICreateVifViewModel + { + private string _primaryInputFile; + private string _completedInputFile; + private readonly IDialogHelper _dialogHelper; + private readonly IXMLInputDataReader _inputDataReader; + + + public CreateVifViewModel(IDialogHelper dialogHelper, IXMLInputDataReader inputDataReader) + { + _dialogHelper = dialogHelper; + _inputDataReader = inputDataReader; + } + + + public string PrimaryInputFile + { + get => _primaryInputFile; + set => SetProperty(ref _primaryInputFile, value); + } + + public string CompletedInputFile + { + get => _completedInputFile; + set => SetProperty(ref _completedInputFile, value); + } + + public ICommand SelectCompletedInputFileCommand + { + get => _selectCompletedInputFileCommand ?? (_selectCompletedInputFileCommand = new RelayCommand(() => { + var selectedFile = _dialogHelper.OpenXMLFileDialog(); + + })); + } + + public ICommand SelectPrimaryInputFileCommand + { + get => _selectPrimaryInputFileCommand ?? (_selectPrimaryInputFileCommand = new RelayCommand(() => { + PrimaryInputFile = _dialogHelper.OpenXMLFileDialog(); + + })); + } + + + public bool CheckDocumentType(string fileName, XmlDocumentType expectedDocumentType) + { + var xElement = new System.Xml.XmlDocument(); + xElement.Load(fileName); + + var documentType = XMLHelper.GetDocumentType(xElement?.DocumentElement?.LocalName); + return documentType.HasValue && documentType.Value == expectedDocumentType; + } + + + #region Commands + + private ICommand _selectPrimaryInputFileCommand; + private ICommand _selectCompletedInputFileCommand; + + + #endregion + + + + + } +} diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index e95d495646b5e9312cb6c573470d4e0194c64f2c..b9e13ea4ed07f17d3904bbc80c92b94d3a4182ce 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -82,15 +82,16 @@ namespace VECTO3GUI2020.ViewModel.Implementation } + private IDialogHelper _dialogHelper; private IWindowHelper _windowHelper; private IDocumentViewModelFactory _documentViewModelFactory; - private ICommand _newMultiStageFileCommand; + private IMultiStageViewModelFactory _multiStageViewModelFactory; private readonly IXMLInputDataReader _inputDataReader; private IOutputViewModel _outputViewModel; - private IAsyncRelayCommand _addJobAsync; - private IAsyncRelayCommand _simulationCommand; + + private readonly string StoredJobsFileName = "storedJobs.json"; @@ -144,6 +145,21 @@ namespace VECTO3GUI2020.ViewModel.Implementation } + private void LogMethod(LogEventInfo evtInfo, object[] objects) + { + if (!SimulationRunning) + { + return; + } + if (evtInfo.Level == LogLevel.Error || evtInfo.Level == LogLevel.Warn || evtInfo.Level == LogLevel.Fatal) + _outputMessage.Report(new MessageEntry() + { + Type = MessageType.ErrorMessage, + Message = evtInfo.FormattedMessage, + Source = evtInfo.CallerMemberName, + }); + } + #region Store and Restore JobList private void LoadFiles() { @@ -179,31 +195,15 @@ namespace VECTO3GUI2020.ViewModel.Implementation private void SaveFileNamesToFile() { - var filesToStore = Jobs.Select(job => job.DataSource.SourceFile).ToList(); string jsonString = JsonConvert.SerializeObject(filesToStore); Debug.WriteLine(jsonString); File.WriteAllText(StoredJobsFileName, jsonString); - } - - - #endregion - private void LogMethod(LogEventInfo evtInfo, object[] objects) - { - if (!SimulationRunning) { - return; - } - if(evtInfo.Level == LogLevel.Error || evtInfo.Level == LogLevel.Warn || evtInfo.Level == LogLevel.Fatal) - _outputMessage.Report(new MessageEntry() { - Type = MessageType.ErrorMessage, - Message = evtInfo.FormattedMessage, - Source = evtInfo.CallerMemberName, - }); - } + #region Simulation private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); @@ -600,6 +600,10 @@ namespace VECTO3GUI2020.ViewModel.Implementation private ICommand _moveJobDownCommand; private ICommand _viewXMLCommand; private IDocumentViewModel _selectedJob; + private IAsyncRelayCommand _addJobAsync; + private IAsyncRelayCommand _simulationCommand; + private IRelayCommand _newVifCommand; + private ICommand _newMultiStageFileCommand; public ICommand CancelSimulation { @@ -616,6 +620,16 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } + public IRelayCommand NewVifCommand + { + get + { + return _newVifCommand ?? (_newVifCommand = new Microsoft.Toolkit.Mvvm.Input.RelayCommand(() => { + _windowHelper.ShowWindow(_multiStageViewModelFactory.GetCreateVifViewModel()); + })); + } + } + public IAsyncRelayCommand SimulationCommand { @@ -861,30 +875,4 @@ namespace VECTO3GUI2020.ViewModel.Implementation #endregion Commands } - - - - - - public class VectoSimulationProgress - { - public enum MsgType - { - StatusMessage, - InfoMessage, - Progress, - LogError, - LogWarning, - - } - - public string Message { get; set; } - - public MsgType Type { get; set; } - - public string Link { get; set; } - } - - - } diff --git a/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs b/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs index 60b6f9edecc3c4896fe5312feb8b61675b6a5afb..80b5bb4dde4e812c895e3a637f3afe95f220a426 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs @@ -9,10 +9,8 @@ namespace VECTO3GUI2020.ViewModel.Interfaces.Document string DocumentName { get; } XmlDocumentType DocumentType { get; } DataSource DataSource { get; } - - IEditViewModel EditViewModel { get; } + IEditViewModel EditViewModel { get; } bool Selected { get; set; } - - bool CanBeEdited { get; set; } + bool CanBeEdited { get; set; } } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs b/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs index 53174738cfb7d13085c8206e2167e1e9bbea8d41..74c0486bacd9a7b3efa897f92f3c4a9b49b112bd 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCore.Utils; +using VECTO3GUI2020.ViewModel.Implementation; using VECTO3GUI2020.ViewModel.Interfaces.Common; using VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle; using VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle.Components; @@ -25,11 +26,14 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces IManufacturingStageViewModel GetManufacturingStageViewModel(IManufacturingStageInputData consolidatedManufacturingStageInputData, bool exempted); IMultistageAirdragViewModel GetMultistageAirdragViewModel(); + IMultistageAirdragViewModel GetMultistageAirdragViewModel( IAirdragDeclarationInputData consolidatedAirdragInputData); IMultistageAuxiliariesViewModel GetAuxiliariesViewModel( IBusAuxiliariesDeclarationData consolidatedAuxiliariesInputData); + + ICreateVifViewModel GetCreateVifViewModel(); //IViewModelBase CreateNewMultiStageJobViewModel(); //IMultiStageJobViewModel CreateMultiStageJobViewModel(string inputProviderType, IMultistageBusInputDataProvider inputData); diff --git a/VECTO3GUI2020/Views/JoblistView.xaml b/VECTO3GUI2020/Views/JoblistView.xaml index 0ae1e63964ca23a3c37690e66c2a5b1fbd46c45d..e6d10d24a5d240855bd73c3f20841c765b6d6969 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml +++ b/VECTO3GUI2020/Views/JoblistView.xaml @@ -56,7 +56,6 @@ BorderBrush ="{StaticResource AccentColorButton}" BorderThickness="1 0 1 1" Name="JobDataGrid" HorizontalAlignment="Stretch" - CanUserReorderColumns="False" AutoGenerateColumns="False" SelectionMode="Single" @@ -69,7 +68,6 @@ AllowDrop="True" Drop="JobDataGrid_OnDrop" PreviewDrop = "JobDataGrid_OnPreviewDrop" ColumnHeaderStyle="{StaticResource JobListDataGridHeaderStyle}" - RowHeight="30" AlternatingRowBackground="LightGray" CellStyle="{DynamicResource DataGridCellStyle1}" SelectedItem = "{Binding SelectedJob}" @@ -106,20 +104,23 @@ <Border BorderBrush="Transparent" BorderThickness="1"> <StackPanel > <Button x:Name="button3" Margin="4" HorizontalAlignment="Stretch" - Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding AddJobAsyncCommand, IsAsync=True}" Background="#FFDDDDDD"> - Add Job</Button> + Style="{StaticResource MultiStageButtonStyle1}" + Command="{Binding AddJobAsyncCommand, IsAsync=True}" Background="#FFDDDDDD"> + Add Job</Button> <Button x:Name="button4" Margin ="4" HorizontalAlignment="Stretch" - Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding EditJob}" - CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Edit Job</Button> + Style="{StaticResource MultiStageButtonStyle1}" + Command="{Binding EditJob}" + CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Edit Job</Button> <Button x:Name="button5" Margin="4" HorizontalAlignment="Stretch" - Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding NewManufacturingStageFile}" AutomationProperties.AutomationId="JobListViewNewManufacturingStageFileButton">New Multistage Job</Button> + Style="{StaticResource MultiStageButtonStyle1}" + Command="{Binding NewManufacturingStageFile}">New Multistage Job</Button> + <Button Margin="4" HorizontalAlignment="Stretch" + Style="{StaticResource MultiStageButtonStyle1}" + Command="{Binding NewVifCommand}">Create VIF</Button> <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> + Style="{StaticResource MultiStageButtonStyle1}" + Command="{Binding RemoveJob, IsAsync=True}" + CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Remove Job</Button> </StackPanel> </Border> </Grid> diff --git a/VECTO3GUI2020/Views/Multistage/CreateVifView.xaml b/VECTO3GUI2020/Views/Multistage/CreateVifView.xaml new file mode 100644 index 0000000000000000000000000000000000000000..8713f82b0937122af50a9cc2044fb11eb3911b8b --- /dev/null +++ b/VECTO3GUI2020/Views/Multistage/CreateVifView.xaml @@ -0,0 +1,23 @@ +<UserControl x:Class="VECTO3GUI2020.Views.Multistage.CreateVifView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:VECTO3GUI2020.Views.Multistage" + xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" + xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.Implementation" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance implementation:CreateVifViewModel}"> + <Grid> + <StackPanel> + <Label Style="{DynamicResource LabelStyle1}">Select Primary Input</Label> + <customControls:FilePicker + Text="{Binding PrimaryInputFile}" + Command="{Binding SelectPrimaryInputFileCommand}"></customControls:FilePicker> + <Label Style="{DynamicResource LabelStyle1}">Select Stage Input</Label> + <customControls:FilePicker + Text="{Binding CompletedInputFile}" + Command="{Binding SelectCompletedInputFileCommand}"></customControls:FilePicker> + </StackPanel> + </Grid> +</UserControl> diff --git a/VECTO3GUI2020/Views/Multistage/CreateVifView.xaml.cs b/VECTO3GUI2020/Views/Multistage/CreateVifView.xaml.cs new file mode 100644 index 0000000000000000000000000000000000000000..70b55ddc961fa68e8de09e251524b3b7c550090e --- /dev/null +++ b/VECTO3GUI2020/Views/Multistage/CreateVifView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace VECTO3GUI2020.Views.Multistage +{ + /// <summary> + /// Interaction logic for CreateVifView.xaml + /// </summary> + public partial class CreateVifView : UserControl + { + public CreateVifView() + { + InitializeComponent(); + } + } +}