Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions PostCodeSerialMonitor/Assets/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions PostCodeSerialMonitor/Assets/Resources.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@
<value>Mostrar timestamps</value>
<comment>In Views/ConfigurationDialog.axaml</comment>
</data>
<data name="TimestampLabel" xml:space="preserve">
<value>Hora: </value>
<comment>In Views/MainWindow.axaml</comment>
</data>
<data name="FirmwareUpdateUrl" xml:space="preserve">
<value>URL de atualização do firmware</value>
<comment>In Views/ConfigurationDialog.axaml</comment>
Expand Down
8 changes: 8 additions & 0 deletions PostCodeSerialMonitor/Assets/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@
<value>Show timestamps</value>
<comment>In Views/ConfigurationDialog.axaml</comment>
</data>
<data name="DescriptionDisplaySettings" xml:space="preserve">
<value>Description display</value>
<comment>In Views/ConfigurationDialog.axaml</comment>
</data>
<data name="TimestampLabel" xml:space="preserve">
<value>Time: </value>
<comment>In Views/MainWindow.axaml</comment>
</data>
<data name="FirmwareUpdateUrl" xml:space="preserve">
<value>Firmware update URL</value>
<comment>In Views/ConfigurationDialog.axaml</comment>
Expand Down
3 changes: 3 additions & 0 deletions PostCodeSerialMonitor/Models/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class AppConfiguration
public bool CheckForFwUpdates { get; set; } = true;
public bool ShowTimestamps { get; set; } = false;

[Required]
public string DescriptionDisplayMode { get; set; } = "NewLine";

[Required]
public string Theme { get; set; } = "Dark";

Expand Down
27 changes: 26 additions & 1 deletion PostCodeSerialMonitor/Models/LogEntry.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
using System;
using System.ComponentModel;

namespace PostCodeSerialMonitor.Models;
// Simple model to hold log entry data
public class LogEntry
public class LogEntry : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;

private bool isSelected;
public bool IsSelected
{
get => isSelected;
set
{
if (isSelected == value) return;
isSelected = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected)));
}
}

public string RawText { get; set; } = string.Empty;
public DateTime Timestamp { get; set; } = DateTime.Now;
public string TimestampText => Timestamp.ToString("HH:mm:ss.fff");
Expand All @@ -14,8 +29,18 @@ public class LogEntry
public string FormattedText => FormatText();
// Flavor, index and code (hex)
public string CodeText => FormatCodeText();
// Individual fields, for column-aligned display
public string FlavorText => DecodedCode.Flavor.ToString();
public string IndexText => $"({DecodedCode.Index}):";
public string CodeHexText => $"{DecodedCode.Code:X4}";
public string NameText => string.IsNullOrEmpty(DecodedCode?.Name) ? string.Empty : $"[{DecodedCode.Name}]";
// Name + description on one line, for the truncated inline preview
public string InlinePreviewText => string.IsNullOrEmpty(Description)
? NameText
: string.IsNullOrEmpty(NameText) ? Description : $"{NameText} {Description}";
// Description or null
public string? Description => string.IsNullOrEmpty(DecodedCode.Description) ? null : DecodedCode?.Description;
public bool HasDescription => !string.IsNullOrEmpty(Description);
public bool IsWarning => SeverityLevel == CodeSeverity.Warning;
public bool IsError => SeverityLevel == CodeSeverity.Error;
public CodeSeverity SeverityLevel => DecodedCode.SeverityLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public partial class ConfigurationDialogViewModel : ViewModelBase
[ObservableProperty]
private bool showTimestamps;

[ObservableProperty]
private ObservableCollection<string> descriptionDisplayModes = new(["Inline", "NewLine", "BottomPanel"]);

[ObservableProperty]
private string selectedDescriptionDisplayMode;

[ObservableProperty]
private string codesMetaBaseUrl;

