diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-16 17:45:25 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-16 17:45:25 +0300 |
| commit | e66cd269ad02302f2a5a4ec377112cd61789647e (patch) | |
| tree | 3f229e2460a16e3b3383cb39e7458a19469553d2 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 53f93d7fd2d2aa4571bad6e93e0c519fce242753 (diff) | |
| download | Tango-e66cd269ad02302f2a5a4ec377112cd61789647e.tar.gz Tango-e66cd269ad02302f2a5a4ec377112cd61789647e.zip | |
Application Logs & Embedded Logs on Logging Module!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
12 files changed, 567 insertions, 19 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ControlledObservableCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ControlledObservableCollection.cs new file mode 100644 index 000000000..e16393e83 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ControlledObservableCollection.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Logging +{ + public class ControlledObservableCollection<T> : ObservableCollection<T> + { + public bool DisableNotification { get; set; } + + public ControlledObservableCollection() : base() + { + + } + + public ControlledObservableCollection(IEnumerable<T> collection) : base(collection) + { + + } + + protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) + { + if (!DisableNotification) + { + base.OnCollectionChanged(e); + } + } + + public void AddRange(IEnumerable<T> collection) + { + foreach (var item in collection) + { + Add(item); + } + } + + public void InsertRange(int index, IEnumerable<T> collection) + { + foreach (var item in collection) + { + Insert(index, item); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs index d082aeca6..64f1913fb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs @@ -10,13 +10,17 @@ using Tango.Logging; namespace Tango.MachineStudio.Logging.Parsing { - public class ApplicationLogFileParser : ILogFileParser<MessageLogItem> + public class ApplicationLogFileParser : ILogFileParser<LogItemBase> { public List<LogFile> GetLogFiles() { List<LogFile> logFiles = new List<LogFile>(); - foreach (var file in Directory.GetFiles(FileLogger.DefaultLogsFolder, "*.log").Where(x => Path.GetFileName(x).StartsWith("Tango.MachineStudio.UI"))) + FileLogger logger = LogManager.Default.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger; + + String logFile = logger != null ? logger.LogFile : null; + + foreach (var file in Directory.GetFiles(FileLogger.DefaultLogsFolder, "*.log").Where(x => Path.GetFileName(x).StartsWith("Tango.MachineStudio.UI") && x != logger.LogFile)) { String dateString = Path.GetFileNameWithoutExtension(file).Replace("Tango.MachineStudio.UI-", ""); DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture); @@ -26,9 +30,9 @@ namespace Tango.MachineStudio.Logging.Parsing return logFiles; } - public List<MessageLogItem> Parse(LogFile logFile) + public List<LogItemBase> Parse(LogFile logFile) { - List<MessageLogItem> logItems = new List<MessageLogItem>(); + List<LogItemBase> logItems = new List<LogItemBase>(); String text = File.ReadAllText(logFile.File); var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])"); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs index 76ca0d162..1a6fcc051 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs @@ -18,7 +18,11 @@ namespace Tango.MachineStudio.Logging.Parsing { List<LogFile> logFiles = new List<LogFile>(); - foreach (var file in Directory.GetFiles(SettingsManager.DefaultFolder + "\\embedded logs", "*.log").Where(x => Path.GetFileName(x).StartsWith("embedded"))) + FileLogger logger = MachineOperator.EmbeddedLogManager.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger; + + String logFile = logger != null ? logger.LogFile : null; + + foreach (var file in Directory.GetFiles(SettingsManager.DefaultFolder + "\\embedded logs", "*.log").Where(x => Path.GetFileName(x).StartsWith("embedded") && x != logFile)) { String dateString = Path.GetFileNameWithoutExtension(file).Replace("embedded-", ""); DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj index 42229544a..8d5b12d73 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj @@ -81,6 +81,7 @@ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="ControlledObservableCollection.cs" /> <Compile Include="Controls\TimelineScrollViewer.cs" /> <Compile Include="Controls\TimeRuler.cs" /> <Compile Include="Converters\DateIsInListToBooleanConverter.cs" /> @@ -98,12 +99,16 @@ <Compile Include="Parsing\ILogFileParser.cs" /> <Compile Include="Parsing\LogFile.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\EmbeddedLogsViewVM.cs" /> <Compile Include="ViewModels\ApplicationLogsViewVM.cs" /> <Compile Include="ViewModels\EventDetailsViewVM.cs" /> <Compile Include="ViewModels\HomeViewVM.cs" /> <Compile Include="ViewModels\EventsViewVM.cs" /> <Compile Include="ViewModels\TimelineEventGroup.cs" /> <Compile Include="ViewModels\TimelineViewVM.cs" /> + <Compile Include="Views\EmbeddedLogsView.xaml.cs"> + <DependentUpon>EmbeddedLogsView.xaml</DependentUpon> + </Compile> <Compile Include="Views\EventDetailsView.xaml.cs"> <DependentUpon>EventDetailsView.xaml</DependentUpon> </Compile> @@ -197,6 +202,10 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <Page Include="Views\EmbeddedLogsView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\EventDetailsView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs index 0b1af937f..b3c16c2b4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs @@ -20,6 +20,7 @@ namespace Tango.MachineStudio.Logging ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); SimpleIoc.Default.Register<EventsViewVM>(); SimpleIoc.Default.Register<ApplicationLogsViewVM>(); + SimpleIoc.Default.Register<EmbeddedLogsViewVM>(); SimpleIoc.Default.Register<HomeViewVM>(); SimpleIoc.Default.Unregister<LoggingNavigationManager>(); @@ -42,6 +43,14 @@ namespace Tango.MachineStudio.Logging } } + public static EmbeddedLogsViewVM EmbeddedLogsViewVM + { + get + { + return ServiceLocator.Current.GetInstance<EmbeddedLogsViewVM>(); + } + } + public static HomeViewVM HomeViewVM { get 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 8ddc544c0..d51607004 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 @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Logging.Navigation; using Tango.MachineStudio.Logging.Parsing; using Tango.SharedUI; @@ -16,9 +17,13 @@ namespace Tango.MachineStudio.Logging.ViewModels { private ApplicationLogFileParser _parser; private List<LogFile> _logFiles; + private INotificationProvider _notification; - private ObservableCollection<MessageLogItem> _logs; - public ObservableCollection<MessageLogItem> Logs + private ControlledObservableCollection<LogItemBase> _realTimeLogs; + private List<LogItemBase> _pausedLogs; + + private ControlledObservableCollection<LogItemBase> _logs; + public ControlledObservableCollection<LogItemBase> Logs { get { return _logs; } set { _logs = value; RaisePropertyChangedAuto(); } @@ -60,10 +65,31 @@ namespace Tango.MachineStudio.Logging.ViewModels set { _isRealTime = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); } } + private bool _realTimePaused; + public bool RealTimePaused + { + get { return _realTimePaused; } + set + { + _realTimePaused = value; + RaisePropertyChangedAuto(); + + if (!_realTimePaused) + { + _realTimeLogs.InsertRange(0, _pausedLogs); + _pausedLogs.Clear(); + } + } + } + public RelayCommand NavigateToHomeCommand { get; set; } - public ApplicationLogsViewVM(LoggingNavigationManager navigation) + public RelayCommand ToggleRealTimePaused { get; set; } + + public ApplicationLogsViewVM(LoggingNavigationManager navigation, INotificationProvider notification) { + _notification = notification; + NavigateToHomeCommand = new RelayCommand(() => navigation.NavigateTo(LoggingNavigationView.HomeView)); _parser = new ApplicationLogFileParser(); @@ -71,28 +97,59 @@ namespace Tango.MachineStudio.Logging.ViewModels _logFiles = _parser.GetLogFiles(); Dates = new ObservableCollection<DateTime>(_logFiles.Select(x => x.DateTime).OrderBy(x => x)); + _realTimeLogs = new ControlledObservableCollection<LogItemBase>(); + _pausedLogs = new List<LogItemBase>(); + + IsRealTime = true; + RealTimePaused = true; + SelectedDate = Dates.Last(); MinDate = Dates.Min(); MaxDate = Dates.Max(); + + LogManager.NewLog += LogManager_NewLog; + + ToggleRealTimePaused = new RelayCommand(() => RealTimePaused = !RealTimePaused); + } + + private void LogManager_NewLog(object sender, LogItemBase log) + { + if (!RealTimePaused) + { + InvokeUI(() => + { + _realTimeLogs.Insert(0, log); + }); + } + else + { + _pausedLogs.Add(log); + } } - private void OnSelectedDateChanged() + private async void OnSelectedDateChanged() { if (IsRealTime) { - //Events = _realTimeEvents; + Logs = _realTimeLogs; } else { - List<MessageLogItem> logs = new List<MessageLogItem>(); + List<LogItemBase> logs = new List<LogItemBase>(); - foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date)) + using (_notification.PushTaskItem("Loading application logs...")) { - logs.AddRange(_parser.Parse(logFile)); + await Task.Factory.StartNew(() => + { + foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date)) + { + logs.AddRange(_parser.Parse(logFile)); + } + }); } - Logs = logs.ToObservableCollection(); + Logs = new ControlledObservableCollection<LogItemBase>(logs); } } } 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 new file mode 100644 index 000000000..126f61402 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EmbeddedLogsViewVM.cs @@ -0,0 +1,158 @@ +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.Integration.Operation; +using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Logging.Navigation; +using Tango.MachineStudio.Logging.Parsing; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Logging.ViewModels +{ + public class EmbeddedLogsViewVM : ViewModel + { + private EmbeddedLogFileParser _parser; + private List<LogFile> _logFiles; + private INotificationProvider _notification; + + private ControlledObservableCollection<LogItemBase> _realTimeLogs; + private List<LogItemBase> _pausedLogs; + + private ControlledObservableCollection<LogItemBase> _logs; + public ControlledObservableCollection<LogItemBase> 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(); } + } + + private bool _realTimePaused; + public bool RealTimePaused + { + get { return _realTimePaused; } + set + { + _realTimePaused = value; + RaisePropertyChangedAuto(); + + if (!_realTimePaused) + { + _realTimeLogs.InsertRange(0, _pausedLogs); + _pausedLogs.Clear(); + } + } + } + + public RelayCommand NavigateToHomeCommand { get; set; } + + public RelayCommand ToggleRealTimePaused { get; set; } + + public EmbeddedLogsViewVM(LoggingNavigationManager navigation, IStudioApplicationManager application, INotificationProvider notification) + { + _notification = notification; + + NavigateToHomeCommand = new RelayCommand(() => navigation.NavigateTo(LoggingNavigationView.HomeView)); + + _parser = new EmbeddedLogFileParser(); + + _logFiles = _parser.GetLogFiles(); + Dates = new ObservableCollection<DateTime>(_logFiles.Select(x => x.DateTime).OrderBy(x => x)); + + _realTimeLogs = new ControlledObservableCollection<LogItemBase>(); + _pausedLogs = new List<LogItemBase>(); + + IsRealTime = true; + RealTimePaused = true; + + SelectedDate = Dates.Last(); + + MinDate = Dates.Min(); + MaxDate = Dates.Max(); + + MachineOperator.EmbeddedLogManager.NewLog += EmbeddedLogManager_NewLog; + + ToggleRealTimePaused = new RelayCommand(() => RealTimePaused = !RealTimePaused); + } + + private void EmbeddedLogManager_NewLog(object sender, LogItemBase log) + { + if (!RealTimePaused) + { + InvokeUI(() => + { + _realTimeLogs.Insert(0, log); + }); + } + else + { + _pausedLogs.Add(log); + } + } + + private async void OnSelectedDateChanged() + { + if (IsRealTime) + { + Logs = _realTimeLogs; + } + else + { + List<LogItemBase> logs = new List<LogItemBase>(); + + using (_notification.PushTaskItem("Loading embedded device logs...")) + { + await Task.Factory.StartNew(() => + { + foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date)) + { + logs.AddRange(_parser.Parse(logFile)); + } + }); + } + + Logs = new ControlledObservableCollection<LogItemBase>(logs); + } + } + } +} 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 1274f6523..b8f464e5f 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 @@ -56,9 +56,9 @@ </Border.Effect> <Grid> <StackPanel Orientation="Horizontal"> - <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left"> + <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Foreground="#202020" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left"> <StackPanel Orientation="Horizontal" > - <materialDesign:PackIcon Kind="KeyboardBackspace" Width="20" Height="20" /> + <materialDesign:PackIcon Kind="ArrowLeftBold" Width="20" Height="20" /> <TextBlock Margin="5 0 0 0" FontSize="16">BACK</TextBlock> </StackPanel> </Button> @@ -77,6 +77,21 @@ <TextBlock VerticalAlignment="Center" Margin="10 17 0 0">Real-Time</TextBlock> </StackPanel> </Border> + + <Button Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding ToggleRealTimePaused}" Padding="0" Height="50" Width="50" Foreground="#202020" ToolTip="Pause/Resume Real-Time"> + <materialDesign:PackIcon Width="50" Height="50"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="Pause"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RealTimePaused}" Value="True"> + <Setter Property="Kind" Value="Play"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </Button> </StackPanel> </Grid> </Border> @@ -173,7 +188,7 @@ </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> - <DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,Converter={StaticResource DateTimeUTCToStringConverter},ConverterParameter='MM/dd/yyyy HH:mm:ss.ff'}" /> + <DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat='MM/dd/yyyy HH:mm:ss.ff'}" /> <DataGridTextColumn Header="FILE" Binding="{Binding CallerFile}" /> <DataGridTextColumn Header="METHOD" Binding="{Binding CallerMethodName}" /> <DataGridTextColumn Header="LINE" Binding="{Binding CallerLineNumber}" /> 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 new file mode 100644 index 000000000..afd5b9a98 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml @@ -0,0 +1,212 @@ +<UserControl x:Class="Tango.MachineStudio.Logging.Views.EmbeddedLogsView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.MachineStudio.Logging" + xmlns:localConverters="clr-namespace:Tango.MachineStudio.Logging.Converters" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.Logging.ViewModels" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.MachineStudio.Logging.Views" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:EmbeddedLogsViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.EmbeddedLogsViewVM}"> + <UserControl.Resources> + <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" /> + <converters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" /> + <converters:DateTimeUTCToStringConverter x:Key="DateTimeUTCToStringConverter" /> + <localConverters:DateIsInListToBooleanConverter x:Key="DateIsInListToBooleanConverter" /> + + <Style x:Key="CustomCalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}" BasedOn="{StaticResource MaterialDesignCalendarDayButton}"> + <Style.Triggers> + <DataTrigger Value="True"> + <DataTrigger.Binding> + <MultiBinding Converter="{StaticResource DateIsInListToBooleanConverter}"> + <Binding /> + <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.Dates" /> + <Binding RelativeSource="{RelativeSource AncestorType=DatePicker}" Path="IsDropDownOpen" ></Binding> + </MultiBinding> + </DataTrigger.Binding> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </DataTrigger> + </Style.Triggers> + </Style> + + <Style x:Key="HighlightDatePickerStyle" TargetType="{x:Type Calendar}" BasedOn="{StaticResource {x:Type Calendar}}"> + <Setter Property="CalendarDayButtonStyle" Value="{StaticResource CustomCalendarDayButtonStyle}" /> + </Style> + + <Style TargetType="DatePickerTextBox" BasedOn="{StaticResource {x:Type DatePickerTextBox}}"> + <Setter Property="IsReadOnly" Value="True"/> + </Style> + </UserControl.Resources> + + <Grid> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="79"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Background="#F1F1F1"> + <Border.Effect> + <DropShadowEffect /> + </Border.Effect> + <Grid> + <StackPanel Orientation="Horizontal"> + <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Foreground="#202020" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left"> + <StackPanel Orientation="Horizontal" > + <materialDesign:PackIcon Kind="ArrowLeftBold" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">BACK</TextBlock> + </StackPanel> + </Button> + <Border Margin="10" Padding="5" BorderBrush="DimGray" BorderThickness="1"> + <Border.Background> + <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> + <GradientStop Color="White"/> + <GradientStop Color="#FFEAEAEA" Offset="1"/> + </LinearGradientBrush> + </Border.Background> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Calendar" Width="24" Height="24" VerticalAlignment="Bottom" Margin="0 0 0 5" /> + <DatePicker x:Name="datePicker" DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" CalendarStyle="{StaticResource HighlightDatePickerStyle}" SelectedDate="{Binding SelectedDate}" materialDesign:HintAssist.Hint="Pick Date" Margin="10 0 0 5" Width="200" VerticalAlignment="Bottom" FontSize="16"> + </DatePicker> + <ToggleButton VerticalAlignment="Bottom" Margin="20 0 0 5" IsChecked="{Binding IsRealTime}"></ToggleButton> + <TextBlock VerticalAlignment="Center" Margin="10 17 0 0">Real-Time</TextBlock> + </StackPanel> + </Border> + + <Button Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding ToggleRealTimePaused}" Padding="0" Height="50" Width="50" Foreground="#202020" ToolTip="Pause/Resume Real-Time"> + <materialDesign:PackIcon Width="50" Height="50"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="Pause"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RealTimePaused}" Value="True"> + <Setter Property="Kind" Value="Play"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </Button> + </StackPanel> + </Grid> + </Border> + + <Grid Grid.Row="1" Background="#B3FFFFFF"> + <Grid Margin="10"> + <Grid.ColumnDefinitions> + + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <Grid> + <Grid> + <Grid> + <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Logs}" 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> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + <Setter Property="Cursor" Value="Hand"></Setter> + </Trigger> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + <Trigger Property="IsFocused" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + <!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> + <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="Foreground" Value="White" /> + <Setter Property="FontWeight" Value="SemiBold"></Setter> + <Setter Property="Cursor" Value="Arrow"></Setter> + </DataTrigger>--> + </Style.Triggers> + </Style> + </DataGrid.RowStyle> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + <!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> + <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="Foreground" Value="White" /> + <Setter Property="FontWeight" Value="SemiBold"></Setter> + <Setter Property="Cursor" Value="Arrow"></Setter> + </DataTrigger>--> + </Style.Triggers> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="#"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <materialDesign:PackIcon Width="16" Height="16"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="Alert"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Category}" Value="Info"> + <Setter Property="Kind" Value="Information"></Setter> + <Setter Property="Foreground" Value="DimGray"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Warning"> + <Setter Property="Kind" Value="Alert"></Setter> + <Setter Property="Foreground" Value="#FFA300"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Error"> + <Setter Property="Kind" Value="AlertOctagon"></Setter> + <Setter Property="Foreground" Value="#FF5C5C"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Critical"> + <Setter Property="Kind" Value="BellPlus"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Debug"> + <Setter Property="Kind" Value="Bug"></Setter> + <Setter Property="Foreground" Value="#303030"></Setter> + </DataTrigger> + <!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> + <Setter Property="Kind" Value="ClockFast"></Setter> + <Setter Property="Foreground" Value="White"></Setter> + </DataTrigger>--> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat='MM/dd/yyyy HH:mm:ss.ff'}" /> + <DataGridTextColumn Header="FILE" Binding="{Binding DebugLogResponse.FileName}" /> + <DataGridTextColumn Header="LINE" Binding="{Binding DebugLogResponse.LineNumber}" /> + <DataGridTextColumn Header="MODULE" Binding="{Binding DebugLogResponse.ModuleId}" /> + <DataGridTextColumn Header="FILTER" Binding="{Binding DebugLogResponse.Filter}" /> + <DataGridTemplateColumn Header="MESSAGE" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Message}" TextTrimming="CharacterEllipsis"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </Grid> + </Grid> + </Grid> + </Grid> + </Grid> + </Grid> + </Grid> +</UserControl> 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 new file mode 100644 index 000000000..a728650cd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EmbeddedLogsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Logging.Views +{ + /// <summary> + /// Interaction logic for EventsView.xaml + /// </summary> + public partial class EmbeddedLogsView : UserControl + { + public EmbeddedLogsView() + { + InitializeComponent(); + } + } +} 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 3089ad610..9fe9e084e 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 @@ -56,9 +56,9 @@ </Border.Effect> <Grid> <StackPanel Orientation="Horizontal"> - <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left"> + <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Foreground="#202020" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left"> <StackPanel Orientation="Horizontal" > - <materialDesign:PackIcon Kind="KeyboardBackspace" Width="20" Height="20" /> + <materialDesign:PackIcon Kind="ArrowLeftBold" Width="20" Height="20" /> <TextBlock Margin="5 0 0 0" FontSize="16">BACK</TextBlock> </StackPanel> </Button> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml index b6ac29893..bf1bc8778 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml @@ -24,6 +24,9 @@ <ContentControl Tag="ApplicationLogsView"> <local:ApplicationLogsView/> </ContentControl> + <ContentControl Tag="EmbeddedLogsView"> + <local:EmbeddedLogsView/> + </ContentControl> <ContentControl Tag="EventsView"> <local:EventsView/> </ContentControl> |
