forked from dotnet/ResXResourceManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputViewModel.cs
More file actions
62 lines (50 loc) · 1.68 KB
/
Copy pathOutputViewModel.cs
File metadata and controls
62 lines (50 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
namespace tomenglertde.ResXManager
{
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using JetBrains.Annotations;
using tomenglertde.ResXManager.Infrastructure;
using TomsToolbox.Essentials;
using TomsToolbox.Wpf;
using TomsToolbox.Wpf.Composition.Mef;
[VisualCompositionExport(RegionId.Content, Sequence = 99)]
[Export(typeof(ITracer))]
public sealed class OutputViewModel : ObservableObject, ITracer
{
[NotNull]
[ItemNotNull]
public ObservableCollection<string> Lines { get; } = new ObservableCollection<string>();
[NotNull]
public ICommand CopyCommand => new DelegateCommand(Copy);
private void Copy()
{
Clipboard.SetText(string.Join(Environment.NewLine, Lines));
}
private void Append([NotNull] string prefix, [NotNull] string value)
{
var lines = value.Split('\n');
Lines.Add(DateTime.Now.ToShortTimeString() + "\t" + prefix + lines[0].Trim('\r'));
Lines.AddRange(lines.Skip(1).Select(l => l.Trim('\r')));
}
void ITracer.TraceError(string value)
{
Append("Error: ", value);
}
void ITracer.TraceWarning(string value)
{
Append("Warning: ", value);
}
void ITracer.WriteLine(string value)
{
Append(string.Empty, value);
}
public override string ToString()
{
return "Output";
}
}
}