Skip to content

Commit 72383e8

Browse files
committed
Add button to re-scan a single folder in the watchlist. Closes #452
- Also fix error where analysing icon wouldn't show up when analysing all folders
1 parent 3dfc4d1 commit 72383e8

File tree

3 files changed

+57
-20
lines changed

3 files changed

+57
-20
lines changed

CompactGUI.Watcher/Watcher.vb

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,27 @@ Public Class Watcher : Inherits ObservableObject
278278

279279
End Function
280280

281+
Public Async Function ParseSingleWatcher(watchedFolder As WatchedFolder) As Task
282+
283+
Dim acquired = Await _parseWatchersSemaphore.WaitAsync(0)
284+
If Not acquired Then Return
285+
286+
Try
287+
If watchedFolder Is Nothing Then Return
288+
If Not IO.Directory.Exists(watchedFolder.Folder) Then
289+
RemoveWatched(watchedFolder)
290+
Return
291+
End If
292+
293+
Await Analyse(watchedFolder.Folder, False)
294+
LastAnalysed = DateTime.Now
295+
WriteToFile()
296+
Finally
297+
_parseWatchersSemaphore.Release()
298+
End Try
299+
300+
301+
End Function
281302

282303
Public Async Function BackgroundCompact() As Task
283304

@@ -306,22 +327,14 @@ Public Class Watcher : Inherits ObservableObject
306327
Debug.WriteLine("Background Analysing: " & folder)
307328
Dim analyser As New Analyser(folder)
308329

309-
Dim ret = Await analyser.AnalyseFolder(Nothing)
310-
311-
'Dim retMSG As String = ""
312-
313-
'retMSG &= $"Compressed Bytes: {analyser.CompressedBytes}" & Environment.NewLine
314-
'retMSG &= $"Uncompressed Bytes: {analyser.UncompressedBytes}" & Environment.NewLine
315-
'retMSG &= $"FileCompressionDetails: {analyser.FileCompressionDetailsList.Count}" & Environment.NewLine
316-
'retMSG &= $"FolderSubs: {analyser.FolderName.Count}" & Environment.NewLine
317-
330+
Dim watched = WatchedFolders.First(Function(f) f.Folder = folder)
331+
watched.IsWorking = True
318332

319-
'MsgBox(retMSG)
333+
Dim ret = Await analyser.AnalyseFolder(Nothing)
320334

321335
analyser.FileCompressionDetailsList.Clear()
322336

323-
Dim watched = WatchedFolders.First(Function(f) f.Folder = folder)
324-
watched.IsWorking = True
337+
325338
watched.LastCheckedDate = DateTime.Now
326339
watched.LastCheckedSize = analyser.CompressedBytes
327340
watched.LastUncompressedSize = analyser.UncompressedBytes

CompactGUI/ViewModels/WatcherViewModel.vb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Public Class WatcherViewModel : Inherits ObservableObject
1313
Public ReadOnly Property ReCompressWatchedCommand As IRelayCommand = New RelayCommand(Of Watcher.WatchedFolder)(Sub(f) AddWatchedFolderToQueue(f))
1414

1515
Public Property RefreshWatchedCommand As AsyncRelayCommand = New AsyncRelayCommand(AddressOf RefreshWatchedAsync)
16+
17+
Public ReadOnly Property ReAnalyseWatchedCommand As IRelayCommand = New AsyncRelayCommand(Of Watcher.WatchedFolder)(Function(f) ReAnalyseWatchedAsync(f))
18+
1619
Public Property ManuallyAddFolderToWatcherCommand As AsyncRelayCommand = New AsyncRelayCommand(AddressOf ManuallyAddFolderToWatcher)
1720

1821

@@ -30,6 +33,11 @@ Public Class WatcherViewModel : Inherits ObservableObject
3033
End Function
3134

3235

36+
Private Async Function ReAnalyseWatchedAsync(watchedfolder As Watcher.WatchedFolder) As Task
37+
Await Task.Run(Function() Watcher.ParseSingleWatcher(watchedfolder))
38+
End Function
39+
40+
3341
Private Sub DeleteWatchersWithNonExistentFolders()
3442

3543
Dim watchersToRemove As New List(Of Watcher.WatchedFolder)

