Skip to content

Commit a6e1d20

Browse files
committed
allow text to be selected in log output
1 parent 2614c59 commit a6e1d20

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

GitContentSearch.UI/ViewModels/MainWindowViewModel.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public MainWindowViewModel(IStorageProvider storageProvider, SettingsService set
2424
{
2525
_storageProvider = storageProvider;
2626
_settingsService = settingsService;
27+
_logOutput.CollectionChanged += LogOutput_CollectionChanged;
2728
LoadSettingsAsync().ConfigureAwait(false);
2829
}
2930

@@ -57,8 +58,38 @@ public MainWindowViewModel(IStorageProvider storageProvider, SettingsService set
5758
[ObservableProperty]
5859
private double searchProgress;
5960

61+
private ObservableCollection<string> _logOutput = new();
62+
public ObservableCollection<string> LogOutput
63+
{
64+
get => _logOutput;
65+
set
66+
{
67+
if (_logOutput != null)
68+
{
69+
_logOutput.CollectionChanged -= LogOutput_CollectionChanged;
70+
}
71+
_logOutput = value;
72+
if (_logOutput != null)
73+
{
74+
_logOutput.CollectionChanged += LogOutput_CollectionChanged;
75+
}
76+
OnPropertyChanged();
77+
UpdateJoinedLogOutput();
78+
}
79+
}
80+
81+
private void LogOutput_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
82+
{
83+
UpdateJoinedLogOutput();
84+
}
85+
86+
private void UpdateJoinedLogOutput()
87+
{
88+
JoinedLogOutput = string.Join(Environment.NewLine, LogOutput);
89+
}
90+
6091
[ObservableProperty]
61-
private ObservableCollection<string> logOutput = new();
92+
private string joinedLogOutput = string.Empty;
6293

6394
[ObservableProperty]
6495
[NotifyCanExecuteChangedFor(nameof(StartSearchCommand))]

GitContentSearch.UI/Views/MainWindow.axaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,10 @@
9797
CornerRadius="8"
9898
Margin="0,16,0,0">
9999
<ScrollViewer Margin="8">
100-
<ItemsControl ItemsSource="{Binding LogOutput}">
101-
<ItemsControl.ItemTemplate>
102-
<DataTemplate>
103-
<TextBlock Text="{Binding}"
104-
TextWrapping="Wrap"
105-
Foreground="#CCCCCC"
106-
FontFamily="Consolas"
107-
Margin="0,2"/>
108-
</DataTemplate>
109-
</ItemsControl.ItemTemplate>
110-
</ItemsControl>
100+
<SelectableTextBlock Text="{Binding JoinedLogOutput}"
101+
TextWrapping="Wrap"
102+
Foreground="#CCCCCC"
103+
FontFamily="Consolas"/>
111104
</ScrollViewer>
112105
</Border>
113106
</Grid>

0 commit comments

Comments
 (0)