Expand Down Expand Up @@ -66,6 +72,7 @@ public ConfigurationDialogViewModel(ConfigurationService configurationService)
CheckForCodeUpdates = _originalConfiguration.CheckForCodeUpdates;
CheckForFwUpdates = _originalConfiguration.CheckForFwUpdates;
ShowTimestamps = _originalConfiguration.ShowTimestamps;
SelectedDescriptionDisplayMode = _originalConfiguration.DescriptionDisplayMode;
CodesMetaBaseUrl = _originalConfiguration.CodesMetaBaseUrl.ToString();
SelectedLanguage = _originalConfiguration.Language;
SelectedTheme = _originalConfiguration.Theme;
Expand All @@ -85,6 +92,7 @@ await _configurationService.UpdateConfigurationAsync(config =>
config.CheckForCodeUpdates = CheckForCodeUpdates;
config.CheckForFwUpdates = CheckForFwUpdates;
config.ShowTimestamps = ShowTimestamps;
config.DescriptionDisplayMode = SelectedDescriptionDisplayMode;
config.CodesMetaBaseUrl = new Uri(CodesMetaBaseUrl);
config.Language = SelectedLanguage;
config.Theme = SelectedTheme;
Expand Down
33 changes: 33 additions & 0 deletions PostCodeSerialMonitor/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public partial class MainWindowViewModel : ViewModelBase
[ObservableProperty]
private bool showTimestamps;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsDescriptionInlineMode))]
[NotifyPropertyChangedFor(nameof(IsDescriptionNewLineMode))]
[NotifyPropertyChangedFor(nameof(IsDescriptionBottomPanelMode))]
private string descriptionDisplayMode = "NewLine";

public bool IsDescriptionInlineMode => DescriptionDisplayMode == "Inline";
public bool IsDescriptionNewLineMode => DescriptionDisplayMode == "NewLine";
public bool IsDescriptionBottomPanelMode => DescriptionDisplayMode == "BottomPanel";

[ObservableProperty]
private string i2cScanOutput = Assets.Resources.ScanButtonText;

Expand All @@ -98,6 +108,9 @@ public partial class MainWindowViewModel : ViewModelBase
[ObservableProperty]
private bool debugModeUnlocked;

[ObservableProperty]
private LogEntry? selectedLogEntry;

private int _appVersionClickCount;

public IStorageProvider? StorageProvider
Expand Down Expand Up @@ -137,6 +150,7 @@ public MainWindowViewModel(
}
SelectedConsoleModel = ConsoleModels.FirstOrDefault();
ShowTimestamps = _configurationService.Config.ShowTimestamps;
DescriptionDisplayMode = _configurationService.Config.DescriptionDisplayMode;

RefreshPorts();
_serialService.DataReceived += OnDataReceived;
Expand Down Expand Up @@ -243,6 +257,24 @@ private void ClearLog()
{
LogEntries.Clear();
RawLogEntries.Clear();
SelectedLogEntry = null;
}

[RelayCommand]
private void SelectLogEntry(LogEntry entry)
{
if (SelectedLogEntry == entry)
{
entry.IsSelected = false;
SelectedLogEntry = null;
return;
}

if (SelectedLogEntry != null)
SelectedLogEntry.IsSelected = false;

entry.IsSelected = true;
SelectedLogEntry = entry;
}

[RelayCommand]
Expand Down Expand Up @@ -420,6 +452,7 @@ private async Task ShowConfigurationAsync()
await dialog.ShowDialog(GetParentWindow());

ShowTimestamps = _configurationService.Config.ShowTimestamps;
DescriptionDisplayMode = _configurationService.Config.DescriptionDisplayMode;
}

[RelayCommand]
Expand Down
5 changes: 5 additions & 0 deletions PostCodeSerialMonitor/Views/ConfigurationDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<TextBlock Text="{x:Static assets:Resources.LogSettings}" FontWeight="Bold" Margin="0,10,0,5"/>
<CheckBox Content="{x:Static assets:Resources.ShowTimestamps}"
IsChecked="{Binding ShowTimestamps}"/>

<TextBlock Text="{x:Static assets:Resources.DescriptionDisplaySettings}" FontWeight="Bold" Margin="0,10,0,5"/>
<ComboBox Width="150"
ItemsSource="{Binding DescriptionDisplayModes}"
SelectedItem="{Binding SelectedDescriptionDisplayMode, Mode=TwoWay}"/>
</StackPanel>
</ScrollViewer>

Expand Down
18 changes: 0 additions & 18 deletions PostCodeSerialMonitor/Views/Converters/NullFontSizeConverter.cs

This file was deleted.

Loading
Loading