diff options
10 files changed, 420 insertions, 362 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/LogFile.cs b/Software/Visual_Studio/Tango.Logging/LogFile.cs index 24a8a11f2..c86ec1792 100644 --- a/Software/Visual_Studio/Tango.Logging/LogFile.cs +++ b/Software/Visual_Studio/Tango.Logging/LogFile.cs @@ -8,14 +8,35 @@ namespace Tango.Logging { public class LogFile { + /// <summary> + /// Gets or sets the date time started Log file. + /// </summary> public DateTime DateTime { get; set; } + /// <summary> + /// Gets or sets the full path of file. + /// </summary> public String File { get; set; } + /// <summary> + /// Gets or sets the name of the file. + /// </summary> + public String FileName { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether set of files + /// </summary> public bool PartOfSet { get; set; } + + /// <summary> + /// Gets or sets the start index of the set. + /// </summary> public int SetStartIndex { get; set; } + /// <summary> + /// Gets or sets the set count of set. + /// </summary> public int SetCount { get; set; } } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs index 504d79aeb..ee4fad4d4 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs @@ -33,7 +33,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers if (index % 2 == 1)//testing Flow-error { - List<DispenserSample> filteredValues = rangeTestValues.Skip(4800).ToList(); + List<DispenserSample> filteredValues = rangeTestValues.Skip(5000).ToList(); // Move Average data List<Task> tasks = new List<Task>(); int calc_count = (int)filteredValues.Count() / 4; @@ -54,23 +54,23 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers Task.WaitAll(tasks.ToArray()); //calculate difference Max Min values for each 250 values - var rangeItems = rangeTestValues.Select((x, i) => new { x, i }).GroupBy(p => (p.i / 250)).Select(x => x.Select(v => v.x).ToList()); + var rangeItems = filteredValues.Select((x, i) => new { x, i }).GroupBy(p => (p.i / 250)).Select(x => x.Select(v => v.x).ToList()); var differenceMaxMin = rangeItems.Select(x => x.Max(t => t.Pressure) - x.Min(t => t.Pressure)).ToList(); FlowAnalyzerResult result = new FlowAnalyzerResult(); - result.AverageValue = rangeTestValues.Average(t => t.Pressure); - result.MinValue = rangeTestValues.Min(t => t.Pressure); - result.MaxValue = rangeTestValues.Max(t => t.Pressure); - result.TotalValue = result.AverageValue == 0 ? 0 : (result.MaxValue - result.MinValue) * 100 / result.AverageValue; + result.AverageValue = filteredValues.Average(t => t.Pressure); + //result.MinValue = rangeTestValues.Min(t => t.Pressure); + //result.MaxValue = rangeTestValues.Max(t => t.Pressure); + //result.TotalValue = result.AverageValue == 0 ? 0 : (result.MaxValue - result.MinValue) * 100 / result.AverageValue; //local test - List<DispenserSample> filterTestValues = rangeTestValues.Skip(10000).Take(1000).ToList(); - result.FilterAverageValue = filterTestValues.Average(t => t.Pressure); - result.FilterMinValue = filterTestValues.Min(t => t.Pressure); - result.FilterMaxValue = filterTestValues.Max(t => t.Pressure); - result.FilterTotalValue = result.FilterAverageValue == 0 ? 0 : (result.FilterMaxValue - result.FilterMinValue) * 100 / result.FilterAverageValue; + //List<DispenserSample> filterTestValues = rangeTestValues.Skip(10000).Take(1000).ToList(); + //result.FilterAverageValue = filterTestValues.Average(t => t.Pressure); + //result.FilterMinValue = filterTestValues.Min(t => t.Pressure); + //result.FilterMaxValue = filterTestValues.Max(t => t.Pressure); + //result.FilterTotalValue = result.FilterAverageValue == 0 ? 0 : (result.FilterMaxValue - result.FilterMinValue) * 100 / result.FilterAverageValue; - result.Result = (result.FilterTotalValue <= 1.5 && result.TotalValue <= 3) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed; + //result.Result = (result.FilterTotalValue <= 1.5 && result.TotalValue <= 3) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed; result.SetLocalErrors(differenceMaxMin); results.Add(result); @@ -95,54 +95,55 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers [Description("Average Value")] public double AverageValue { get; set; } - [Description("Max Value")] - public double MaxValue { get; set; } + //[Description("Max Value")] + //public double MaxValue { get; set; } - [Description("Min Value")] - public double MinValue { get; set; } + //[Description("Min Value")] + //public double MinValue { get; set; } - [Description("Total Value Peak to peak")] - public double TotalValue { get; set; } + //[Description("Total Value Peak to peak")] + //public double TotalValue { get; set; } - [Description("Local Average Value")] - public double FilterAverageValue { get; set; } + //[Description("Local Average Value")] + //public double FilterAverageValue { get; set; } - [Description("Local Max Value")] - public double FilterMaxValue { get; set; } + //[Description("Local Max Value")] + //public double FilterMaxValue { get; set; } - [Description("Local Min Value")] - public double FilterMinValue { get; set; } + //[Description("Local Min Value")] + //public double FilterMinValue { get; set; } - [Description("Local Total Value Peak to peak")] - public double FilterTotalValue { get; set; } + //[Description("Local Total Value Peak to peak")] + //public double FilterTotalValue { get; set; } [Description("Errors under 15")] public string LocalErrorsUnder15 { get; set; } - [Description("Errors under 20")] + [Description("Errors greater than or equal to 15 and less than 20")] public string LocalErrorsUnder20 { get; set; } - [Description("Errors under 25")] + [Description("Errors greater than or equal to 20 and less than 25")] public string LocalErrorsUnder25 { get; set; } - [Description("Errors under 30")] + [Description("Errors greater than or equal to 25 and less than 30")] public string LocalErrorsUnder30 { get; set; } public FlowAnalyzerResult() { - AverageValue = MaxValue = MinValue = TotalValue = FilterAverageValue = FilterMaxValue = FilterMinValue = FilterTotalValue = 0.0; + // AverageValue = MaxValue = MinValue = TotalValue = FilterAverageValue = FilterMaxValue = FilterMinValue = FilterTotalValue = 0.0; + AverageValue = 0.0; Result = AnalyzerResultValue.Undetermined; } public void SetLocalErrors(List<double> differenceMaxMin) { - int count = differenceMaxMin.Where(x => x <= 15).Count(); + int count = differenceMaxMin.Where(x => x < 15).Count(); LocalErrorsUnder15 = (count > 10 ? "multiple" : count.ToString()); - count = differenceMaxMin.Where(x => x <= 20 && x > 15).Count(); + count = differenceMaxMin.Where(x => x < 20 && x >= 15).Count(); LocalErrorsUnder20 = (count > 10 ? "multiple" : count.ToString()); - count = differenceMaxMin.Where(x => x <= 25 && x > 20).Count(); + count = differenceMaxMin.Where(x => x < 25 && x >= 20).Count(); LocalErrorsUnder25 = (count > 10 ? "multiple" : count.ToString()); - count = differenceMaxMin.Where(x => x <= 30 && x > 25).Count(); + count = differenceMaxMin.Where(x => x< 30 && x >= 25).Count(); LocalErrorsUnder30 = (count > 10 ? "multiple" : count.ToString()); } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj index 74ed4a4a5..9c37b8d10 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj @@ -20,7 +20,7 @@ <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> + <OutputPath>..\..\Build\DispenserAnalyzer\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> @@ -29,7 +29,7 @@ <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> + <OutputPath>..\..\Build\DispenserAnalyzer\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/App.config b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/App.config index f9370449f..bafe24888 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/App.config +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/App.config @@ -49,6 +49,14 @@ <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> </assemblyBinding> </runtime> </configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs index 93d856b2e..1a43a7eff 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerFileParser/ApplicationLogViewerParser.cs @@ -21,28 +21,33 @@ namespace Tango.LogViewer.UI.LogViewerFileParser String text = File.ReadAllText(file); var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])"); + String logText = String.Empty; + for (int i = 1; i < logs.Length; i += 2) { try { DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture); - String rest = logs[i + 1]; - var entries = Regex.Split(rest, @"\[(.*?)\]"); + logText = logs[i + 1]; + var matches = Regex.Matches(logText, @"(?<=\[)(.*?)(?=\])"); MessageLogItem item = new MessageLogItem(); item.TimeStamp = new DateTime(datetime.Year, datetime.Month, datetime.Day, date.Hour, date.Minute, date.Second, date.Millisecond); - item.Category = (LogCategory)Enum.Parse(typeof(LogCategory), entries[1]); - item.CallerFile = entries[3]; - item.CallerMethodName = entries[5]; - item.CallerLineNumber = int.Parse(entries[7]); - item.Message = new String(entries[8].Skip(2).ToArray()); + item.Category = (LogCategory)Enum.Parse(typeof(LogCategory), matches[0].ToString()); + item.CallerFile = matches[1].ToString(); + item.CallerMethodName = matches[2].ToString(); + item.CallerLineNumber = int.Parse(matches[3].ToString()); + + int messageStartIndex = matches[3].Index + matches[3].Length + 2; + + item.Message = logText.Substring(messageStartIndex, logText.Length - messageStartIndex); logItems.Add(item); } catch (Exception ex) { - //LogManager.Default.Log(ex, "Could not parse log line: " + logs[i]); + LogManager.Default.Log(ex, "Could not parse log line: " + logText); } } } diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerManager.cs b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerManager.cs index 6c5a68d1a..e7be4797f 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerManager.cs +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/LogViewerManager.cs @@ -6,36 +6,43 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Logging; +using Tango.LogViewer.UI.LogViewerFileParser; namespace Tango.LogViewer.UI { public class LogViewerManager { - public static List<LogFile> LogFiles { get; set; } + private ILogViewerParser _parser; - static LogViewerManager() + public LogFile LogFile { get; set; } + + public string FileName { get; set; } + + public bool IsEmbeddedLog { get; set; } + + public int CountOfSet { get; set; } + + public LogViewerManager() { - LogFiles = new List<LogFile>(); + LogFile = null; ; } /// <summary> - /// Static member to create list of LogFiles by given path. + /// Create LogFile by given path. /// </summary> /// <param name="file">The file.</param> - public static void InitLogFile(String file) + public void InitLogFile(String file) { - LogFiles.Clear(); - LogFiles = GetLogFiles(file); + LogFile = GetLogFile(file); } /// <summary> /// Gets set of log files by path. /// </summary> - public static List<LogFile> GetLogFiles(string filePath) + public LogFile GetLogFile(string filePath) { - List<LogFile> logFiles = new List<LogFile>(); if (!File.Exists(filePath)) - return logFiles; + return null; var directoryName = Path.GetDirectoryName(filePath); var logfileName = Path.GetFileNameWithoutExtension(filePath); @@ -51,33 +58,72 @@ namespace Tango.LogViewer.UI logfileName = logfileName.Substring(0, indexPos); } - HashSet<string> dateStrings = new HashSet<string>(); - foreach (var file in Directory.GetFiles(directoryName, "*.log").Where(x => (Path.GetFileName(x).StartsWith(logfileName)))) + try { - try + String dateString = System.IO.Path.GetFileNameWithoutExtension(filePath).Replace($"{fileName}-", ""); + indexPos = dateString.IndexOf(FileLogger.FILE_SET_EXTENSION); + int indexOfFile = 0; + CountOfSet = 0; + if (indexPos > 0) { - String dateString = System.IO.Path.GetFileNameWithoutExtension(file).Replace($"{fileName}-", ""); - indexPos = dateString.IndexOf(FileLogger.FILE_SET_EXTENSION); - int indexOfFile = 0; - if (indexPos > 0) - { - string fileNameIndex = dateString.Substring(indexPos + FileLogger.FILE_SET_EXTENSION.Length); - int.TryParse(fileNameIndex, out indexOfFile); - dateString = dateString.Substring(0, indexPos); - } - if (!dateStrings.Contains(dateString)) - { - dateStrings.Add(dateString); - DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture); - logFiles.Add(new LogFile() { DateTime = date, File = file, PartOfSet = indexOfFile > 0, }); - } + string fileNameIndex = dateString.Substring(indexPos + FileLogger.FILE_SET_EXTENSION.Length); + string[] fileEntries = Directory.GetFiles(directoryName, $"{logfileName}*{Path.GetExtension(filePath)}").Where(x => Path.GetFileName(x).StartsWith(logfileName)).OrderBy(x => x).ToArray(); + CountOfSet = fileEntries.Length; + int.TryParse(fileNameIndex, out indexOfFile); + dateString = dateString.Substring(0, indexPos); } - catch (Exception ex) - { + DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture); + return (new LogFile() { DateTime = date, File = filePath, FileName= logfileName, PartOfSet = indexOfFile > 0, SetStartIndex = indexOfFile, SetCount = CountOfSet }); + } + catch (Exception ex) + { + + } + + return null; + } + + /// <summary> + /// Parses the this LogFile. + /// </summary> + public List<LogItemBase> Parse() + { + IsEmbeddedLog = false; + FileName = ""; + List<LogItemBase> logItems = new List<LogItemBase>(); + if (LogFile == null) + return logItems; + + FileName = LogFile.FileName; + + IsEmbeddedLog = FileName.StartsWith("Embedded"); + if (IsEmbeddedLog) + { + _parser = new EmbeddedLogViewerParser(); + } + else + { + _parser = new ApplicationLogViewerParser(); + } + if (LogFile.PartOfSet) + { + string extension = Path.GetExtension(LogFile.File); + var directoryName = Path.GetDirectoryName(LogFile.File); + + string[] fileEntries = Directory.GetFiles(directoryName, $"{FileName}*{extension}").Where(x => Path.GetFileName(x).StartsWith(FileName)).OrderBy(x => x).ToArray(); + + foreach (var file in fileEntries) + { + _parser.Parse(file, LogFile.DateTime, ref logItems); } } - return logFiles; + else + { + _parser.Parse(LogFile.File, LogFile.DateTime, ref logItems); + } + + return logItems; } } } diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/MainWindow.xaml index d1492c513..a46f404fb 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/MainWindow.xaml @@ -14,6 +14,159 @@ <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"></converters:EnumToDescriptionConverter> <converters:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/> <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter"/> + + <SolidColorBrush x:Key="GrayBrush5" Color="#464646"/> + <SolidColorBrush x:Key="BorderGrayBrush" Color="#464646"/> + <SolidColorBrush x:Key="SelectedItemBrush" Color="#007ACC"/> + + <Style x:Key="LogDataGridCellStyle" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="VerticalAlignment" Value="Center"/> + <Setter Property="TextBlock.VerticalAlignment" Value="Center" /> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type DataGridCell}"> + <Grid Background="{TemplateBinding Background}"> + <ContentPresenter VerticalAlignment="Bottom" /> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" /> + </Trigger> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="IsFocused" Value="False" /> + <Condition Property="DataGridCell.IsSelected" Value="True" /> + </MultiTrigger.Conditions> + <MultiTrigger.Setters> + <Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" /> + </MultiTrigger.Setters> + </MultiTrigger> + </Style.Triggers> + </Style> + + <Style x:Key="LogDataGridRowStyle" TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Style.Triggers> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" /> + <Setter Property="Cursor" Value="Hand"></Setter> + </Trigger> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" /> + </Trigger> + <Trigger Property="IsFocused" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> + <Setter Property="Background" Value="#3F3F49"></Setter> + <Setter Property="Foreground" Value="White" /> + <Setter Property="FontWeight" Value="SemiBold"></Setter> + <Setter Property="Cursor" Value="Arrow"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding LogObject}" Value="External Bridge"> + <Setter Property="Foreground" Value="#28A805" /> + </DataTrigger> + </Style.Triggers> + </Style> + + <Style x:Key="EmLogDataGridRowStyle" TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Style.Triggers> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" /> + <Setter Property="Cursor" Value="Hand"></Setter> + </Trigger> + <Trigger Property="DataGridCell.IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" /> + </Trigger> + <Trigger Property="IsFocused" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + + <DataTrigger Binding="{Binding LogObject}" Value="External Bridge"> + <Setter Property="Foreground" Value="#28A805" /> + </DataTrigger> + </Style.Triggers> + </Style> + + <DataTemplate x:Key="EmIconStyle"> + <fa:ImageAwesome Width="14" Height="16" Margin="0 0 0 0" VerticalAlignment="Top"> + <fa:ImageAwesome.Style> + <Style TargetType="fa:ImageAwesome"> + <Setter Property="Icon" Value="ExclamationTriangle"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Category}" Value="Info"> + <Setter Property="Icon" Value="InfoCircle"></Setter> + <Setter Property="Foreground" Value="LightBlue"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Warning"> + <Setter Property="Icon" Value="ExclamationTriangle"></Setter> + <Setter Property="Foreground" Value="DarkOrange"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Error"> + <Setter Property="Icon" Value="ExclamationTriangle"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Critical"> + <Setter Property="Icon" Value="Bell"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Debug"> + <Setter Property="Icon" Value="Bug"></Setter> + <Setter Property="Foreground" Value="LightGray"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </fa:ImageAwesome.Style> + </fa:ImageAwesome> + </DataTemplate> + <DataTemplate x:Key="LogIconStyle"> + <fa:ImageAwesome Height="16" Width="14" Margin="0 0 0 0" VerticalAlignment="Top"> + <fa:ImageAwesome.Style> + <Style TargetType="fa:ImageAwesome"> + <Setter Property="Icon" Value="ExclamationTriangle"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Category}" Value="Info"> + <Setter Property="Icon" Value="InfoCircle"></Setter> + <Setter Property="Foreground" Value="LightBlue"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Warning"> + <Setter Property="Icon" Value="ExclamationTriangle"></Setter> + <Setter Property="Foreground" Value="DarkOrange"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Error"> + <Setter Property="Icon" Value="ExclamationTriangle"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Critical"> + <Setter Property="Icon" Value="Bell"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Debug"> + <Setter Property="Icon" Value="Bug"></Setter> + <Setter Property="Foreground" Value="LightGray"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> + <Setter Property="Icon" Value="HourglassStart"></Setter> + <Setter Property="Foreground" Value="White"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </fa:ImageAwesome.Style> + </fa:ImageAwesome> + </DataTemplate> + </Window.Resources> <Grid> <Grid.RowDefinitions> @@ -31,17 +184,22 @@ </MenuItem> </Menu> + <Grid Grid.Row="1" Margin="0 20 0 20"> <DockPanel> <StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="10 0 0 0"> <TextBlock FontSize="10">Start Time:</TextBlock> - <mahapps:TimePicker x:Name="startTimePicker" SelectedTime="{Binding StartSelectedTime}" Width="160" VerticalAlignment="Center" FontSize="16" IsClockVisible="False" Culture="en-In"/> + <Border BorderThickness="1" BorderBrush="{StaticResource BorderGrayBrush}" VerticalAlignment="Center" CornerRadius="5" > + <mahapps:TimePicker x:Name="startTimePicker" SelectedTime="{Binding StartSelectedTime}" Width="160" VerticalAlignment="Center" FontSize="16" IsClockVisible="False" Culture="{Binding Culture}" BorderBrush="{StaticResource BorderGrayBrush}" BorderThickness="0" Margin="1"/> + </Border> </StackPanel> <StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="20 0 0 0"> <TextBlock FontSize="10">End Time:</TextBlock> - <mahapps:TimePicker x:Name="enddatePicker" SelectedTime="{Binding EndSelectedTime}" Width="160" VerticalAlignment="Center" FontSize="16" IsClockVisible="False" Culture="en-In" PickerVisibility="HourMinute" /> + <Border BorderThickness="1" BorderBrush="{StaticResource BorderGrayBrush}" VerticalAlignment="Center" CornerRadius="5" > + <mahapps:TimePicker x:Name="enddatePicker" SelectedTime="{Binding EndSelectedTime}" Width="160" VerticalAlignment="Center" FontSize="16" IsClockVisible="False" Culture="{Binding Culture}" PickerVisibility="HourMinute" BorderBrush="{StaticResource BorderGrayBrush}" BorderThickness="0" Margin="1"/> + </Border> </StackPanel> - <Border BorderThickness="1" BorderBrush="#B9B9B9" VerticalAlignment="Center" Padding="10 7" CornerRadius="5" Margin="30 10 0 0"> + <Border BorderThickness="1" BorderBrush="{StaticResource BorderGrayBrush}" VerticalAlignment="Center" Padding="10 7" CornerRadius="5" Margin="30 10 0 0"> <StackPanel> <ItemsControl VerticalAlignment="Center" ItemsSource="{Binding SelectedLogCategories}"> <ItemsControl.ItemsPanel> @@ -52,7 +210,7 @@ <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="10 0 0 0"> - <CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center"></CheckBox> + <CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" BorderBrush="{StaticResource BorderGrayBrush}"></CheckBox> <TextBlock Text="{Binding Data}" Margin="5 0 0 0" VerticalAlignment="Center"></TextBlock> </StackPanel> </DataTemplate> @@ -61,9 +219,10 @@ </StackPanel> </Border> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 10 30 0"> - <fa:ImageAwesome Icon="Search" Width="24" Height="24" /> - <TextBox VerticalAlignment="Center" Margin="10 0 0 0" Width="300" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged}" /> + <fa:ImageAwesome Icon="Search" Width="24" Height="24" Foreground="#7A7A7A"/> + <TextBox VerticalAlignment="Center" Margin="10 0 0 0" Width="300" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged, Delay=1000}" /> </StackPanel> + </DockPanel> </Grid> <Grid Grid.Row="2" > @@ -77,112 +236,18 @@ <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions> - <TextBox FontSize="14" Grid.Row="0" FontFamily="Segoe UI">Log</TextBox> - <TextBox FontSize="14" Grid.Row="0" Grid.Column="2" Margin="10 0 0 0" FontFamily="Segoe UI">Message</TextBox> - <Border Visibility="{Binding IsEmbeddedLog, Converter={StaticResource BooleanToVisibilityInverseConverter}}" Grid.Column="0" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="#B9B9B9" Margin="0 0 10 0"> - <DataGrid x:Name="ActionGrid" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" 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}}"> - <Setter Property="VerticalContentAlignment" Value="Center"/> - <Style.Triggers> - <Trigger Property="IsMouseOver" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="#2196f3" /> - <Setter Property="Cursor" Value="Hand"></Setter> - </Trigger> - <Trigger Property="IsSelected" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="#2196f3" /> - </Trigger> - <Trigger Property="IsFocused" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - </Trigger> - <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> - <Setter Property="Background" Value="#3F3F49"></Setter> - <Setter Property="Foreground" Value="White" /> - <Setter Property="FontWeight" Value="SemiBold"></Setter> - <Setter Property="Cursor" Value="Arrow"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding LogObject}" Value="External Bridge"> - <Setter Property="Foreground" Value="#28A805" /> - </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 Property="VerticalAlignment" Value="Center"/> - <Setter Property="TextBlock.VerticalAlignment" Value="Center" /> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type DataGridCell}"> - <Grid Background="{TemplateBinding Background}"> - <ContentPresenter VerticalAlignment="Bottom" /> - </Grid> - </ControlTemplate> - </Setter.Value> - </Setter> - <Style.Triggers> - <Trigger Property="DataGridCell.IsSelected" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="#2196f3" /> - </Trigger> - <MultiTrigger> - <MultiTrigger.Conditions> - <Condition Property="IsFocused" Value="False" /> - <Condition Property="DataGridCell.IsSelected" Value="True" /> - </MultiTrigger.Conditions> - <MultiTrigger.Setters> - <Setter Property="Foreground" Value="#2196f3" /> - </MultiTrigger.Setters> - </MultiTrigger> - </Style.Triggers> - - </Style> - </DataGrid.CellStyle> + <TextBlock FontSize="14" Grid.Row="0" FontFamily="Segoe UI">Log</TextBlock> + <StackPanel Orientation="Horizontal" Margin="0" Grid.Row="0" Grid.Column="2"> + <TextBlock FontSize="14" Margin="10 0 0 0" FontFamily="Segoe UI">Message</TextBlock> + <CheckBox x:Name="WrapMessgeTextCheckBox" VerticalAlignment="Center" BorderBrush="{StaticResource BorderGrayBrush}" Margin="30 -5 0 0"></CheckBox> + <TextBlock Text="Wrap message text" Margin="5 -5 0 0" VerticalAlignment="Center"></TextBlock> + </StackPanel> + + <Border Visibility="{Binding IsEmbeddedLog, Converter={StaticResource BooleanToVisibilityInverseConverter}}" Grid.Column="0" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{StaticResource BorderGrayBrush}" Margin="0 0 10 0"> + <DataGrid x:Name="ActionGrid" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding LogsViewSource}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True" + CellStyle="{StaticResource LogDataGridCellStyle}" RowStyle="{StaticResource LogDataGridRowStyle}"> <DataGrid.Columns> - <DataGridTemplateColumn Header="ICON"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <fa:ImageAwesome Width="16" Height="16" Margin="0 0 0 0" VerticalAlignment="Top"> - <fa:ImageAwesome.Style> - <Style TargetType="fa:ImageAwesome"> - <Setter Property="Icon" Value="ExclamationTriangle"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Category}" Value="Info"> - <Setter Property="Icon" Value="Info"></Setter> - <Setter Property="Foreground" Value="LightBlue"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Warning"> - <Setter Property="Icon" Value="ExclamationTriangle"></Setter> - <Setter Property="Foreground" Value="DarkOrange"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Error"> - <Setter Property="Icon" Value="ExclamationCircle"></Setter> - <Setter Property="Foreground" Value="Red"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Critical"> - <Setter Property="Icon" Value="Bell"></Setter> - <Setter Property="Foreground" Value="Red"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Debug"> - <Setter Property="Icon" Value="Bug"></Setter> - <Setter Property="Foreground" Value="LightGray"></Setter> - </DataTrigger> - <!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> - <Setter Property="Icon" Value="ClockOutline"></Setter> - <Setter Property="Foreground" Value="White"></Setter> - </DataTrigger>--> - </Style.Triggers> - </Style> - </fa:ImageAwesome.Style> - </fa:ImageAwesome> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> + <DataGridTemplateColumn Header="ICON" CellTemplate="{StaticResource LogIconStyle}"/> <DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat='MM/dd/yyyy HH:mm:ss.ff'}" /> <DataGridTextColumn Header="FILE" Binding="{Binding RelativeCallerFile}" /> <DataGridTextColumn Header="METHOD" Binding="{Binding CallerMethodName}" /> @@ -201,106 +266,15 @@ </DataGrid.Columns> </DataGrid> </Border> - <Border Visibility="{Binding IsEmbeddedLog, Converter={StaticResource BoolToVisibilityConverter}}" Grid.Column="0" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="#B9B9B9" Margin="0 0 10 0"> - <DataGrid x:Name="embededGrid" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" 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}}"> - <Setter Property="VerticalContentAlignment" Value="Center"/> - <Style.Triggers> - <Trigger Property="IsMouseOver" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="#2196f3" /> - <Setter Property="Cursor" Value="Hand"></Setter> - </Trigger> - <Trigger Property="DataGridCell.IsSelected" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="#2196f3" /> - </Trigger> - <Trigger Property="IsFocused" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - </Trigger> - - <DataTrigger Binding="{Binding LogObject}" Value="External Bridge"> - <Setter Property="Foreground" Value="#28A805" /> - </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 Property="VerticalAlignment" Value="Center"/> - <Setter Property="TextBlock.VerticalAlignment" Value="Center" /> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type DataGridCell}"> - <Grid Background="{TemplateBinding Background}"> - <ContentPresenter VerticalAlignment="Bottom" /> - </Grid> - </ControlTemplate> - </Setter.Value> - </Setter> - <Style.Triggers> - <Trigger Property="IsSelected" Value="True"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="#2196f3" /> - </Trigger> - <MultiTrigger> - <MultiTrigger.Conditions> - <Condition Property="IsFocused" Value="False" /> - <Condition Property="DataGridCell.IsSelected" Value="True" /> - </MultiTrigger.Conditions> - <MultiTrigger.Setters> - <Setter Property="Foreground" Value="#2196f3" /> - </MultiTrigger.Setters> - </MultiTrigger> - </Style.Triggers> - - - </Style> - </DataGrid.CellStyle> + <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" Margin="0 -80 0 0" Visibility="{Binding Loading,Converter={StaticResource BoolToVisibilityConverter}}"> + <mahapps:ProgressRing Foreground="LightGray" Width="80" Height="80"></mahapps:ProgressRing> + <TextBlock Text="Loading..." FontStyle="Italic" Margin="50 0 0 0" FontSize="18" VerticalAlignment="Center"></TextBlock> + </StackPanel> + <Border Visibility="{Binding IsEmbeddedLog, Converter={StaticResource BoolToVisibilityConverter}}" Grid.Column="0" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{StaticResource BorderGrayBrush}" Margin="0 0 10 0"> + <DataGrid x:Name="embededGrid" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding LogsViewSource}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True" + CellStyle="{StaticResource LogDataGridCellStyle}" RowStyle="{StaticResource EmLogDataGridRowStyle}"> <DataGrid.Columns> - <DataGridTemplateColumn Header="ICON"> - <DataGridTemplateColumn.CellTemplate> - <DataTemplate> - <fa:ImageAwesome Width="16" Height="16" Margin="0 0 0 0" VerticalAlignment="Top"> - <fa:ImageAwesome.Style> - <Style TargetType="fa:ImageAwesome"> - <Setter Property="Icon" Value="ExclamationTriangle"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Category}" Value="Info"> - <Setter Property="Icon" Value="Info"></Setter> - <Setter Property="Foreground" Value="LightBlue"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Warning"> - <Setter Property="Icon" Value="ExclamationTriangle"></Setter> - <Setter Property="Foreground" Value="DarkOrange"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Error"> - <Setter Property="Icon" Value="ExclamationCircle"></Setter> - <Setter Property="Foreground" Value="Red"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Critical"> - <Setter Property="Icon" Value="Bell"></Setter> - <Setter Property="Foreground" Value="Red"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Debug"> - <Setter Property="Icon" Value="Bug"></Setter> - <Setter Property="Foreground" Value="LightGray"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup"> - <Setter Property="Icon" Value="ClockOutline"></Setter> - <Setter Property="Foreground" Value="White"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </fa:ImageAwesome.Style> - </fa:ImageAwesome> - </DataTemplate> - </DataGridTemplateColumn.CellTemplate> - </DataGridTemplateColumn> + <DataGridTemplateColumn Header="ICON" CellTemplate="{StaticResource EmIconStyle}"/> <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}" /> @@ -320,10 +294,23 @@ </DataGrid.Columns> </DataGrid> </Border> - <Border Margin="10 0 0 0" Grid.Column="2" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="#B9B9B9"> - <TextBox BorderThickness="0" Text="{Binding Message}" IsReadOnly="True" AcceptsReturn="False" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" TextWrapping="NoWrap"/> + <Border Margin="10 0 0 0" Grid.Column="2" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{StaticResource BorderGrayBrush}"> + <TextBox BorderThickness="0" Text="{Binding Message}" IsReadOnly="True" AcceptsReturn="False" VerticalScrollBarVisibility="Auto"> + <TextBox.Style> + <Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}"> + <Setter Property="TextWrapping" Value="NoWrap"></Setter> + <Setter Property="HorizontalScrollBarVisibility" Value="Auto"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ElementName=WrapMessgeTextCheckBox, Path=IsChecked}" Value="True"> + <Setter Property="TextWrapping" Value="Wrap"></Setter> + <Setter Property="HorizontalScrollBarVisibility" Value="Hidden"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBox.Style> + </TextBox> </Border> - <GridSplitter Grid.Column="1" Grid.Row="1" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="4" Background="#B9B9B9"/> + <GridSplitter Grid.Column="1" Grid.Row="1" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="4" Background="{StaticResource BorderGrayBrush}"/> </Grid> </Grid> <StatusBar Grid.Row="3" Grid.ColumnSpan="2" Background="Transparent"> @@ -342,8 +329,8 @@ <StatusBarItem Grid.Column="1"> <TextBlock Text="{Binding FileName}"></TextBlock> </StatusBarItem> - <Separator Grid.Column="2" /> - <StatusBarItem Grid.Column="3"> + <Separator Grid.Column="2" Visibility="{Binding IsSet, Converter={StaticResource BoolToVisibilityConverter}}"/> + <StatusBarItem Grid.Column="3" Visibility="{Binding IsSet, Converter={StaticResource BoolToVisibilityConverter}}"> <TextBlock> <Run Text="Set: "></Run> <Run Text="{Binding CountOfSet}"></Run> diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/Tango.LogViewer.UI.csproj b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/Tango.LogViewer.UI.csproj index 76be4e85e..66f8549a5 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/Tango.LogViewer.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/Tango.LogViewer.UI.csproj @@ -20,7 +20,7 @@ <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> - <OutputPath>..\..\Build\Utilities\Debug\</OutputPath> + <OutputPath>..\..\Build\LogViewer\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> @@ -29,17 +29,20 @@ <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> - <OutputPath>..\..\Build\Utilities\Release\</OutputPath> + <OutputPath>..\..\Build\LogViewer\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath> + </Reference> <Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL"> <HintPath>..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath> </Reference> - <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> - <HintPath>..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath> + <Reference Include="MahApps.Metro, Version=1.6.5.1, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll</HintPath> </Reference> <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath> @@ -53,7 +56,7 @@ <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <HintPath>..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + <HintPath>..\..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> <Reference Include="System.Xml" /> <Reference Include="Microsoft.CSharp" /> @@ -119,10 +122,6 @@ <None Include="App.config" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\MachineStudio\Tango.MachineStudio.UI\Tango.MachineStudio.UI.csproj"> - <Project>{116DFDB0-7681-46FE-8BAD-FE8AE09BB076}</Project> - <Name>Tango.MachineStudio.UI</Name> - </ProjectReference> <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/ViewModels/MainViewVM.cs index cb4a8d49e..11d62a8ab 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/ViewModels/MainViewVM.cs @@ -14,12 +14,14 @@ using System.Windows.Data; using System.Diagnostics; using System.IO; using Tango.LogViewer.UI.LogViewerFileParser; +using System.Globalization; namespace Tango.LogViewer.UI.ViewModels { public class MainViewVM: ViewModel { - private ILogViewerParser _parser; + + private LogViewerManager _logViewerManager; #region Properties public SelectedObjectCollection<LogCategory> SelectedLogCategories { get; set; } @@ -133,12 +135,29 @@ namespace Tango.LogViewer.UI.ViewModels public bool IsEmbeddedLog { get { return _isEmbeddedLog; } - set { _isEmbeddedLog = value; - RaisePropertyChangedAuto(); - } + set { _isEmbeddedLog = value; RaisePropertyChangedAuto(); } } - + private bool _isSet; + /// <summary> + /// Gets or sets a value indicating whether set of files. + /// </summary> + public bool IsSet + { + get { return _isSet; } + set { _isSet = value; RaisePropertyChangedAuto(); } + } + + private bool _loading; + + public bool Loading + { + get { return _loading; } + set { _loading = value; RaisePropertyChangedAuto(); } + } + + public CultureInfo Culture { get; set; } + #endregion public RelayCommand OpeFileLogCommand { get; set; } @@ -146,6 +165,8 @@ namespace Tango.LogViewer.UI.ViewModels #region Constructors public MainViewVM() { + Culture = new CultureInfo("he-IL"); + SelectedLogCategories = new SelectedObjectCollection<LogCategory>(new ObservableCollection<LogCategory>() { LogCategory.Info, @@ -161,8 +182,11 @@ namespace Tango.LogViewer.UI.ViewModels LogCategory.Critical, LogCategory.Debug, }); + _logViewerManager = new LogViewerManager(); + IsSet = false; IsEmbeddedLog = false; - ClearFilters(); + Loading = false; + Clear(); OpeFileLogCommand = new RelayCommand(OpenLogFile); SelectedLogCategories.SynchedSource.CollectionChanged += (_, __) => { @@ -175,15 +199,22 @@ namespace Tango.LogViewer.UI.ViewModels /// <summary> /// Clears the all filters. Set filter properties to init state. /// </summary> - private void ClearFilters() + private void Clear() { - FileName = "FileName"; + FileName = ""; StartSelectedTime = TimeSpan.Zero; EndSelectedTime = TimeSpan.Zero; Filter = ""; SelectedLog = null; SelectedLogCategories.SynchedSource= SelectedLogCategories.Source; CountOfSet = 0; + IsSet = false; + if (Logs != null) + { + Logs.Clear(); + RaisePropertyChanged("Logs"); + } + } /// <summary> @@ -210,67 +241,26 @@ namespace Tango.LogViewer.UI.ViewModels /// </summary> public async void LoadLogFile(String fileName) { - ClearFilters(); - LogViewerManager.InitLogFile(fileName); + Clear(); + Loading = true; + _logViewerManager.InitLogFile(fileName); List<LogItemBase> logs = new List<LogItemBase>(); await Task.Factory.StartNew(() => - { - foreach (var logFile in LogViewerManager.LogFiles) - { - logs.AddRange(Parse(logFile)); - } - }); + { + logs.AddRange(_logViewerManager.Parse()); + }); + + CountOfSet = _logViewerManager.CountOfSet; + IsSet = CountOfSet > 0 ? true : false; + IsEmbeddedLog = _logViewerManager.IsEmbeddedLog; + FileName = _logViewerManager.FileName; Logs = new ObservableCollection<LogItemBase>(logs); LogsViewSource = CollectionViewSource.GetDefaultView(Logs); ApplyLogsFilter(); + Loading = false; } - /// <summary> - /// Parses the specified log file. - /// </summary> - public List<LogItemBase> Parse(LogFile logFile) - { - List<LogItemBase> logItems = new List<LogItemBase>(); - List<LogFile> logFiles = new List<LogFile>(); - string fileName = Path.GetFileNameWithoutExtension(logFile.File); - FileName = fileName; - IsEmbeddedLog = fileName.StartsWith("Embedded"); - if (IsEmbeddedLog) - { - _parser = new EmbeddedLogViewerParser(); - } - else - { - _parser = new ApplicationLogViewerParser(); - } - - if (logFile.PartOfSet) - { - string extension = Path.GetExtension(logFile.File); - var directoryName = Path.GetDirectoryName(logFile.File); - int indexPos = fileName.IndexOf(FileLogger.FILE_SET_EXTENSION); - if (indexPos > 0) - { - fileName = fileName.Substring(0, indexPos); - FileName = fileName; - } - string folder = logFile.File; - string[] fileEntries = Directory.GetFiles(directoryName, $"{fileName}*{extension}").Where(x => Path.GetFileName(x).StartsWith(fileName)).OrderBy(x => x).ToArray(); - CountOfSet = fileEntries.Length; - foreach (var file in fileEntries) - { - _parser.Parse(file, logFile.DateTime, ref logItems); - } - } - else - { - CountOfSet = 1; - _parser.Parse(logFile.File, logFile.DateTime, ref logItems); - } - - return logItems; - } - + #endregion #region Filtering diff --git a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/packages.config b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/packages.config index 224f74b3a..0ac4ca4b4 100644 --- a/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/packages.config +++ b/Software/Visual_Studio/Utilities/Tango.LogViewer.UI/packages.config @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <packages> + <package id="ControlzEx" version="3.0.2.4" targetFramework="net461" /> <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net461" /> - <package id="MahApps.Metro" version="1.5.0" targetFramework="net461" /> + <package id="MahApps.Metro" version="1.6.5" targetFramework="net461" /> <package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.0" targetFramework="net461" /> <package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net461" /> </packages>
\ No newline at end of file |
