diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-15 19:51:07 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-15 19:51:07 +0300 |
| commit | ca293b80c52a54c73251fbf3cd50741fb5653ae9 (patch) | |
| tree | f1168fa167a26bf8455e601291b8a19945a70187 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels | |
| parent | 9ff8293b603f72c5faa8d238b3005524c31cc5a8 (diff) | |
| download | Tango-ca293b80c52a54c73251fbf3cd50741fb5653ae9.tar.gz Tango-ca293b80c52a54c73251fbf3cd50741fb5653ae9.zip | |
Lots Of Work !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs | 99 | ||||
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs (renamed from Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs) | 7 | ||||
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs | 28 |
3 files changed, 132 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs new file mode 100644 index 000000000..8ddc544c0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Logging; +using Tango.MachineStudio.Logging.Navigation; +using Tango.MachineStudio.Logging.Parsing; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Logging.ViewModels +{ + public class ApplicationLogsViewVM : ViewModel + { + private ApplicationLogFileParser _parser; + private List<LogFile> _logFiles; + + private ObservableCollection<MessageLogItem> _logs; + public ObservableCollection<MessageLogItem> Logs + { + get { return _logs; } + set { _logs = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<DateTime> _dates; + public ObservableCollection<DateTime> Dates + { + get { return _dates; } + set { _dates = value; RaisePropertyChangedAuto(); } + } + + private DateTime _selectedDate; + public DateTime SelectedDate + { + get { return _selectedDate; } + set { _selectedDate = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); } + } + + private DateTime _minDate; + public DateTime MinDate + { + get { return _minDate; } + set { _minDate = value; RaisePropertyChangedAuto(); } + } + + private DateTime _maxDate; + public DateTime MaxDate + { + get { return _maxDate; } + set { _maxDate = value; RaisePropertyChangedAuto(); } + } + + + private bool _isRealTime; + public bool IsRealTime + { + get { return _isRealTime; } + set { _isRealTime = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); } + } + + public RelayCommand NavigateToHomeCommand { get; set; } + + public ApplicationLogsViewVM(LoggingNavigationManager navigation) + { + NavigateToHomeCommand = new RelayCommand(() => navigation.NavigateTo(LoggingNavigationView.HomeView)); + + _parser = new ApplicationLogFileParser(); + + _logFiles = _parser.GetLogFiles(); + Dates = new ObservableCollection<DateTime>(_logFiles.Select(x => x.DateTime).OrderBy(x => x)); + + SelectedDate = Dates.Last(); + + MinDate = Dates.Min(); + MaxDate = Dates.Max(); + } + + private void OnSelectedDateChanged() + { + if (IsRealTime) + { + //Events = _realTimeEvents; + } + else + { + List<MessageLogItem> logs = new List<MessageLogItem>(); + + foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date)) + { + logs.AddRange(_parser.Parse(logFile)); + } + + Logs = logs.ToObservableCollection(); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs index e5121e709..361adef01 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -18,7 +18,7 @@ using Tango.SharedUI; namespace Tango.MachineStudio.Logging.ViewModels { - public class MainViewVM : ViewModel + public class EventsViewVM : ViewModel { private INotificationProvider _notification; private IStudioApplicationManager _application; @@ -96,7 +96,9 @@ namespace Tango.MachineStudio.Logging.ViewModels public RelayCommand NavigateToEventsCommand { get; set; } - public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation) + public RelayCommand NavigateToHomeCommand { get; set; } + + public EventsViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation) { TimelineViewVM = new TimelineViewVM(notification); @@ -110,6 +112,7 @@ namespace Tango.MachineStudio.Logging.ViewModels RegisterMessage<MachineConnectionChangedMessage>(OnMachineConnectionChanged); DisplayTimelineCommand = new RelayCommand<MachinesEvent>(DisplayTimeline); NavigateToEventsCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.EventsView)); + NavigateToHomeCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.HomeView)); } private void OnMachineConnectionChanged(MachineConnectionChangedMessage msg) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs new file mode 100644 index 000000000..b87323491 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.MachineStudio.Logging.Navigation; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Logging.ViewModels +{ + public class HomeViewVM : ViewModel + { + private LoggingNavigationManager _navigation; + + public RelayCommand<String> NavigateToCommand { get; set; } + + public HomeViewVM(LoggingNavigationManager navigation) + { + _navigation = navigation; + + NavigateToCommand = new RelayCommand<string>((view) => + { + navigation.NavigateTo((LoggingNavigationView)Enum.Parse(typeof(LoggingNavigationView), view)); + }); + } + } +} |