CompactGUI/Views/Components/FolderWatcherCard.xaml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<ui:ProgressRing Width="15" Height="15"
158158
Margin="0,0,6,0" Padding="7"
159159
Foreground="#FFBFC7CE" IsIndeterminate="True"
160-
Visibility="{Binding IsWorking, Converter={StaticResource BoolToVisConverter}}" />
160+
Visibility="{Binding IsWorking, Converter={StaticResource BoolToVisConverter}, Mode=OneWay}" />
161161
<Viewbox Grid.Column="1"
162162
Width="12" Height="12"
163163
Margin="0,0,5,0" HorizontalAlignment="Left"
@@ -172,17 +172,18 @@
172172
Visibility="{Binding IsSteamGame, Converter={StaticResource BooleanToInverseVisibilityConverter}}" />
173173
<Grid>
174174
<TextBlock Text="{Binding DisplayName, Converter={StaticResource StrippedFolderPathConverter}}"
175-
MaxWidth="280" MinWidth="100"
175+
MinWidth="100" MaxWidth="280"
176176
Margin="0,-2,0,0" VerticalAlignment="Top"
177177
FontSize="15" FontWeight="SemiBold" Foreground="White"
178178
MouseLeftButtonDown="DisplayNameTextBlock_MouseLeftButtonDown"
179179
TextTrimming="CharacterEllipsis"
180180
Visibility="{Binding IsEditing, Converter={StaticResource BooleanToInverseVisibilityConverter}}" />
181181

182182
<TextBox Text="{Binding DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
183-
MaxWidth="280" MinWidth="100"
184-
Margin="-3,-3,0,0" VerticalAlignment="Top" Padding="0"
185-
FontSize="15" FontWeight="SemiBold" Foreground="{StaticResource TextControlForeground}"
183+
MinWidth="100" MaxWidth="280"
184+
Margin="-3,-3,0,0" Padding="0" VerticalAlignment="Top"
185+
FontSize="15" FontWeight="SemiBold"
186+
Foreground="{StaticResource TextControlForeground}"
186187
KeyDown="DisplayNameTextBox_KeyDown" LostFocus="DisplayNameTextBox_LostFocus"
187188
Visibility="{Binding IsEditing, Converter={StaticResource BoolToVisConverter}}" />
188189
</Grid>
@@ -251,14 +252,14 @@
251252
Foreground="White">
252253
<ui:SymbolIcon FontSize="14" Symbol="Delete16" />
253254
<Button.ToolTip>
254-
<ToolTip Background="#304257" ToolTipService.InitialShowDelay="100">
255+
<ToolTip ToolTipService.InitialShowDelay="100">
255256
<TextBlock Text="Remove from Watchlist"
256257
FontSize="12" Foreground="#FFBFC7CE" TextWrapping="NoWrap" />
257258
</ToolTip>
258259
</Button.ToolTip>
259260
</Button>
260261

261-
<Button Margin="0,0,35,0" HorizontalAlignment="Right"
262+
<Button Margin="0,0,40,0" HorizontalAlignment="Right"
262263
Background="#6B8399"
263264
Command="{Binding ElementName=UiWatcherListView, Path=DataContext.ReCompressWatchedCommand}"
264265
CommandParameter="{Binding}"
@@ -274,12 +275,27 @@
274275
</ui:SymbolIcon.RenderTransform>
275276
</ui:SymbolIcon>
276277
<Button.ToolTip>
277-
<ToolTip Background="#304257" ToolTipService.InitialShowDelay="100">
278+
<ToolTip ToolTipService.InitialShowDelay="100">
278279
<TextBlock Text="Add to compression queue"
279280
FontSize="12" Foreground="#FFBFC7CE" TextWrapping="NoWrap" />
280281
</ToolTip>
281282
</Button.ToolTip>
282283
</Button>
284+
285+
<Button Margin="0,0,80,0" HorizontalAlignment="Right" Visibility="{Binding IsWorking, Converter={StaticResource BooleanToInverseVisibilityConverter}}"
286+
Command="{Binding ElementName=UiWatcherListView, Path=DataContext.ReAnalyseWatchedCommand}"
287+
CommandParameter="{Binding}"
288+
Foreground="White">
289+
<ui:FontIcon FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets" FontSize="14"
290+
Glyph="&#xE9F3;" />
291+
<Button.ToolTip>
292+
<ToolTip ToolTipService.InitialShowDelay="100">
293+
<TextBlock Text="Re-analyse this folder"
294+
FontSize="12" Foreground="#FFBFC7CE" TextWrapping="NoWrap" />
295+
</ToolTip>
296+
</Button.ToolTip>
297+
</Button>
298+
283299
</Grid>
284300

285301

0 commit comments

Comments
 (0)