diff --git a/.gitignore b/.gitignore index 0f6e6ab57cf9b8b246b9e2d1b043dc98c6921f85..27fd0863a2fd6eb2ae4a79d091bdf46586f7da96 100644 --- a/.gitignore +++ b/.gitignore @@ -219,3 +219,4 @@ Documentation/VehiclesReleaseComparisonDeclarationMode/tmp/ /VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/tests.xml /VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/finalGroup41.VIF_Report_4.xml /VectoCore/VectoCoreTest/TestData/XML/XMLReaderDeclaration/output +/Vecto3GUI2020Test/TestData/output diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 08d76a8756f36440387fc8d09cde7083d17eb06c..2ba4e70116339f4356d6aaa08e5830e6b9797317 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -593,14 +593,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation { get { - return _cancelSimulationCommand ?? new RelayCommand(() => { + return _cancelSimulationCommand ?? (_cancelSimulationCommand = new RelayCommand(() => { _outputViewModel.AddMessage(new MessageEntry() { Message="Canceling Simulation", Type=MessageType.StatusMessage, }); cancellationTokenSource.Cancel(); }, - () => SimulationRunning); + () => SimulationRunning)); } } diff --git a/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs index 790a3d2379ee00830f97a7cc309b3a8c2ea67060..e0b8aaa5b15b47fc89e40597789a8403e30b3e6d 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/OutputViewModel.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; +using System.Linq; +using System.Text; using System.Windows.Data; using System.Windows.Input; using Microsoft.Toolkit.Mvvm.Input; @@ -65,10 +67,12 @@ namespace VECTO3GUI2020.ViewModel #region Commands + // ReSharper disable once UnusedMember.Global public ICommand OpenFolderCommand => _openFolderCommand ?? (_openFolderCommand = new RelayCommand<string>( OpenFolderExecute)); + // ReSharper disable once UnusedMember.Global public ICommand OpenFileCommand => _openFileCommand ?? (_openFileCommand = new RelayCommand<string>( OpenFileExecute)); @@ -79,10 +83,17 @@ namespace VECTO3GUI2020.ViewModel return; } + link = Path.GetFullPath(link); - var directoryPath = Path.GetDirectoryName(link); + var explorerCommandStrBuilder = new StringBuilder(); + explorerCommandStrBuilder.Append("explorer.exe"); + explorerCommandStrBuilder.Append(" /select "); + explorerCommandStrBuilder.Append(link); - StartProcess(directoryPath); + //var directoryPath = Path.GetDirectoryName(link); + //StartProcess(directoryPath); + + StartProcess("explorer.exe", ("/select," + link)); } private void OpenFileExecute(string link){ @@ -95,11 +106,26 @@ namespace VECTO3GUI2020.ViewModel } - private void StartProcess(string command) + private void StartProcess(string command, params string[]arguments) { + string argumentsString = ""; + if (arguments != null) { + var argumentsStrBuilder = new StringBuilder(); + foreach (var argument in arguments) { + argumentsStrBuilder.Append(argument); + if(argument != arguments.Last()) { + argumentsStrBuilder.Append(" "); + } + } + + argumentsString = argumentsStrBuilder.ToString(); + Debug.WriteLine(argumentsString); + } + + try { - Process.Start(command); + Process.Start(command, argumentsString ); } catch (Exception e) {