diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs new file mode 100644 index 000000000..b46c6477e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Logging; +using Tango.PPC.Common; + +namespace Tango.PPC.Technician.ViewModels +{ + public class LoggingViewVM : PPCViewModel + { + public SynchronizedObservableCollection<LogItemBase> ApplicationLogs { get; set; } + public SynchronizedObservableCollection<LogItemBase> EmbeddedLogs { get; set; } + + public LoggingViewVM() + { + ApplicationLogs = new SynchronizedObservableCollection<LogItemBase>(); + EmbeddedLogs = new SynchronizedObservableCollection<LogItemBase>(); + LogManager.NewLog += LogManager_NewLog; + } + + private void LogManager_NewLog(object sender, LogItemBase log) + { + ApplicationLogs.Insert(0, log); + + var now = DateTime.Now; + + try + { + foreach (var l in ApplicationLogs.ToList()) + { + if (l.TimeStamp.Date < DateTime.Now.Date) + { + ApplicationLogs.Remove(l); + } + } + } + catch + { + //I don't know if this will cause an exception but I'm tired. + } + } + + public override void OnApplicationStarted() + { + + } + } +} |
