Skip to content

Commit f321d31

Browse files
committed
Added indicator for disk space saved in the Watched Folders view. Closes #406
1 parent b13844b commit f321d31

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

CompactGUI.Watcher/Watcher.vb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Imports CompactGUI.Core
55
Imports System.Threading
66
Imports System.Collections.Specialized
77
Imports System.Runtime
8+
Imports System.ComponentModel
89

910
Public Class Watcher : Inherits ObservableObject
1011

@@ -89,9 +90,11 @@ Public Class Watcher : Inherits ObservableObject
8990
End If
9091

9192
If immediateFlushToDisk Then WriteToFile()
93+
OnPropertyChanged(NameOf(TotalSaved))
9294

9395
End Sub
9496

97+
9598
Public Sub RemoveWatched(item As WatchedFolder)
9699

97100
Dim x = Watchers.Find(Function(f) f.Folder = item.Folder)
@@ -102,7 +105,7 @@ Public Class Watcher : Inherits ObservableObject
102105

103106
WatchedFolders.Remove(item)
104107
WriteToFile()
105-
108+
OnPropertyChanged(NameOf(TotalSaved))
106109

107110
End Sub
108111

@@ -114,7 +117,7 @@ Public Class Watcher : Inherits ObservableObject
114117
For Each f In WatchedFolders
115118
f.RefreshProperties()
116119
Next
117-
120+
OnPropertyChanged(NameOf(TotalSaved))
118121
End Sub
119122

120123
Private Async Function GetWatchedFoldersFromJson() As Task(Of ObservableCollection(Of WatchedFolder))
@@ -171,7 +174,7 @@ Public Class Watcher : Inherits ObservableObject
171174

172175
WriteToFile()
173176
Debug.WriteLine("")
174-
177+
OnPropertyChanged(NameOf(TotalSaved))
175178

176179
IsActive = False
177180
End Function
@@ -206,6 +209,14 @@ Public Class Watcher : Inherits ObservableObject
206209
End Function
207210

208211

212+
Public ReadOnly Property TotalSaved As Long
213+
Get
214+
Return WatchedFolders.Sum(Function(f) f.LastUncompressedSize - f.LastCheckedSize)
215+
End Get
216+
End Property
217+
218+
219+
209220
End Class
210221

211222
Public Class WatchedFolder : Inherits ObservableObject

CompactGUI/Views/MainWindow.xaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,8 +1155,13 @@
11551155
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RefreshWatchedCommand}" Background="Transparent" Foreground="#FFBFC7CE">
11561156
<ui:FontIcon Glyph="&#xE9F3;" FontSize="14" />
11571157
</Button>
1158-
1159-
<ui:ListView x:Name="uiWatcherListView" Margin="-10,60,0,0" Padding="0" Width="480" ItemsSource="{Binding Source = {StaticResource src}}" d:ItemsSource="{d:SampleData}" KeyboardNavigation.TabNavigation="None" ui:ScrollViewerHelper.AutoHideScrollBars="False">
1158+
1159+
<TextBlock FontSize="14" Foreground="#FFBFC7CE" HorizontalAlignment="Right" Margin="0,2,0,220">
1160+
<Run Text="Disk space saved: " />
1161+
<Run Text="{Binding Watcher.TotalSaved, Mode=OneWay, Converter={StaticResource BytesToReadableConverter}}" />
1162+
</TextBlock>
1163+
1164+
<ui:ListView x:Name="uiWatcherListView" Margin="-10,60,0,0" Padding="0" Width="480" ItemsSource="{Binding Source = {StaticResource src}}" d:ItemsSource="{d:SampleData}" KeyboardNavigation.TabNavigation="None" ui:ScrollViewerHelper.AutoHideScrollBars="False">
11601165
<ui:ListView.ItemContainerStyle>
11611166
<Style TargetType="ui:ListViewItem">
11621167
<Setter Property="Margin" Value="0,0,0,10"/>

0 commit comments

Comments
 (0)