Cosmos/source/Cosmos.Build.Builder/ViewModels/MainWindowLogger.cs
José Pedro f969601a53
Builder improvements.
- Added check for dependencies, which can be installed from the builder.
- Replaced CosmosTask with CosmosBuildDefinition, which is much simpler.
- The builder can be opened without any command line arguments.
- If the VS path is not specified as a command line argument, it can be selected in a dialog.
2018-03-30 19:44:19 +01:00

44 lines
1.3 KiB
C#

using System;
using System.Windows;
using Cosmos.Build.Builder.Models;
namespace Cosmos.Build.Builder.ViewModels
{
internal class MainWindowLogger : ILogger
{
private static readonly string[] NewLineStringArray = new string[] { Environment.NewLine };
private MainWindowViewModel _viewModel;
public MainWindowLogger(MainWindowViewModel viewModel)
{
_viewModel = viewModel;
}
public void LogMessage(string text) => Application.Current.Dispatcher.Invoke(
() =>
{
_viewModel.CurrentSection.LogMessage(text);
foreach (var line in text.Split(NewLineStringArray, StringSplitOptions.None))
{
_viewModel.TailItems.Push(line);
}
});
public void NewSection(string name) => Application.Current.Dispatcher.Invoke(
() =>
{
_viewModel.Sections.Add(new Section(name));
_viewModel.TailItems.Clear();
});
public void SetError() => Application.Current.Dispatcher.Invoke(
() =>
{
_viewModel.CurrentSection.SetError();
_viewModel.CloseWhenCompleted = false;
});
}
}