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

Skip to content
Snippets Groups Projects
Commit cd15d687 authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

adding status bar to main window (outputview)

parent 6e6a3d07
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.InputData.FileIO.JSON;
......@@ -159,25 +160,19 @@ namespace VECTO3GUI2020.ViewModel.Implementation
SimulationRunning = true;
await RunSimulationAsync(cancellationTokenSource.Token,
new Progress<MessageEntry>((message) => { _outputViewModel.Messages.Add(message); }),
new Progress<int>((i) => _outputViewModel.Progress = i));
new Progress<int>((i) => _outputViewModel.Progress = i),
new Progress<string>((msg) => _outputViewModel.StatusMessage = msg));
SimulationRunning = false;
_outputViewModel.Progress = 0;
cancellationTokenSource.Dispose();
}
private async Task RunSimulationAsync(CancellationToken ct, IProgress<MessageEntry> outputMessages, IProgress<int> progress)
private async Task RunSimulationAsync(CancellationToken ct, IProgress<MessageEntry> outputMessages,
IProgress<int> progress, IProgress<string> status)
{
progress.Report(0);
//for (int i = 0; i <= 100; i++) {
// await Task.Delay(100);
// progress.Report(i);
// if (ct.IsCancellationRequested) {
// return;
// }
//}
status.Report("starting...");
IDocumentViewModel[] jobs;
lock (_jobsLock) {
jobs = Jobs.Where(x => x.Selected).ToArray();
......@@ -187,22 +182,14 @@ namespace VECTO3GUI2020.ViewModel.Implementation
Time = DateTime.Now,
Type = MessageType.InfoMessage,
});
status.Report("No jobs selected");
return;
}
}
//TODO add output path to settings
var outputPath = Settings.Default.DefaultFilePath;
var sumFileWriter = new FileOutputWriter(GetOutputDirectory(Jobs.First(x => x.Selected).DataSource.SourceFile));
var sumContainer = new SummaryDataContainer(sumFileWriter);
var jobContainer = new JobContainer(sumContainer);
var mode = ExecutionMode.Declaration;
var fileWriters = new Dictionary<int, FileOutputWriter>();
......@@ -210,9 +197,6 @@ namespace VECTO3GUI2020.ViewModel.Implementation
var xmlReader = _inputDataReader;
foreach (var jobEntry in jobs) {
try
{
......@@ -368,15 +352,10 @@ namespace VECTO3GUI2020.ViewModel.Implementation
var duration = start.Elapsed.TotalSeconds;
progress.Report(Convert.ToInt32(sumProgress * 100 / jobProgress.Count));
//outputMessages.Report(
// new MessageEntry()
// {
// 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))))
// });
var justFinished = jobProgress.Where(x => x.Value.Done & !finishedRuns.Contains(x.Key))
status.Report(string.Format(
"Duration: {0:F1}s, Current Progress: {1:P} ({2})", duration, sumProgress / jobProgress.Count,
string.Join(", ", jobProgress.Select(x => string.Format("{0,4:P}", x.Value.Progress)))));
var justFinished = jobProgress.Where(x => x.Value.Done & !finishedRuns.Contains(x.Key))
.ToDictionary(x => x.Key, x => x.Value);
//PrintRuns(justFinished, fileWriters);
finishedRuns.AddRange(justFinished.Select(x => x.Key));
......
......@@ -15,6 +15,7 @@ namespace VECTO3GUI2020.ViewModel
private object _messageLock = new Object();
private ObservableCollection<MessageEntry> _messages = new ObservableCollection<MessageEntry>();
private int _progress;
private string _statusMessage;
public ObservableCollection<MessageEntry> Messages
{
......@@ -30,6 +31,12 @@ namespace VECTO3GUI2020.ViewModel
set => SetProperty(ref _progress, value);
}
public string StatusMessage
{
get { return _statusMessage; }
set { SetProperty(ref _statusMessage, value); }
}
public OutputViewModel()
{
......@@ -45,5 +52,6 @@ namespace VECTO3GUI2020.ViewModel
ObservableCollection<MessageEntry> Messages { get; }
int Progress { get; set; }
string StatusMessage { get; set; }
}
}
\ No newline at end of file
......@@ -61,6 +61,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
_actualModalData = _settings.ActualModalData;
_serializeVectoRunData = _settings.SerializeVectoRunData;
_dialogHelper = dialogHelper;
_defaultOutputPath = _settings.DefaultOutputPath;
}
private ICommand _closeWindowCommand;
......
......@@ -5,8 +5,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VECTO3GUI2020.Views"
xmlns:impl="clr-namespace:VECTO3GUI2020.ViewModel.Implementation"
xmlns:viewModel="clr-namespace:VECTO3GUI2020.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignData Type=viewModel:IOutputViewModel}">
<Grid>
<DockPanel>
<ProgressBar DockPanel.Dock="Top" Minimum="0" Maximum="100" Value="{Binding Progress}"></ProgressBar>
......@@ -63,6 +64,7 @@
</Style>
</DataGrid.CellStyle>
</DataGrid>
<StatusBar DockPanel.Dock="Bottom" VerticalAlignment="Bottom"><TextBlock Text="{Binding StatusMessage}"/></StatusBar>
</DockPanel>
</Grid>
</UserControl>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment