diff --git a/VECTO3GUI/MainWindow.xaml b/VECTO3GUI/MainWindow.xaml index d32e48dd507f614ec259b31bd73b03ab65968c43..c4b7cf477a0290517f31e0382f425afc2c112b45 100644 --- a/VECTO3GUI/MainWindow.xaml +++ b/VECTO3GUI/MainWindow.xaml @@ -73,7 +73,10 @@ <Grid Grid.Row="2"> - <StatusBar/> + <StatusBar > + <StatusBarItem><TextBlock Text="{Binding CurrentViewModel.Status}"/></StatusBarItem> + <StatusBarItem HorizontalAlignment="Right"><ProgressBar Width="150" Height="20" Value="{Binding CurrentViewModel.Progress}"></ProgressBar></StatusBarItem> + </StatusBar> </Grid> diff --git a/VECTO3GUI/VECTO3GUI.csproj b/VECTO3GUI/VECTO3GUI.csproj index 15a0c9d34203480f9a2e4e92b347909b7cc73114..0ed559f3fcfe223e6c5dd74a4a26fabfb911c314 100644 --- a/VECTO3GUI/VECTO3GUI.csproj +++ b/VECTO3GUI/VECTO3GUI.csproj @@ -138,10 +138,18 @@ <HintPath>..\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll</HintPath> <Private>True</Private> </Reference> + <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> + <HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Configuration" /> <Reference Include="System.Data" /> + <Reference Include="System.IO.Compression" /> + <Reference Include="System.Runtime.Serialization" /> + <Reference Include="System.ServiceModel" /> + <Reference Include="System.Transactions" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll</HintPath> diff --git a/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs b/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs index 9b7ca1fc202c09038ee9841441d11464c25a8bcd..d502a430a90952a1b1285fa165f5e78ff32652e5 100644 --- a/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs +++ b/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs @@ -6,6 +6,7 @@ using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.IO; +using System.IO.Pipes; using System.Linq; using System.Threading; using System.Windows; @@ -15,6 +16,8 @@ using System.Xml; using System.Xml.Linq; using Castle.Core.Internal; using Ninject; +using NLog; +using NLog.Targets; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; @@ -31,6 +34,7 @@ using VECTO3GUI.ViewModel.Interfaces; using VECTO3GUI.Helper; using VECTO3GUI.Model; using VECTO3GUI.Views; +using LogManager = TUGraz.VectoCommon.Models.LogManager; using MessageBox = System.Windows.MessageBox; @@ -67,6 +71,11 @@ namespace VECTO3GUI.ViewModel.Impl private ICommand _doubleClickCommand; private ICommand _runSimulationCommand; private BackgroundWorker SimulationWorker; + private string _status; + private double _progress; + private ICommand _stopSimulationCommand; + private bool _canRunSimulation = true; + private bool _canStopSimulation = false; #endregion @@ -114,6 +123,18 @@ namespace VECTO3GUI.ViewModel.Impl set { SetProperty(ref _visibilitySecView, value); } } + public string Status + { + get { return _status; } + set { SetProperty(ref _status, value); } + } + + public double Progress + { + get { return _progress; } + set { SetProperty(ref _progress, value); } + } + #endregion @@ -129,6 +150,32 @@ namespace VECTO3GUI.ViewModel.Impl SimulationWorker.WorkerReportsProgress = true; SimulationWorker.WorkerSupportsCancellation = true; + var target = new MethodCallTarget("VectoGuiTarget", (evtInfo, obj) => LogMethod(evtInfo, obj)); + NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target); + } + + private void LogMethod(LogEventInfo evtInfo, object[] objects) + { + if (!SimulationWorker.IsBusy || SimulationWorker.CancellationPending) { + return; + } + + //if (evtInfo.Level == LogLevel.Warn) { + // SimulationWorker.ReportProgress( + // 0, + // new VectoSimulationProgress() { + // Type = VectoSimulationProgress.MsgType.LogWarning, + // Message = evtInfo.FormattedMessage + // }); + //} else + if (evtInfo.Level == LogLevel.Error || evtInfo.Level == LogLevel.Fatal) { + SimulationWorker.ReportProgress( + 0, + new VectoSimulationProgress() { + Type = VectoSimulationProgress.MsgType.LogError, + Message = evtInfo.FormattedMessage + }); + } } private void SetJobEntries() @@ -167,7 +214,26 @@ namespace VECTO3GUI.ViewModel.Impl public ICommand RunSimulation { - get { return _runSimulationCommand ?? (_runSimulationCommand = new RelayCommand(DoRunSimulation, CanRunSimulation)); } + get { return _runSimulationCommand ?? (_runSimulationCommand = new RelayCommand(DoRunSimulation, CanRunSimulationCmd)); } + } + + public ICommand StopSimulation + { + get { + return _stopSimulationCommand ?? (_stopSimulationCommand = new RelayCommand(DoStopSimulation, CanStopSimulationCmd)); + } + } + + public bool CanRunSimulation + { + get { return _canRunSimulation; } + set { SetProperty(ref _canRunSimulation, value); } + } + + public bool CanStopSimulation + { + get { return _canStopSimulation; } + set { SetProperty(ref _canStopSimulation, value); } } public ICommand DoubleClickCommand @@ -633,7 +699,7 @@ namespace VECTO3GUI.ViewModel.Impl #region RunVECTOSimulation - private bool CanRunSimulation() + private bool CanRunSimulationCmd() { return !SimulationWorker.IsBusy; } @@ -647,6 +713,18 @@ namespace VECTO3GUI.ViewModel.Impl } } + private bool CanStopSimulationCmd() + { + return SimulationWorker.IsBusy; + } + + private void DoStopSimulation() + { + SimulationWorker.CancelAsync(); + } + + + private void RunVectoSimulation(object theSender, DoWorkEventArgs e) { var sender = theSender as BackgroundWorker; @@ -654,9 +732,12 @@ namespace VECTO3GUI.ViewModel.Impl return; } + CanRunSimulation = false; + CanStopSimulation = true; + var jobs = Jobs.Where(x => x.Selected).ToArray(); if (jobs.Length == 0) { - sender.ReportProgress(100, new VectoSimulationProgress() {Target = VectoSimulationProgress.Targets.Message, Message = "No jobs selected for simulation"}); + sender.ReportProgress(100, new VectoSimulationProgress() {Type = VectoSimulationProgress.MsgType.StatusMessage, Message = "No jobs selected for simulation"}); return; } var sumFileWriter = new FileOutputWriter(Path.GetDirectoryName(jobs.First().JobEntryFilePath)); @@ -678,7 +759,7 @@ namespace VECTO3GUI.ViewModel.Impl if (!File.Exists(fullFileName)) { sender.ReportProgress( 0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = $"File {jobEntry.JobEntryFilePath} not found!" }); @@ -688,7 +769,7 @@ namespace VECTO3GUI.ViewModel.Impl sender.ReportProgress( 0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = $"Reading file {Path.GetFileName(fullFileName)}" }); var extension = Path.GetExtension(jobEntry.JobEntryFilePath); @@ -717,7 +798,7 @@ namespace VECTO3GUI.ViewModel.Impl sender.ReportProgress( 0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = $"No input provider for job {Path.GetFileName(fullFileName)}" }); continue; @@ -732,22 +813,22 @@ namespace VECTO3GUI.ViewModel.Impl sender.ReportProgress( 0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = $"Finished reading data for job {Path.GetFileName(fullFileName)}" }); } catch (Exception ex) { MessageBox.Show( $"ERROR running job {Path.GetFileName(jobEntry.JobEntryFilePath)}: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); - sender.ReportProgress(0, new VectoSimulationProgress() {Target = VectoSimulationProgress.Targets.Message, Message = ex.Message}); + sender.ReportProgress(0, new VectoSimulationProgress() {Type = VectoSimulationProgress.MsgType.StatusMessage, Message = ex.Message}); } } foreach (var cycle in jobContainer.GetCycleTypes()) { - sender.ReportProgress(0, new VectoSimulationProgress() {Target = VectoSimulationProgress.Targets.Message, Message = $"Detected cycle {cycle.Name}: {cycle.CycleType}"}); + sender.ReportProgress(0, new VectoSimulationProgress() {Type = VectoSimulationProgress.MsgType.StatusMessage, Message = $"Detected cycle {cycle.Name}: {cycle.CycleType}"}); } - sender.ReportProgress(0, new VectoSimulationProgress() {Target = VectoSimulationProgress.Targets.Message, Message = $"Starting simulation ({jobs.Length} jobs, {jobContainer.GetProgress().Count} runs)"}); + sender.ReportProgress(0, new VectoSimulationProgress() {Type = VectoSimulationProgress.MsgType.StatusMessage, Message = $"Starting simulation ({jobs.Length} jobs, {jobContainer.GetProgress().Count} runs)"}); var start = Stopwatch.StartNew(); @@ -765,7 +846,7 @@ namespace VECTO3GUI.ViewModel.Impl sender.ReportProgress( Convert.ToInt32(sumProgress * 100.0 / progress.Count), new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Status, + Type = VectoSimulationProgress.MsgType.Progress, Message = string.Format( "Duration: {0:F1}s, Curernt Progress: {1:P} ({2})", duration, sumProgress / progress.Count, string.Join(", ", progress.Select(x => string.Format("{0,4:P}", x.Value.Progress)))) @@ -787,7 +868,7 @@ namespace VECTO3GUI.ViewModel.Impl foreach (var progressEntry in jobContainer.GetProgress()) { sender.ReportProgress(100, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, Message = + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", $"{progressEntry.Value.RunName} {progressEntry.Value.CycleName} {progressEntry.Value.RunSuffix}", progressEntry.Value.Progress, @@ -798,7 +879,7 @@ namespace VECTO3GUI.ViewModel.Impl sender.ReportProgress( 100, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = progressEntry.Value.Error.Message } ); @@ -812,7 +893,7 @@ namespace VECTO3GUI.ViewModel.Impl sender.ReportProgress( 100, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format( "{2} for '{0}' written to {1}", Path.GetFileName(jobEntry.JobEntryFilePath), entry.Key, entry.Value), Link = "<XML>" + entry.Key @@ -823,14 +904,14 @@ namespace VECTO3GUI.ViewModel.Impl if (File.Exists(sumFileWriter.SumFileName)) { sender.ReportProgress(100, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format("Sum file written to {0}", sumFileWriter.SumFileName), Link = "<CSV>" + sumFileWriter.SumFileName }); } sender.ReportProgress(100, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format("Simulation finished in {0:F1}s", start.Elapsed.TotalSeconds) }); } @@ -843,20 +924,20 @@ namespace VECTO3GUI.ViewModel.Impl if (p.Value.Error != null) { SimulationWorker.ReportProgress(0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format("Finished Run {0} with ERROR: {1}", runName, p.Value.Error.Message), Link = "<CSV>" + modFilename }); } else { SimulationWorker.ReportProgress(0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format("Finished run {0} successfully.", runName) }); } if (File.Exists(modFilename)) { SimulationWorker.ReportProgress(0, new VectoSimulationProgress() { - Target = VectoSimulationProgress.Targets.Message, + Type = VectoSimulationProgress.MsgType.StatusMessage, Message = string.Format("Run {0}: Modal results written to {1}", runName, modFilename), Link = "<CSV>" + modFilename }); @@ -867,7 +948,10 @@ namespace VECTO3GUI.ViewModel.Impl private void VectoSimulationCompleted(object sender, RunWorkerCompletedEventArgs e) { - // TODO! + Progress = 0; + Status = ""; + CanRunSimulation = true; + CanStopSimulation = false; } private void VectoSimulationProgressChanged(object sender, ProgressChangedEventArgs e) @@ -877,13 +961,21 @@ namespace VECTO3GUI.ViewModel.Impl return; } - switch (progress.Target) { - case VectoSimulationProgress.Targets.Message: + switch (progress.Type) { + case VectoSimulationProgress.MsgType.LogError: + case VectoSimulationProgress.MsgType.LogWarning: + case VectoSimulationProgress.MsgType.InfoMessage: + case VectoSimulationProgress.MsgType.StatusMessage: { //if (progress.Link == null) { - Messages.Add(new MessageEntry() {Message = progress.Message}); + Messages.Add(new MessageEntry() { Message = progress.Message, Type = progress.Type.ToMessageType() }); + //} break; - case VectoSimulationProgress.Targets.Status: break; + } + case VectoSimulationProgress.MsgType.Progress: + Progress = e.ProgressPercentage; + Status = progress.Message; + break; default: throw new ArgumentOutOfRangeException(); } } @@ -891,23 +983,40 @@ namespace VECTO3GUI.ViewModel.Impl public class VectoSimulationProgress { - public enum Targets + public enum MsgType { - Message, - Status + StatusMessage, + InfoMessage, + Progress, + LogError, + LogWarning, + } public string Message { get; set; } - public Targets Target { get; set; } + public MsgType Type { get; set; } public string Link { get; set; } } - + #endregion } - + public static class MsgTypeExtensions + { + public static MessageType ToMessageType(this JoblistViewModel.VectoSimulationProgress.MsgType mt) + { + switch (mt) { + case JoblistViewModel.VectoSimulationProgress.MsgType.StatusMessage: return MessageType.StatusMessage; + case JoblistViewModel.VectoSimulationProgress.MsgType.InfoMessage: return MessageType.InfoMessage; + case JoblistViewModel.VectoSimulationProgress.MsgType.Progress: return MessageType.StatusMessage; + case JoblistViewModel.VectoSimulationProgress.MsgType.LogError: return MessageType.ErrorMessage; + case JoblistViewModel.VectoSimulationProgress.MsgType.LogWarning: return MessageType.WarningMessage; + default: throw new ArgumentOutOfRangeException(nameof(mt), mt, null); + } + } + } } diff --git a/VECTO3GUI/ViewModel/Impl/MessageEntry.cs b/VECTO3GUI/ViewModel/Impl/MessageEntry.cs index dc8ed960fb1fb0bc7c03e94165f852c36da48187..c0e69e0c3195e549e02572aa089f1170b03566d6 100644 --- a/VECTO3GUI/ViewModel/Impl/MessageEntry.cs +++ b/VECTO3GUI/ViewModel/Impl/MessageEntry.cs @@ -1,16 +1,29 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace VECTO3GUI.ViewModel.Impl { + + public enum MessageType + { + InfoMessage, + StatusMessage, + ErrorMessage, + WarningMessage, + } + public class MessageEntry : ObservableObject { + + private string _message; private DateTime _time; private string _source; + private MessageType _type; public string Message { @@ -18,6 +31,12 @@ namespace VECTO3GUI.ViewModel.Impl set { SetProperty(ref _message, value); } } + public MessageType Type + { + get { return _type; } + set { SetProperty(ref _type, value); } + } + public DateTime Time { get { return _time; } diff --git a/VECTO3GUI/ViewModel/Interfaces/IJoblistViewModel.cs b/VECTO3GUI/ViewModel/Interfaces/IJoblistViewModel.cs index 6300e454c78781345da1eb3d9601439c47fc2878..d43218b833d3dece9302a65662eb19f701c51569 100644 --- a/VECTO3GUI/ViewModel/Interfaces/IJoblistViewModel.cs +++ b/VECTO3GUI/ViewModel/Interfaces/IJoblistViewModel.cs @@ -25,5 +25,8 @@ namespace VECTO3GUI.ViewModel.Interfaces ICommand OpenInFolder { get; } ICommand DoubleClickCommand { get; } ICommand RunSimulation { get; } + ICommand StopSimulation { get; } + bool CanRunSimulation { get; } + bool CanStopSimulation { get; } } } diff --git a/VECTO3GUI/Views/JoblistView.xaml b/VECTO3GUI/Views/JoblistView.xaml index 93a7f66d7b8c8fbc6161a0ebc2b24b42b8d08ec6..f0ba443646d4371929658855d47b25a3f0af51ca 100644 --- a/VECTO3GUI/Views/JoblistView.xaml +++ b/VECTO3GUI/Views/JoblistView.xaml @@ -8,6 +8,7 @@ xmlns:views="clr-namespace:VECTO3GUI.Views" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:converter="clr-namespace:VECTO3GUI.Helper.Converter" + xmlns:vecto3Gui="clr-namespace:VECTO3GUI" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="600" d:DataContext="{d:DesignInstance Type=impl:JoblistViewModel, IsDesignTimeCreatable=False}"> @@ -34,10 +35,17 @@ <StackPanel Orientation="Vertical"> <Button VerticalAlignment="Top" Margin="10,10,0,0" - Command="{Binding RunSimulation}"> + Command="{Binding RunSimulation}" Visibility="{Binding CanRunSimulation, Converter={converter:BoolVisibilityConverter}}"> <StackPanel Orientation="Horizontal"> <iconPacks:PackIconModern Width="20" Height="15" Kind="ControlPlay" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Green"/> - <TextBlock Text="Start " /> + <TextBlock Text="Start" Margin="5,0,0,0" /> + </StackPanel> + </Button> + <Button VerticalAlignment="Top" Margin="10,10,0,0" + Command="{Binding StopSimulation}" Visibility="{Binding CanStopSimulation, Converter={converter:BoolVisibilityConverter}}"> + <StackPanel Orientation="Horizontal"> + <iconPacks:PackIconModern Width="20" Height="15" Kind="ControlStop" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red"/> + <TextBlock Text="Stop" Margin="5,0,0,0" /> </StackPanel> </Button> @@ -165,14 +173,52 @@ <Grid Grid.Row="2" Grid.ColumnSpan="3" Grid.Column="0" Margin="10,20,20,10"> <DataGrid ItemsSource="{Binding Messages}" BorderThickness="1" CanUserAddRows="False" AutoGenerateColumns="False" SelectionUnit="FullRow" - IsReadOnly="True" HeadersVisibility="All" RowHeaderWidth="5"> + IsReadOnly="True" HeadersVisibility="All" RowHeaderWidth="5" RowHeight="5" Name="MessageList"> <DataGrid.Columns> <DataGridTextColumn Header="Message" Binding="{Binding Message}" Width="*" /> - <DataGridTextColumn Header="Time" Binding="{Binding Time}" Width="130" /> - <DataGridTextColumn Header="Source" Binding="{Binding Source}" Width="150" /> + <!--<DataGridTextColumn Header="Time" Binding="{Binding Time}" Width="130" />--> + <!--<DataGridTextColumn Header="Source" Binding="{Binding Source}" Width="150" />--> </DataGrid.Columns> - + <DataGrid.RowStyle> + <Style TargetType="DataGridRow"> + <Style.Triggers> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.StatusMessage}"> + <Setter Property="Background" Value="AliceBlue"/> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.InfoMessage}"> + <Setter Property="Background" Value="LemonChiffon"/> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.ErrorMessage}"> + <Setter Property="Background" Value="Red"/> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.WarningMessage}"> + <Setter Property="Background" Value="Gold"/> + </DataTrigger> + </Style.Triggers> + </Style> + </DataGrid.RowStyle> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell"> + <Setter Property="FontFamily" Value="Courier New"/> + <Style.Triggers> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.StatusMessage}"> + <Setter Property="Foreground" Value="Black"/> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.InfoMessage}"> + <Setter Property="Foreground" Value="DimGray"/> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.ErrorMessage}"> + <Setter Property="Foreground" Value="White"/> + <Setter Property="FontWeight" Value="Bold"/> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="{x:Static impl:MessageType.WarningMessage}"> + <Setter Property="Foreground" Value="Black"/> + <Setter Property="FontWeight" Value="Bold"/> + </DataTrigger> + </Style.Triggers> + </Style> + </DataGrid.CellStyle> </DataGrid> </Grid> diff --git a/VECTO3GUI/Views/JoblistView.xaml.cs b/VECTO3GUI/Views/JoblistView.xaml.cs index 029a8ff922641069015723396aa67ff52b688c04..26e113c61c6462d03c4515883dd3701e25d620fa 100644 --- a/VECTO3GUI/Views/JoblistView.xaml.cs +++ b/VECTO3GUI/Views/JoblistView.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -27,6 +28,16 @@ namespace VECTO3GUI.Views public JoblistView() { InitializeComponent(); + ((INotifyCollectionChanged)MessageList.Items).CollectionChanged += AutoScroll; + } + + private void AutoScroll(object sender, NotifyCollectionChangedEventArgs e) + { + if (MessageList.Items.Count > 0) { + var border = VisualTreeHelper.GetChild(MessageList, 0) as Decorator; + var scroll = border?.Child as ScrollViewer; + scroll?.ScrollToEnd(); + } } } } diff --git a/VECTO3GUI/packages.config b/VECTO3GUI/packages.config index 2cb8134ec1dc64efe357691771c6a8486048fce7..3b6709c51cae09d49b19cd56ed6e8ba47182c524 100644 --- a/VECTO3GUI/packages.config +++ b/VECTO3GUI/packages.config @@ -8,6 +8,7 @@ <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net452" /> <package id="Ninject" version="3.3.4" targetFramework="net452" /> <package id="Ninject.Extensions.Factory" version="3.3.2" targetFramework="net452" /> + <package id="NLog" version="4.5.11" targetFramework="net452" /> <package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net452" /> <package id="WindowsAPICodePack-Core" version="1.1.2" targetFramework="net452" /> <package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net452" /> diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index f7b8acad5de8c5a138ad7998ccb4cb7935b37c9f..38b0921505ba8e3d7e53821fa31729a0774f3d97 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -89,12 +89,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return _sourceFile; } } - public bool SavedInDeclarationMode + public virtual bool SavedInDeclarationMode { get { return Body.GetEx(JsonKeys.SavedInDeclMode).Value<bool>(); } } - public string AppVersion { get { return "VECTO-JSON"; } } + public virtual string AppVersion { get { return "VECTO-JSON"; } } internal string BasePath { @@ -1098,6 +1098,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } + #region Overrides of JSONFile + + public override bool SavedInDeclarationMode { get { return true; } } + + #endregion + #region Implementation of ISingleBusInputDataProvider public IVehicleDeclarationInputData PrimaryVehicle { get; } @@ -1153,6 +1159,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON // return ; //} + #region Overrides of JSONFile + + public override bool SavedInDeclarationMode { get { return true; } } + + #endregion + #region Implementation of IDeclarationInputDataProvider public IDeclarationJobInputData JobInputData { get { return this; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs index 6be1919179ae261fd7e2c59e4bc4704a21c53a48..7a3cfa3fa587e105b0fd19cdf3156ac234e44022 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs @@ -205,7 +205,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var fcCurRes = fuel.ConsumptionMap.GetFuelConsumption(tqCurrent, engineSpeed, true); if (fcCurRes.Extrapolated) { Log.Warn( - "EffShift Strategy: Extrapolation of fuel consumption for current gear!n: {1}, Tq: {2}", + "EffShift Strategy: Extrapolation of fuel consumption for current gear!n: {0}, Tq: {1}", engineSpeed, tqCurrent); } fcCurrent += fcCurRes.Value.Value() * fuel.FuelData.LowerHeatingValueVecto.Value();