diff --git a/VECTO3GUI2020/App.xaml b/VECTO3GUI2020/App.xaml index 817f5f0b1b06102dfd0be81a55b244696f9a79d1..56139706be5acb5aeb5c30b9ae093a5ea401f81b 100644 --- a/VECTO3GUI2020/App.xaml +++ b/VECTO3GUI2020/App.xaml @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:VECTO3GUI2020" - ShutdownMode="OnMainWindowClose"> + ShutdownMode="OnMainWindowClose" + > <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> @@ -17,7 +18,8 @@ <ResourceDictionary Source="DataGridStyles.xaml"/> <ResourceDictionary Source="Resources/Templates/ErrorTemplates.xaml"/> <ResourceDictionary Source="Resources/ObjectProvider.xaml"/> - <ResourceDictionary Source="Resources/Icons/drawables.xaml"></ResourceDictionary> + <ResourceDictionary Source="Resources/Icons/drawables.xaml"/> + <ResourceDictionary Source="Resources/DataTemplateSelectors.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> diff --git a/VECTO3GUI2020/Helper/MultistageParameterDataTemplateSelector.cs b/VECTO3GUI2020/Helper/TemplateSelector/MultistageParameterDataTemplateSelector.cs similarity index 96% rename from VECTO3GUI2020/Helper/MultistageParameterDataTemplateSelector.cs rename to VECTO3GUI2020/Helper/TemplateSelector/MultistageParameterDataTemplateSelector.cs index 74a73b23bee97dada9d9e9a539a7fd19e34e380b..d0adf397526cf705b21e7122bcde6d0824a20206 100644 --- a/VECTO3GUI2020/Helper/MultistageParameterDataTemplateSelector.cs +++ b/VECTO3GUI2020/Helper/TemplateSelector/MultistageParameterDataTemplateSelector.cs @@ -4,7 +4,7 @@ using System.Windows.Controls; using TUGraz.VectoCommon.Exceptions; using VECTO3GUI2020.Views.Multistage.CustomControls; -namespace VECTO3GUI2020.Helper +namespace VECTO3GUI2020.Helper.TemplateSelector { public class MultistageParameterDataTemplateSelector : DataTemplateSelector { diff --git a/VECTO3GUI2020/Helper/TemplateSelector/MultistageVehicleDataTemplateSelector.cs b/VECTO3GUI2020/Helper/TemplateSelector/MultistageVehicleDataTemplateSelector.cs new file mode 100644 index 0000000000000000000000000000000000000000..648db0e189bd5dfe5a013b480cfe1b562433da72 --- /dev/null +++ b/VECTO3GUI2020/Helper/TemplateSelector/MultistageVehicleDataTemplateSelector.cs @@ -0,0 +1,53 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using TUGraz.VectoCommon.Exceptions; +using VECTO3GUI2020.ViewModel.Interfaces.JobEdit.Vehicle; +using VECTO3GUI2020.ViewModel.MultiStage.Implementation; +using VECTO3GUI2020.Views.Multistage; +using VECTO3GUI2020.Views.Multistage.CustomControls; + +namespace VECTO3GUI2020.Helper.TemplateSelector +{ + public class MultistageVehicleDataTemplateSelector : DataTemplateSelector + { + + /// <summary> + /// Selects a vehicle viewmodel based on the ExemptedVehicleProperty + /// </summary> + /// <param name="item"></param> + /// <param name="container"></param> + /// <returns></returns> + public override DataTemplate SelectTemplate(object item, DependencyObject container) + { + FrameworkElement element = container as FrameworkElement; + IVehicleViewModel vm = item as IVehicleViewModel; + + if (element != null && item != null && vm != null) + { + FrameworkElementFactory factory = null; + Type type = null; + + switch (vm) { + case DeclarationInterimStageBusVehicleViewModel_v2_8 declvm: + if (declvm.ExemptedVehicle) { + type = typeof(VehicleView_v2_8_exempted); + } else { + type = typeof(VehicleView_v2_8); + } + + break; + default: + throw new NotImplementedException($"no template defined for {vm.GetType()}"); + } + + factory = new FrameworkElementFactory(type); + DataTemplate dt = new DataTemplate(); + dt.VisualTree = factory; + return dt; + } + + return base.SelectTemplate(item, container); + } + } +} \ No newline at end of file diff --git a/VECTO3GUI2020/Ninject/MultistageModule.cs b/VECTO3GUI2020/Ninject/MultistageModule.cs index c36e13772ffe0bc172f7b9eb92b7bbd1cc8c750b..2037ace01228a9de8c2ab60bd99f5fb89b22e5e7 100644 --- a/VECTO3GUI2020/Ninject/MultistageModule.cs +++ b/VECTO3GUI2020/Ninject/MultistageModule.cs @@ -30,7 +30,7 @@ namespace VECTO3GUI2020.Ninject NamedLikeFactoryMethod((IMultiStageViewModelFactory f)=>f.GetInterimStageVehicleViewModel()); Bind<IManufacturingStageViewModel>().To<ManufacturingStageViewModel_v0_1>(). - NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetManufacturingStageViewModel(null)); + NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetManufacturingStageViewModel(null, false)); Bind<IMultistageAirdragViewModel>().To<MultistageAirdragViewModel>(). NamedLikeFactoryMethod((IMultiStageViewModelFactory f) => f.GetMultistageAirdragViewModel()); diff --git a/VECTO3GUI2020/Resources/DataTemplateSelectors.xaml b/VECTO3GUI2020/Resources/DataTemplateSelectors.xaml new file mode 100644 index 0000000000000000000000000000000000000000..acb9d8062dca35fd8f288c268e975d575814889e --- /dev/null +++ b/VECTO3GUI2020/Resources/DataTemplateSelectors.xaml @@ -0,0 +1,7 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:templateSelector="clr-namespace:VECTO3GUI2020.Helper.TemplateSelector"> + <templateSelector:MultistageParameterDataTemplateSelector x:Key="MultistageParameterTemplateSelector"/> + <templateSelector:MultistageVehicleDataTemplateSelector x:Key="MultistageVehicleDataTemplateSelector"/> + +</ResourceDictionary> \ No newline at end of file diff --git a/VECTO3GUI2020/Resources/Icons/FolderClosed_16x.xaml b/VECTO3GUI2020/Resources/Icons/FolderClosed_16x.xaml new file mode 100644 index 0000000000000000000000000000000000000000..3d162d6e29001f1317a402e6c40d19258bb411f6 --- /dev/null +++ b/VECTO3GUI2020/Resources/Icons/FolderClosed_16x.xaml @@ -0,0 +1,20 @@ +<!-- This file was generated by the AiToXaml tool.--> +<!-- Tool Version: 14.0.22307.0 --> +<Viewbox Width="16" Height="16" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <Rectangle Width="16" Height="16"> + <Rectangle.Fill> + <DrawingBrush> + <DrawingBrush.Drawing> + <DrawingGroup> + <DrawingGroup.Children> + <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M0,0L16,0 16,16 0,16z" /> + <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M1.5,1L9.61,1 10.61,3 13.496,3C14.323,3,14.996,3.673,14.996,4.5L14.996,12.5C14.996,13.327,14.323,14,13.496,14L1.5,14C0.673,14,0,13.327,0,12.5L0,2.5C0,1.673,0.673,1,1.5,1" /> + <GeometryDrawing Brush="#FFEFEFF0" Geometry="F1M1.9998,3.0004L1.9998,4.0004 8.8738,4.0004 8.3738,3.0004z" /> + <GeometryDrawing Brush="#FFDBB679" Geometry="F1M2,3L8.374,3 8.874,4 2,4z M13.496,4L10,4 9.992,4 8.992,2 1.5,2C1.225,2,1,2.224,1,2.5L1,12.5C1,12.776,1.225,13,1.5,13L13.496,13C13.773,13,13.996,12.776,13.996,12.5L13.996,4.5C13.996,4.224,13.773,4,13.496,4" /> + </DrawingGroup.Children> + </DrawingGroup> + </DrawingBrush.Drawing> + </DrawingBrush> + </Rectangle.Fill> + </Rectangle> +</Viewbox> \ No newline at end of file diff --git a/VECTO3GUI2020/Resources/Icons/drawables.xaml b/VECTO3GUI2020/Resources/Icons/drawables.xaml index 2d2c760217db5d9d2b2519a774f34d0e9c52e469..268ae2eb9978c633093b5f7437951bd85aface0d 100644 --- a/VECTO3GUI2020/Resources/Icons/drawables.xaml +++ b/VECTO3GUI2020/Resources/Icons/drawables.xaml @@ -66,4 +66,24 @@ </Rectangle> </Viewbox> </DataTemplate> + <DataTemplate x:Key="FolderIcon"> + <Viewbox Width="16" Height="16" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <Rectangle Width="16" Height="16"> + <Rectangle.Fill> + <DrawingBrush> + <DrawingBrush.Drawing> + <DrawingGroup> + <DrawingGroup.Children> + <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M0,0L16,0 16,16 0,16z" /> + <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M1.5,1L9.61,1 10.61,3 13.496,3C14.323,3,14.996,3.673,14.996,4.5L14.996,12.5C14.996,13.327,14.323,14,13.496,14L1.5,14C0.673,14,0,13.327,0,12.5L0,2.5C0,1.673,0.673,1,1.5,1" /> + <GeometryDrawing Brush="#FFEFEFF0" Geometry="F1M1.9998,3.0004L1.9998,4.0004 8.8738,4.0004 8.3738,3.0004z" /> + <GeometryDrawing Brush="#FFDBB679" Geometry="F1M2,3L8.374,3 8.874,4 2,4z M13.496,4L10,4 9.992,4 8.992,2 1.5,2C1.225,2,1,2.224,1,2.5L1,12.5C1,12.776,1.225,13,1.5,13L13.496,13C13.773,13,13.996,12.776,13.996,12.5L13.996,4.5C13.996,4.224,13.773,4,13.496,4" /> + </DrawingGroup.Children> + </DrawingGroup> + </DrawingBrush.Drawing> + </DrawingBrush> + </Rectangle.Fill> + </Rectangle> + </Viewbox> + </DataTemplate> </ResourceDictionary> \ No newline at end of file diff --git a/VECTO3GUI2020/Resources/MultistageParameterDataTemplates.xaml b/VECTO3GUI2020/Resources/MultistageParameterDataTemplates.xaml index f3499fc795fdb1f56bf70c50d1759cc676333396..8cfc734c7145572251067ec2c1cc7edb1054dff6 100644 --- a/VECTO3GUI2020/Resources/MultistageParameterDataTemplates.xaml +++ b/VECTO3GUI2020/Resources/MultistageParameterDataTemplates.xaml @@ -1,9 +1,9 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" - xmlns:helper="clr-namespace:VECTO3GUI2020.Helper"> + xmlns:helper="clr-namespace:VECTO3GUI2020.Helper" + xmlns:templateSelector="clr-namespace:VECTO3GUI2020.Helper.TemplateSelector"> - <helper:MultistageParameterDataTemplateSelector x:Key="MultistageParameterTemplateSelector"/> <customControls:MultistageParameterTextView x:Key="MultistageTextBoxView"/> <customControls:MultistageParameterComboBoxView x:Key="MultistageComboBoxView"/> diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index ec9339a4034f6cffd3cb9b58e5d78fce6d6aa8b9..9de0c0a0c3222f03c1903cea8bd101e37be705c4 100644 --- a/VECTO3GUI2020/VECTO3GUI2020.csproj +++ b/VECTO3GUI2020/VECTO3GUI2020.csproj @@ -77,6 +77,9 @@ <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath> </Reference> + <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> <Reference Include="Ninject, Version=3.3.4.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL"> <HintPath>..\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath> </Reference> @@ -170,10 +173,11 @@ <Compile Include="Helper\IndexedStorage.cs" /> <Compile Include="Helper\IWindowHelper.cs" /> <Compile Include="Helper\DialogHelper.cs" /> - <Compile Include="Helper\MultistageParameterDataTemplateSelector.cs" /> + <Compile Include="Helper\TemplateSelector\MultistageParameterDataTemplateSelector.cs" /> <Compile Include="Helper\MultistageParameterViewModel.cs" /> <Compile Include="Helper\NameOfMarkUpExtension.cs" /> <Compile Include="Helper\NameResolver.cs" /> + <Compile Include="Helper\TemplateSelector\MultistageVehicleDataTemplateSelector.cs" /> <Compile Include="Helper\WindowHelper.cs" /> <Compile Include="Helper\XMLExtension.cs" /> <Compile Include="Helper\XmlHelper.cs" /> @@ -444,6 +448,9 @@ <Compile Include="Views\Multistage\VehicleView_v2_8.xaml.cs"> <DependentUpon>VehicleView_v2_8.xaml</DependentUpon> </Compile> + <Compile Include="Views\Multistage\VehicleView_v2_8_exempted.xaml.cs"> + <DependentUpon>VehicleView_v2_8_exempted.xaml</DependentUpon> + </Compile> <Compile Include="Views\OutputView.xaml.cs"> <DependentUpon>OutputView.xaml</DependentUpon> </Compile> @@ -456,6 +463,10 @@ <Page Include="DataGridStyles.xaml"> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Resources\DataTemplateSelectors.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Resources\Icons\AddDocument_16x.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -468,6 +479,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Resources\Icons\FolderClosed_16x.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Resources\Icons\Trash_16x.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -691,6 +706,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\Multistage\VehicleView_v2_8_exempted.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\OutputView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 2f4a614202ba6a4c1c36d162817a27eddcf7b076..79b78d20cdd8a301a819b4559498b3b4749f1f65 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -18,6 +18,7 @@ using System.Xml.Linq; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.WindowsAPICodePack.Shell.Interop; using Microsoft.WindowsAPICodePack.Shell.PropertySystem; +using Newtonsoft.Json; using NLog; using NLog.Targets; using TUGraz.VectoCommon.Exceptions; @@ -59,39 +60,40 @@ namespace VECTO3GUI2020.ViewModel.Implementation private readonly Settings _settings = Settings.Default; - private ICommand _addJobCommand; - private ICommand _editJobCommand; - private ICommand _removeJobCommand; - private ICommand _moveJobUpCommand; - private ICommand _moveJobDownCommand; - private ICommand _viewXMLCommand; - private bool _isLoading = false; - public bool IsLoading - { - get => _isLoading; - set => SetProperty(ref _isLoading, value); - } - private BackgroundWorker fileReadingBackgroundWorker; + private BackgroundWorker fileReadingBackgroundWorker; private object _jobsLock = new Object(); private ObservableCollection<IDocumentViewModel> _jobs = new ObservableCollection<IDocumentViewModel>(); public ObservableCollection<IDocumentViewModel> Jobs{ get => _jobs; set => SetProperty(ref _jobs, value);} - private IDialogHelper _dialogHelper; + public IDocumentViewModel SelectedJob + { + get => _selectedJob; + set + { + if(SetProperty(ref _selectedJob, value)) { + RemoveJob.NotifyCanExecuteChanged(); + }; + + } + } + + + private IDialogHelper _dialogHelper; private IWindowHelper _windowHelper; private IDocumentViewModelFactory _documentViewModelFactory; private ICommand _newMultiStageFileCommand; private IMultiStageViewModelFactory _multiStageViewModelFactory; - private IAsyncRelayCommand _addJobAsync; private readonly IXMLInputDataReader _inputDataReader; - private IAsyncRelayCommand _simulationCommand; private readonly IOutputViewModel _outputViewModel; + private IAsyncRelayCommand _addJobAsync; + private IAsyncRelayCommand _simulationCommand; - - + private readonly string StoredJobsFileName = "storedJobs.json"; + #endregion @@ -101,10 +103,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation public JobListViewModel() { BindingOperations.EnableCollectionSynchronization(Jobs, _jobsLock); - InitFileBackGroundWorker(); - - - } + } public JobListViewModel(IDocumentViewModelFactory documentViewModelFactory, @@ -134,8 +133,52 @@ namespace VECTO3GUI2020.ViewModel.Implementation //configure Nlog var target = new MethodCallTarget("VectoGuiTarget", (evtInfo, obj) => LogMethod(evtInfo, obj)); NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); + + + System.Windows.Application.Current.Exit += new ExitEventHandler(this.OnApplicationExit); + var filesToRead = ReadFileNamesFromFile(); + if (filesToRead != null) { + foreach (var fileName in filesToRead) { + Task.Run(() => AddJobAsync(fileName)); + } + } + } + + #region Store and Restore JobList + private void OnApplicationExit(object sender, EventArgs e) + { + SaveFileNamesToFile(); + } + + + private string[] ReadFileNamesFromFile() + { + try { + var filesJson = File.ReadAllText(StoredJobsFileName); + IList<string> filesToRead = JsonConvert.DeserializeObject<List<string>>(filesJson); + return filesToRead.ToArray(); + } catch (Exception e) { + Debug.WriteLine(e.Message); + } + + return null; } + 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) { @@ -149,24 +192,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation }); } - - - private void InitFileBackGroundWorker() - { - fileReadingBackgroundWorker = new BackgroundWorker - { - WorkerReportsProgress = true - }; - fileReadingBackgroundWorker.DoWork += fileworker_DoWork; - fileReadingBackgroundWorker.ProgressChanged += fileworker_ProgressChanged; - fileReadingBackgroundWorker.RunWorkerCompleted += fileworker_RunWorkerCompleted; - } - - private void fileworker_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - Debug.WriteLine(e.ProgressPercentage); - } - + #region Simulation private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); private bool _simulationRunning = false; @@ -549,8 +575,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation return outFile; } - + #endregion #region Commands + private ICommand _editJobCommand; + private IAsyncRelayCommand _removeJobCommand; + private ICommand _moveJobUpCommand; + private ICommand _moveJobDownCommand; + private ICommand _viewXMLCommand; + private IDocumentViewModel _selectedJob; public ICommand CancelSimulation { @@ -616,7 +648,9 @@ namespace VECTO3GUI2020.ViewModel.Implementation if (fileName != null) { try { var result = await LoadFileAsync(fileName); - Jobs.Add(result); + lock (_jobsLock) { + Jobs.Add(result); + } return result; } catch (Exception e) { var errorString = ""; @@ -655,51 +689,16 @@ namespace VECTO3GUI2020.ViewModel.Implementation } - - public ICommand AddJob - { - get - { - return _addJobCommand ?? new RelayCommand(AddJobExecute, () => { return true; }); - } - private set - { - _addJobCommand = value; - OnPropertyChanged(); - } - } - - - private void AddJobExecute() - { - IsLoading = true; - var filename = _dialogHelper.OpenXMLFileDialog(); - if (filename != null) - { - LoadJob(filename); - } - else - { - IsLoading = false; - } - } - - public void LoadJob([NotNull] string fileName) - { - fileReadingBackgroundWorker.RunWorkerAsync(fileName); - } - - - public ICommand EditJob + public ICommand EditJob { get - { - return _editJobCommand ?? new Util.RelayCommand<IJobViewModel>(EditJobExecute, - (IJobViewModel jobentry) => { + { + return _editJobCommand ?? (_editJobCommand = new Util.RelayCommand<IJobViewModel>(EditJobExecute, + (IJobViewModel jobentry) => { var canExecute = jobentry != null && jobentry.CanBeEdited; - return canExecute; - }); - } + return canExecute; + })); + } set { _editJobCommand = value; @@ -744,14 +743,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation } - public ICommand RemoveJob + public IAsyncRelayCommand RemoveJob { get { - return _removeJobCommand ?? new Util.RelayCommand<IDocumentViewModel>(RemoveJobExecute, (IDocumentViewModel jobentry) => - { - return (jobentry != null); - }); + return _removeJobCommand ?? (_removeJobCommand = new AsyncRelayCommand<IDocumentViewModel>(RemoveJobExecute, + (IDocumentViewModel jobEntry) => { + return (SelectedJob != null); + })); } set { @@ -760,14 +759,28 @@ namespace VECTO3GUI2020.ViewModel.Implementation } } - private void RemoveJobExecute(IDocumentViewModel selectedDocument) - { - if (selectedDocument == null) return; + public void OnJobSelectionChanged() + { + RemoveJob.NotifyCanExecuteChanged(); + } - Jobs.Remove(selectedDocument); + private async Task RemoveJobExecute(IDocumentViewModel selectedDocument) + { + if (selectedDocument == null) { + return; + } + + await Task.Run(() => { + lock (_jobsLock) { + Jobs.Remove(selectedDocument); + } + }); + + OnPropertyChanged(); - } + + } public ICommand moveJobUp { @@ -824,50 +837,10 @@ namespace VECTO3GUI2020.ViewModel.Implementation } #endregion Commands - - #region BackgroundworkerXMLreading - - void fileworker_DoWork(object sender, DoWorkEventArgs e) - { - string filename = e.Argument as string; - Debug.Assert(filename != null); - - try - { - var xElement = new System.Xml.XmlDocument(); - xElement.Load(filename); - - var documentType = XMLHelper.GetDocumentType(xElement?.DocumentElement?.LocalName); - if (documentType == null) - { - Debug.WriteLine("Unknown Document Type"); - e.Cancel = true; - return; - } - - - - - var result = _documentViewModelFactory.CreateDocumentViewModel((XmlDocumentType)documentType, filename); - e.Result = result; - } - catch (Exception) - { - e.Cancel = true; - throw; - } - } + } - void fileworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - Debug.Assert(e.Result is IDocumentViewModel); - Jobs.Add(e.Result as IDocumentViewModel); - IsLoading = false; - } - #endregion - } public class VectoSimulationProgress @@ -889,4 +862,6 @@ namespace VECTO3GUI2020.ViewModel.Implementation public string Link { get; set; } } + + } diff --git a/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs b/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs index 6b09b8717c8fab496c4bae1091a04c2640d9cbce..c9669f027a7d16d8696f9631eee0895c9c489989 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/IJobListViewModel.cs @@ -8,9 +8,7 @@ namespace VECTO3GUI2020.ViewModel.Interfaces { public interface IJobListViewModel : IMainViewModel { - ICommand AddJob { get; } - ICommand EditJob { get; } - ObservableCollection<IDocumentViewModel> Jobs { get; } + ObservableCollection<IDocumentViewModel> Jobs { get; } ICommand NewManufacturingStageFile { get; } Task<IDocumentViewModel> AddJobAsync(string fileName); } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs index c362975ad4e2e663fa9967ad9d80a74324137f0c..e97eaac8d4bac0ae4fe2eb76ff92b34fd311a4c2 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/InterimStageBusVehicleViewModel_v2_8.cs @@ -140,27 +140,33 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public DeclarationInterimStageBusVehicleViewModel_v2_8(IVehicleDeclarationInputData consolidatedVehicleData, - IMultiStageViewModelFactory multistageViewModelFactory) + IMultiStageViewModelFactory multistageViewModelFactory, bool exempted) { ConsolidatedVehicleData = consolidatedVehicleData; - + _exemptedVehicle = exempted; _multiStageViewModelFactory = multistageViewModelFactory; - MultistageAirdragViewModel = _multiStageViewModelFactory.GetMultistageAirdragViewModel(consolidatedVehicleData?.Components?.AirdragInputData); - - MultistageAirdragViewModel.AirdragViewModelChanged += ((sender, args) => { - if (sender is IMultistageAirdragViewModel vm) { - if (AirdragModifiedMultistageMandatory) { - if (vm.AirDragViewModel != null) { - AirdragModifiedMultistage = true; + + if (!exempted) { + MultistageAirdragViewModel = _multiStageViewModelFactory.GetMultistageAirdragViewModel(consolidatedVehicleData?.Components?.AirdragInputData); + + MultistageAirdragViewModel.AirdragViewModelChanged += ((sender, args) => { + if (sender is IMultistageAirdragViewModel vm) + { + if (AirdragModifiedMultistageMandatory) + { + if (vm.AirDragViewModel != null) + { + AirdragModifiedMultistage = true; + } } } - } - }); + }); - MultistageAuxiliariesViewModel = - _multiStageViewModelFactory.GetAuxiliariesViewModel(consolidatedVehicleData?.Components? - .BusAuxiliaries); + MultistageAuxiliariesViewModel = + _multiStageViewModelFactory.GetAuxiliariesViewModel(consolidatedVehicleData?.Components? + .BusAuxiliaries); + } CreateParameterViewModels(); @@ -372,6 +378,8 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation { multistageParameterViewModel.UpdateEditingEnabled(); } + MultistageAirdragViewModel.SetAirdragInputData(vehicleInputData?.Components?.AirdragInputData); + MultistageAuxiliariesViewModel.SetAuxiliariesInputData(vehicleInputData?.Components?.BusAuxiliaries); OnPropertyChanged(string.Empty); } @@ -922,11 +930,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public bool ExemptedVehicle { - get { throw new NotImplementedException(); } + get => _exemptedVehicle; + //set => SetProperty(ref _exemptedVehicle, value); } - public VehicleCategory VehicleCategory { get { throw new NotImplementedException(); } @@ -1138,7 +1146,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation private bool _airdragModifiedMultistageMandatory; private int? _numberPassengersStandingLowerDeck; private int? _numberPassengersStandingUpperDeck; - - + private bool _exemptedVehicle; } } \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs index a0f8a942108ebf574af9b5dcc2d7640a11bf3dc9..bb7d149e35068bee947630f185e80905d02c0533 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/ManufacturingStageViewModel_v0_1.cs @@ -71,14 +71,14 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public void SetInputData(IVehicleDeclarationInputData vehicleInputData) { VehicleViewModel.SetVehicleInputData(vehicleInputData); - VehicleViewModel.MultistageAirdragViewModel.SetAirdragInputData(vehicleInputData?.Components?.AirdragInputData); - VehicleViewModel.MultistageAuxiliariesViewModel.SetAuxiliariesInputData(vehicleInputData?.Components?.BusAuxiliaries); + OnPropertyChanged(nameof(CurrentView)); } - public ManufacturingStageViewModel_v0_1(IManufacturingStageInputData consolidatedManufacturingStageInputData, IMultiStageViewModelFactory viewModelFactory) + public ManufacturingStageViewModel_v0_1(IManufacturingStageInputData consolidatedManufacturingStageInputData, bool exempted, + IMultiStageViewModelFactory viewModelFactory) { Title = "Edit Manufacturing Stage"; _viewModelFactory = viewModelFactory; @@ -88,16 +88,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation _consolidatedManufacturingStageInputData = consolidatedManufacturingStageInputData; - VehicleViewModel = (IMultistageVehicleViewModel)_viewModelFactory.GetInterimStageVehicleViewModel(consolidatedManufacturingStageInputData?.Vehicle); + VehicleViewModel = (IMultistageVehicleViewModel)_viewModelFactory.GetInterimStageVehicleViewModel(consolidatedManufacturingStageInputData?.Vehicle, exempted); CurrentView = VehicleViewModel as IViewModelBase; Components.Add(VehicleViewModel.Name, VehicleViewModel as IViewModelBase); - - - Components.Add("Airdrag", VehicleViewModel.MultistageAirdragViewModel as IViewModelBase); - Components.Add("Auxiliaries", VehicleViewModel.MultistageAuxiliariesViewModel as IViewModelBase); } @@ -115,7 +111,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation public ICommand SwitchComponentViewCommand { get { - return _switchComponentViewCommand ?? new RelayCommand<string>(SwitchViewExecute, (string s) => true); + return _switchComponentViewCommand ?? new RelayCommand<string>(SwitchViewExecute, (string s) => SwitchViewCanExecute(s)); } } @@ -128,6 +124,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } } + private bool SwitchViewCanExecute(string viewToShow) + { + return Components[viewToShow] != null; + + } + #endregion private class ApplicationInformationMultistage : IApplicationInformation diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs index b9d1a2a335bd9f5b8b88a4a3674c5583d1cccd21..baf72977d0663f3c0a3232ea15ade05be9bf7dc7 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs @@ -74,8 +74,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation _primaryVehicle = _jobInputData.PrimaryVehicle; _dialogHelper = multistageDependencies.DialogHelperLazy; _inputDataReader = inputDataReader; + + var exempted = true; //= PrimaryVehicle.Vehicle.ExemptedVehicle + _manufacturingStageViewModel = - vmFactory.GetManufacturingStageViewModel(_consolidateManufacturingStage); + vmFactory.GetManufacturingStageViewModel(_consolidateManufacturingStage, exempted); // QUESTION: HEV/PEV ? //var hybridElectric = inputData.PrimaryVehicleData.Vehicle.HybridElectricHDV; @@ -84,6 +87,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } + + + #region Commands @@ -224,9 +230,11 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation var vehicleErrorInfo = vehicleViewModel as IDataErrorInfo; errorMessage += vehicleErrorInfo.Error.Replace(",", "\n"); + var auxiliariesErrorInfo = vehicleViewModel.MultistageAuxiliariesViewModel as IDataErrorInfo; - if (!auxiliariesErrorInfo.Error.IsNullOrEmpty()) + if (auxiliariesErrorInfo != null && + !auxiliariesErrorInfo.Error.IsNullOrEmpty()) { errorMessage += "\n Auxiliaries \n"; errorMessage += auxiliariesErrorInfo.Error.Replace(",", "\n"); @@ -341,10 +349,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } #endregion - - - - #region Implementation of IInputDataProvider public string DocumentName => Path.GetFileNameWithoutExtension(_inputData.DataSource.SourceFile); diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/NewMultiStageJobViewModel.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/NewMultiStageJobViewModel.cs index 0468834e7dd0d4b08022fa0fe555d6139a270432..45318bd8124dfcff38380e6b81c2cb844da8945b 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/NewMultiStageJobViewModel.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/NewMultiStageJobViewModel.cs @@ -80,7 +80,6 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation } if (inputDataProvider == null) { - _dialogHelper.ShowMessageBox("invalid input file", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs b/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs index 90e54e472247409ce253f842c908ea3e585edc53..53174738cfb7d13085c8206e2167e1e9bbea8d41 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Interfaces/IMultiStageViewModelFactory.cs @@ -20,9 +20,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Interfaces IVehicleViewModel GetInterimStageVehicleViewModel(); - IVehicleViewModel GetInterimStageVehicleViewModel(IVehicleDeclarationInputData consolidatedVehicleData); + IVehicleViewModel GetInterimStageVehicleViewModel(IVehicleDeclarationInputData consolidatedVehicleData, bool exempted); - IManufacturingStageViewModel GetManufacturingStageViewModel(IManufacturingStageInputData consolidatedManufacturingStageInputData); + IManufacturingStageViewModel GetManufacturingStageViewModel(IManufacturingStageInputData consolidatedManufacturingStageInputData, bool exempted); IMultistageAirdragViewModel GetMultistageAirdragViewModel(); IMultistageAirdragViewModel GetMultistageAirdragViewModel( diff --git a/VECTO3GUI2020/Views/JoblistView.xaml b/VECTO3GUI2020/Views/JoblistView.xaml index d0f691c0a4e7068dd7a99da7317d765d81417634..8716be765c0d3bfc1c6802a49b4fc532609a1646 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml +++ b/VECTO3GUI2020/Views/JoblistView.xaml @@ -58,6 +58,7 @@ RowHeight="30" AlternatingRowBackground="LightGray" CellStyle="{DynamicResource DataGridCellStyle1}" + SelectedItem = "{Binding SelectedJob}" > <DataGrid.Columns> <DataGridCheckBoxColumn IsReadOnly="False" Header="Simulate" Binding="{Binding Selected}" Width="1*"></DataGridCheckBoxColumn> @@ -88,7 +89,7 @@ <StackPanel > <Button x:Name="button3" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding AddJobAsyncCommand}" Background="#FFDDDDDD"> + Command="{Binding AddJobAsyncCommand, IsAsync=True}" Background="#FFDDDDDD"> Add Job</Button> <Button x:Name="button4" Margin ="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" @@ -99,7 +100,7 @@ Command="{Binding NewManufacturingStageFile}" AutomationProperties.AutomationId="JobListViewNewManufacturingStageFileButton">New Multistage Job</Button> <Button x:Name="button6" Margin="4" HorizontalAlignment="Stretch" Style="{StaticResource MultiStageButtonStyle1}" - Command="{Binding RemoveJob}" + Command="{Binding RemoveJob, IsAsync=True}" CommandParameter="{Binding ElementName=JobDataGrid, Path=SelectedItem}">Remove Job</Button> </StackPanel> </Border> diff --git a/VECTO3GUI2020/Views/JoblistView.xaml.cs b/VECTO3GUI2020/Views/JoblistView.xaml.cs index b64cacf114f17b87aeb375903b41251c696ad156..7a2f519898371d9460593dc8b2f7ea3828fb6744 100644 --- a/VECTO3GUI2020/Views/JoblistView.xaml.cs +++ b/VECTO3GUI2020/Views/JoblistView.xaml.cs @@ -1,5 +1,6 @@ using System.Windows; using System.Windows.Controls; +using System.Windows.Input; using VECTO3GUI2020.ViewModel.Implementation; using VECTO3GUI2020.ViewModel.Interfaces; @@ -46,5 +47,10 @@ namespace VECTO3GUI2020.Views e.Effects = DragDropEffects.None; } } + + private void JobDataGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + CommandManager.InvalidateRequerySuggested(); + } } } diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml b/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml index 614ebbf578717fae433d5e08887404b7c31095a6..31afd998057d63816e703fe626eff8fee935105a 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml @@ -17,9 +17,15 @@ <TextBox x:Name="textBox" VerticalContentAlignment="Center" Padding="4" Margin = "0 0 0 0" IsReadOnly="True" Text="{Binding Text, ElementName=filepickercustomcontrol}" HorizontalAlignment="Stretch" TextWrapping="Wrap" Style="{DynamicResource TextBoxStyle1}"/> - <Button x:Name="button" Padding="4" Margin="4 0 0 0" Grid.Column="1" ContentTemplate="{DynamicResource AddDocumentIcon}" + <Button x:Name="button" Padding="4" Margin="4 0 0 0" Grid.Column="1" Command="{Binding Command, ElementName=filepickercustomcontrol}" Style="{DynamicResource FilePickerButtonStyle}"> - + <Button.ContentTemplate> + <Binding Path="ButtonContentTemplate" ElementName="filepickercustomcontrol" Converter="{StaticResource NullToUnsetValue}"> + <Binding.FallbackValue> + <StaticResource ResourceKey="AddDocumentIcon"></StaticResource> + </Binding.FallbackValue> + </Binding> + </Button.ContentTemplate> </Button> </Grid> </UserControl> diff --git a/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml.cs b/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml.cs index 8fe20e035718c3aed625d9204a7007086d28dae3..6c7de5effe5ecc2f774e384ac89ddf77d2e272dc 100644 --- a/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml.cs +++ b/VECTO3GUI2020/Views/Multistage/CustomControls/FilePicker.xaml.cs @@ -20,6 +20,15 @@ namespace VECTO3GUI2020.Views.Multistage.CustomControls /// </summary> public partial class FilePicker : UserControl { + public static readonly DependencyProperty ButtonContentTemplateProperty = DependencyProperty.Register( + "ButtonContentTemplate", typeof(DataTemplate), typeof(FilePicker), new PropertyMetadata(default(DataTemplate))); + + public DataTemplate ButtonContentTemplate + { + get { return (DataTemplate)GetValue(ButtonContentTemplateProperty); } + set { SetValue(ButtonContentTemplateProperty, value); } + } + public static readonly DependencyProperty CommandProperty = DependencyProperty.Register( "Command", typeof(ICommand), typeof(FilePicker), new PropertyMetadata(default(ICommand))); diff --git a/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml b/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml index 9d8137454ca38e97b76c0d0a162239683443eb07..eab0e480c6208eed1e42bdf46e8f4cbd1a4b10d4 100644 --- a/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml +++ b/VECTO3GUI2020/Views/Multistage/ManufacturingStageView.xaml @@ -29,7 +29,7 @@ </StackPanel> </DockPanel> - <ContentControl DockPanel.Dock="Top" Content="{Binding CurrentView}"/> + <ContentControl ContentTemplateSelector="{StaticResource MultistageVehicleDataTemplateSelector}" DockPanel.Dock="Top" Content="{Binding CurrentView}"/> </DockPanel> </Grid> </UserControl> diff --git a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml index 99ef7e8b6b34a4334df68cbb32b3faacb0f29968..5a2e002671fb709e0196e127ed3fdef51780325f 100644 --- a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml +++ b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8.xaml @@ -11,11 +11,6 @@ mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" BorderBrush="{DynamicResource ButtonHighlightColor}" BorderThickness="2px" Margin="4px"> <UserControl.Resources> - <Style TargetType="custom:MultiStageParameter"> - <Setter Property="NameLookUpResourceManager" Value="{x:Static properties:BusStrings.ResourceManager}"/> - <Setter Property="Validation.ErrorTemplate" Value="{StaticResource multistageParameterControlErrorTemplate}"/> - </Style> - <Style TargetType="ContentControl"> <Setter Property="ContentTemplateSelector" Value="{DynamicResource MultistageParameterTemplateSelector}"/> <Setter Property="IsTabStop" Value="False"></Setter> @@ -32,12 +27,8 @@ Style="{DynamicResource LabelStyle1}"/> - <ContentControl Content="{Binding ParameterViewModels[Manufacturer]}" > - </ContentControl> - - + <ContentControl Content="{Binding ParameterViewModels[Manufacturer]}"/> <ContentControl Content="{Binding ParameterViewModels[ManufacturerAddress]}"/> - <ContentControl Content="{Binding ParameterViewModels[VIN]}"/> diff --git a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8_exempted.xaml b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8_exempted.xaml new file mode 100644 index 0000000000000000000000000000000000000000..0e6f60a87288e264d1155ebaf0f81cf8ea7be8f2 --- /dev/null +++ b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8_exempted.xaml @@ -0,0 +1,63 @@ +<UserControl x:Class="VECTO3GUI2020.Views.Multistage.VehicleView_v2_8_exempted" + 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" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800"> + <UserControl.Resources> + <Style TargetType="ContentControl"> + <Setter Property="ContentTemplateSelector" Value="{DynamicResource MultistageParameterTemplateSelector}"/> + <Setter Property="IsTabStop" Value="False"></Setter> + </Style> + </UserControl.Resources> + <Grid> + <ScrollViewer> + <DockPanel> + <StackPanel> + <Label Content="VEHICLE DATA" HorizontalAlignment="Stretch" FontSize="15" VerticalAlignment="Stretch" + Style="{DynamicResource LabelStyle1}"/> + + + <ContentControl Content="{Binding ParameterViewModels[Manufacturer]}"/> + <ContentControl Content="{Binding ParameterViewModels[ManufacturerAddress]}"/> + <ContentControl Content="{Binding ParameterViewModels[VIN]}"/> + <ContentControl Content="{Binding ParameterViewModels[Model]}"/> + <ContentControl Content="{Binding ParameterViewModels[LegislativeClass]}"/> + <ContentControl Content="{Binding ParameterViewModels[CurbMassChassis]}"/> + <ContentControl Content="{Binding ParameterViewModels[GrossVehicleMassRating]}"/> + <ContentControl Content="{Binding ParameterViewModels[RegisteredClass]}"/> + + + + <Separator/> + + <ContentControl + Content="{Binding ParameterViewModels[VehicleCode]}"/> + + <ContentControl + Content="{Binding ParameterViewModels[LowEntry]}"/> + <Separator/> + + <ContentControl + Content="{Binding ParameterViewModels[HeightInMm]}"/> + <Separator/> + + <Label Style="{DynamicResource LabelStyle1}">Number of Passengers</Label> + <ContentControl + Content="{Binding ParameterViewModels[NumberPassengerSeatsLowerDeck]}"/> + <ContentControl + Content="{Binding ParameterViewModels[NumberPassengerSeatsUpperDeck]}"/> + <ContentControl + Content="{Binding ParameterViewModels[NumberPassengersStandingLowerDeck]}"/> + <ContentControl + Content="{Binding ParameterViewModels[NumberPassengersStandingUpperDeck]}"/> + + + + </StackPanel> + </DockPanel> + </ScrollViewer> + </Grid> +</UserControl> diff --git a/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8_exempted.xaml.cs b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8_exempted.xaml.cs new file mode 100644 index 0000000000000000000000000000000000000000..56db7aca7d57d6cf53f94e4baea20e5833ba72f7 --- /dev/null +++ b/VECTO3GUI2020/Views/Multistage/VehicleView_v2_8_exempted.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 VehicleView_v2_8_exempted.xaml + /// </summary> + public partial class VehicleView_v2_8_exempted : UserControl + { + public VehicleView_v2_8_exempted() + { + InitializeComponent(); + } + } +} diff --git a/VECTO3GUI2020/Views/SettingsView.xaml b/VECTO3GUI2020/Views/SettingsView.xaml index 225d9506482e2c5aa0e773fb63623bc488f283da..f6579754edbfc73cc82c0840f6f5b33eee280769 100644 --- a/VECTO3GUI2020/Views/SettingsView.xaml +++ b/VECTO3GUI2020/Views/SettingsView.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:VECTO3GUI2020.Views" xmlns:customControls="clr-namespace:VECTO3GUI2020.Views.Multistage.CustomControls" xmlns:implementation="clr-namespace:VECTO3GUI2020.ViewModel.Implementation" - mc:Ignorable="d" Height="450" Width="800" d:DataContext="{d:DesignInstance implementation:SettingsViewModel }"> + mc:Ignorable="d" d:DataContext="{d:DesignInstance implementation:SettingsViewModel }"> <UserControl.Resources> <Style TargetType="Label"> <Setter Property="Margin" Value="4 4 4 4"></Setter> @@ -20,66 +20,82 @@ </UserControl.Resources> <Grid> - <DockPanel LastChildFill="False"> - <Grid DockPanel.Dock="Top"> + <DockPanel VerticalAlignment="Stretch" LastChildFill="False"> + <Label DockPanel.Dock="Top" Style="{StaticResource LabelStyle1}">File I/O</Label> + <Border DockPanel.Dock="Top" BorderBrush="{StaticResource ButtonHighlightColor}" BorderThickness="1"> + <Grid DockPanel.Dock="Top" IsSharedSizeScope="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="1*"></ColumnDefinition> - <ColumnDefinition Width="1*"></ColumnDefinition> - <ColumnDefinition Width="1*"></ColumnDefinition> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> - <RowDefinition Height="30"></RowDefinition> - <RowDefinition Height="30"></RowDefinition> - <RowDefinition Height="30"></RowDefinition> </Grid.RowDefinitions> - - - <Label Grid.Row="0" Grid.Column="0" DockPanel.Dock="Left">Default Path</Label> - <customControls:FilePicker Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" DockPanel.Dock="Right" - Text="{Binding DefaultFilePath}" - HorizontalAlignment="Stretch" Command="{Binding ChangeFilePath}"/> - - <Label Grid.Row="1" Grid.Column="0" DockPanel.Dock="Left">Default Path</Label> - <Grid Grid.Row="1" Grid.Column="1" Margin="4" VerticalAlignment="Stretch" Grid.ColumnSpan="3" DockPanel.Dock="Right"> - <Grid.RowDefinitions> - <RowDefinition></RowDefinition> - </Grid.RowDefinitions> + + <Label Grid.Row="0" Grid.Column="0" DockPanel.Dock="Left">Default Input Path</Label> + <customControls:FilePicker Grid.Row="0" + Grid.Column="1" + DockPanel.Dock="Right" + Text="{Binding DefaultFilePath}" + HorizontalAlignment="Stretch" Command="{Binding ChangeFilePath}" + ButtonContentTemplate="{DynamicResource FolderIcon}"/> + + + <Label Grid.Column="0" Grid.Row="1">Default Output Path</Label> + <customControls:FilePicker Grid.Row="1" + Grid.Column="1" + Text="{Binding DefaultOutputPath}" + Command="{Binding ChangeOutputPath}" + ButtonContentTemplate="{DynamicResource FolderIcon}"/> + </Grid> + </Border> + <Border BorderBrush="{DynamicResource ButtonHighlightColor}" BorderThickness="1" DockPanel.Dock="Top"> + <StackPanel> + + <Label DockPanel.Dock="Top" Style="{DynamicResource LabelStyle1}">Simulation Settings</Label> + + <Grid> <Grid.ColumnDefinitions> - <ColumnDefinition></ColumnDefinition> - <ColumnDefinition Width="30px"></ColumnDefinition> + <ColumnDefinition Width="2*"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="2*"/> + <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions> - <TextBox x:Name="textBox" VerticalContentAlignment="Center" Padding="4" Margin = "0 0 0 0" IsReadOnly="false" - Text="{Binding DefaultOutputPath}" HorizontalAlignment="Stretch" TextWrapping="Wrap" - Style="{DynamicResource TextBoxStyle1}"/> - <Button x:Name="button" Padding="4" Margin="4 0 0 0" Grid.Column="1" ContentTemplate="{DynamicResource AddDocumentIcon}" - Command="{Binding ChangeOutputPath}" Style="{DynamicResource FilePickerButtonStyle}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Label Grid.Row="0" Grid.Column="0">Serialize Vecto Run Data</Label> + <CheckBox Grid.Row="0" Grid.Column="1" IsChecked="{Binding SerializeVectoRunData}"></CheckBox> + + <Label Grid.Row="1" Grid.Column="2">Write Modal Results</Label> + <CheckBox Grid.Row="1" Grid.Column="3" IsChecked="{Binding WriteModalResults}"></CheckBox> + + <Label Grid.Row="2" Grid.Column="0">Validate</Label> + <CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding Validate}"></CheckBox> + + <Label Grid.Row="0" Grid.Column="2">Actual Modal Data</Label> + <CheckBox Grid.Row="0" Grid.Column="3" IsChecked="{Binding ActualModalData}"></CheckBox> + + <Label Grid.Row="1" Grid.Column="0">ModalResults1Hz</Label> + <CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding ModalResults1Hz}"></CheckBox> + + - </Button> - </Grid> - <!--<customControls:FilePicker Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" DockPanel.Dock="Right" - Text="{Binding DefaultOutputPath}" - HorizontalAlignment="Stretch" Command="{Binding ChangeOutputPath}"/>--> + </Grid> - <Label Grid.Row="2" Grid.Column="0">Serialize Vecto Run Data</Label> - <CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding SerializeVectoRunData}"></CheckBox> + </StackPanel> + </Border> - <Label Grid.Row="3" Grid.Column="2">Write Modal Results</Label> - <CheckBox Grid.Row="3" Grid.Column="3" IsChecked="{Binding WriteModalResults}"></CheckBox> - <Label Grid.Row="3" Grid.Column="0">Validate</Label> - <CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding Validate}"></CheckBox> - <Label Grid.Row="4" Grid.Column="2">Actual Modal Data</Label> - <CheckBox Grid.Row="4" Grid.Column="3" IsChecked="{Binding ActualModalData}"></CheckBox> - <Label Grid.Row="4" Grid.Column="0">ModalResults1Hz</Label> - <CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding ModalResults1Hz}"></CheckBox> - </Grid> - <!--<DockPanel DockPanel.Dock="Bottom" LastChildFill="False"> + + <!--</Grid>--> + <DockPanel DockPanel.Dock="Bottom" LastChildFill="False"> <Button DockPanel.Dock="Right" Width="100" Command="{Binding CloseWindowCommand}" @@ -87,7 +103,7 @@ Style="{DynamicResource MultiStageButtonStyle1}" Margin="4" Padding="4">Close</Button> - </DockPanel>--> + </DockPanel> </DockPanel> </Grid> </UserControl> diff --git a/VECTO3GUI2020/packages.config b/VECTO3GUI2020/packages.config index 71cda27b08c69a3e38256d3ef0f67ee74f029076..97e7978a0cfc88179dabd19f433872eab0b0c9ad 100644 --- a/VECTO3GUI2020/packages.config +++ b/VECTO3GUI2020/packages.config @@ -5,6 +5,7 @@ <package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net48" /> <package id="Microsoft.Maps.MapControl.WPF" version="1.0.0.3" targetFramework="net48" /> <package id="Microsoft.Toolkit.Mvvm" version="7.0.2" targetFramework="net48" /> + <package id="Newtonsoft.Json" version="12.0.1" targetFramework="net48" /> <package id="Ninject" version="3.3.4" targetFramework="net48" /> <package id="Ninject.Extensions.ChildKernel" version="3.3.0" targetFramework="net48" /> <package id="Ninject.Extensions.Factory" version="3.3.3" targetFramework="net48" /> diff --git a/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs b/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs index 231bc7af5ac725d74c0ac384c2e472b79cfd69f5..0358255e58d2b0dfab1e52d4e956af46730b88e3 100644 --- a/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs +++ b/Vecto3GUI2020Test/ViewModelTests/JobListViewModelTests.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Diagnostics; +using System.Threading.Tasks; using Ninject; using NUnit.Framework; using NUnit.Framework.Internal; @@ -19,7 +20,8 @@ namespace Vecto3GUI2020Test.ViewModelTests public async Task CancelSimulationWhileLoadingFiles() { var jobListViewModel = _kernel.Get<IJobListViewModel>() as JobListViewModel; - + var watch = new Stopwatch(); + watch.Start(); //load final vif var loadedFile = await jobListViewModel.AddJobAsync(GetFullPath(finalVIF)).ConfigureAwait(false); @@ -39,6 +41,8 @@ namespace Vecto3GUI2020Test.ViewModelTests Assert.That(() => jobListViewModel.SimulationRunning == false, constraint); TestContext.WriteLine("Done!"); + watch.Stop(); + TestContext.WriteLine($"ExecutionTime {watch.Elapsed.TotalSeconds}s"); } @@ -46,6 +50,8 @@ namespace Vecto3GUI2020Test.ViewModelTests public async Task CancelSimulationWhenJobContainerIsRunning() { var jobListViewModel = _kernel.Get<IJobListViewModel>() as JobListViewModel; + var watch = new Stopwatch(); + watch.Start(); //load final vif var loadedFile = await jobListViewModel.AddJobAsync(GetFullPath(finalVIF)).ConfigureAwait(false); @@ -72,6 +78,9 @@ namespace Vecto3GUI2020Test.ViewModelTests jobListViewModel.CancelSimulation.Execute(null); Assert.That(() => jobListViewModel.SimulationRunning == false, constraint); TestContext.WriteLine("Done!"); + + watch.Stop(); + TestContext.WriteLine($"ExecutionTime {watch.Elapsed.TotalSeconds}s"); } } } \ No newline at end of file