diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-19 13:55:25 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-19 13:55:25 +0300 |
| commit | 4f81c6ce6c3b836bbfdb86532199aa37382b6147 (patch) | |
| tree | df5f62f54feafd06fac8c3672d6706d19198c789 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging | |
| parent | 90fa13d3f55a5ad704ce34b508f15b4abada6872 (diff) | |
| download | Tango-4f81c6ce6c3b836bbfdb86532199aa37382b6147.tar.gz Tango-4f81c6ce6c3b836bbfdb86532199aa37382b6147.zip | |
Some improvements and fixes to machine studio logging module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging')
9 files changed, 109 insertions, 12 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 index 2b12b1670..c56ca5541 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Data; using Tango.Core.Commands; using Tango.Logging; using Tango.MachineStudio.Common.Notifications; @@ -19,6 +21,8 @@ namespace Tango.MachineStudio.Logging.ViewModels private ApplicationLogFileParser _parser; private List<LogFile> _logFiles; private INotificationProvider _notification; + private bool _dialog_shown; + private bool _is_debug; private ControlledObservableCollection<LogItemBase> _realTimeLogs; private List<LogItemBase> _pausedLogs; @@ -30,6 +34,29 @@ namespace Tango.MachineStudio.Logging.ViewModels set { _logs = value; RaisePropertyChangedAuto(); } } + private ICollectionView _logsViewSource; + public ICollectionView LogsViewSource + { + get { return _logsViewSource; } + set { _logsViewSource = value; RaisePropertyChangedAuto(); } + } + + private String _filter; + public String Filter + { + get { return _filter; } + set + { + _filter = value; + RaisePropertyChangedAuto(); + + if (RealTimePaused) + { + LogsViewSource.Refresh(); + } + } + } + private LogItemBase _selectedLog; public LogItemBase SelectedLog { @@ -84,9 +111,19 @@ namespace Tango.MachineStudio.Logging.ViewModels if (!_realTimePaused) { + LogsViewSource.Filter = null; _realTimeLogs.InsertRange(0, _pausedLogs); _pausedLogs.Clear(); } + else + { + LogsViewSource.Filter = (x) => + { + if (String.IsNullOrWhiteSpace(Filter)) return true; + LogItemBase log = x as LogItemBase; + return log.Message.ToLower().Contains(Filter.ToLower()); + }; + } } } @@ -126,6 +163,8 @@ namespace Tango.MachineStudio.Logging.ViewModels ToggleRealTimePaused = new RelayCommand(() => RealTimePaused = !RealTimePaused); ClearRealTimeLogsCommand = new RelayCommand(() => { _realTimeLogs.Clear(); }); + + _is_debug = LogManager.Categories.Contains(LogCategory.Debug); } private void LogManager_NewLog(object sender, LogItemBase log) @@ -134,6 +173,17 @@ namespace Tango.MachineStudio.Logging.ViewModels { InvokeUI(() => { + if (_is_debug) + { + if (_realTimeLogs.Count > 1000) + { + for (int i = 998; i < _realTimeLogs.Count; i++) + { + _realTimeLogs.RemoveAt(i); + } + } + } + _realTimeLogs.Insert(0, log); }); } @@ -166,14 +216,22 @@ namespace Tango.MachineStudio.Logging.ViewModels Logs = new ControlledObservableCollection<LogItemBase>(logs); } + + LogsViewSource = CollectionViewSource.GetDefaultView(Logs); } private void OnSelectedLogChanged() { - if (SelectedLog != null) + if (SelectedLog != null && !_dialog_shown) { - _notification.ShowModalDialog<LogDetailsViewVM, ApplicationLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); - SelectedLog = null; + _dialog_shown = true; + _notification.ShowModalDialog<LogDetailsViewVM, ApplicationLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => + { + + }, () => + { + _dialog_shown = false; + }); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs index 1895dd230..3f6775b75 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs @@ -21,6 +21,7 @@ namespace Tango.MachineStudio.Logging.ViewModels private EmbeddedLogFileParser _parser; private List<LogFile> _logFiles; private INotificationProvider _notification; + private bool _dialog_shown; private ControlledObservableCollection<LogItemBase> _realTimeLogs; private List<LogItemBase> _pausedLogs; @@ -172,10 +173,16 @@ namespace Tango.MachineStudio.Logging.ViewModels private void OnSelectedLogChanged() { - if (SelectedLog != null) + if (SelectedLog != null && !_dialog_shown) { - _notification.ShowModalDialog<LogDetailsViewVM, EmbeddedLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => { }, () => { }); - SelectedLog = null; + _dialog_shown = true; + _notification.ShowModalDialog<LogDetailsViewVM, EmbeddedLogDetailsView>(new LogDetailsViewVM(SelectedLog), (x) => + { + + }, () => + { + _dialog_shown = false; + }); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs index 98fcf12db..e2185bbdc 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -25,6 +25,7 @@ namespace Tango.MachineStudio.Logging.ViewModels private ObservableCollection<MachinesEvent> _realTimeEvents; private Machine _connectedMachine; private LoggingNavigationManager _navigation; + private bool _dialog_shown; private Machine _selectedMachine; public Machine SelectedMachine @@ -178,10 +179,16 @@ namespace Tango.MachineStudio.Logging.ViewModels private void OnSelectedEventChanged() { - if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted) + if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted && !_dialog_shown) { - _notification.ShowModalDialog<EventDetailsViewVM, EventDetailsView>(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { }); - SelectedEvent = null; + _dialog_shown = true; + _notification.ShowModalDialog<EventDetailsViewVM, EventDetailsView>(new EventDetailsViewVM(SelectedEvent), (x) => + { + + }, () => + { + _dialog_shown = false; + }); } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml index 3ca10f370..310f4fd87 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml @@ -99,6 +99,11 @@ <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">CLEAR</TextBlock> </StackPanel> </Button> + + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="30 0 0 0"> + <materialDesign:PackIcon Kind="Magnify" Width="24" Height="24" /> + <TextBox VerticalAlignment="Center" Margin="10 0 0 0" Width="200" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding RealTimePaused}" materialDesign:HintAssist.Hint="Filter" /> + </StackPanel> </StackPanel> </Grid> </Border> @@ -113,7 +118,7 @@ <Grid> <Grid> <Grid> - <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> + <DataGrid x:Name="grid" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" SelectedCellsChanged="grid_SelectedCellsChanged" ItemsSource="{Binding LogsViewSource}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> <DataGrid.RowStyle> <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> <Style.Triggers> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs index 6cdf6ea53..234fdfeab 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs @@ -24,5 +24,15 @@ namespace Tango.MachineStudio.Logging.Views { InitializeComponent(); } + + private void DataGrid_Selected(object sender, RoutedEventArgs e) + { + + } + + private void grid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) + { + grid.SelectedIndex = -1; + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml index ba6330f77..4573c8451 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml @@ -113,7 +113,7 @@ <Grid> <Grid> <Grid> - <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> + <DataGrid x:Name="grid" SelectedCellsChanged="grid_SelectedCellsChanged" Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> <DataGrid.RowStyle> <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> <Style.Triggers> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml.cs index a728650cd..bc897cc82 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml.cs @@ -24,5 +24,10 @@ namespace Tango.MachineStudio.Logging.Views { InitializeComponent(); } + + private void grid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) + { + grid.SelectedIndex = -1; + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml index 9fe9e084e..196b6f930 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml @@ -121,7 +121,7 @@ <Grid> <Grid> <Grid> - <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Events}" SelectedItem="{Binding SelectedEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> + <DataGrid x:Name="grid" SelectedCellsChanged="grid_SelectedCellsChanged" Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Events}" SelectedItem="{Binding SelectedEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> <DataGrid.RowStyle> <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> <Style.Triggers> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml.cs index b17eea54c..83710f1c9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml.cs @@ -24,5 +24,10 @@ namespace Tango.MachineStudio.Logging.Views { InitializeComponent(); } + + private void grid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) + { + grid.SelectedIndex = -1; + } } } |
