Skip to content

Commit

Permalink
Added indicator for disk space saved in the Watched Folders view. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
Iridium-IO committed Jun 28, 2024
1 parent b13844b commit f321d31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
17 changes: 14 additions & 3 deletions CompactGUI.Watcher/Watcher.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Imports CompactGUI.Core
Imports System.Threading
Imports System.Collections.Specialized
Imports System.Runtime
Imports System.ComponentModel

Public Class Watcher : Inherits ObservableObject

Expand Down Expand Up @@ -89,9 +90,11 @@ Public Class Watcher : Inherits ObservableObject
End If

If immediateFlushToDisk Then WriteToFile()
OnPropertyChanged(NameOf(TotalSaved))

End Sub


Public Sub RemoveWatched(item As WatchedFolder)

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

WatchedFolders.Remove(item)
WriteToFile()

OnPropertyChanged(NameOf(TotalSaved))

End Sub

Expand All @@ -114,7 +117,7 @@ Public Class Watcher : Inherits ObservableObject
For Each f In WatchedFolders
f.RefreshProperties()
Next

OnPropertyChanged(NameOf(TotalSaved))
End Sub

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

WriteToFile()
Debug.WriteLine("")

OnPropertyChanged(NameOf(TotalSaved))

IsActive = False
End Function
Expand Down Expand Up @@ -206,6 +209,14 @@ Public Class Watcher : Inherits ObservableObject
End Function


Public ReadOnly Property TotalSaved As Long
Get
Return WatchedFolders.Sum(Function(f) f.LastUncompressedSize - f.LastCheckedSize)
End Get
End Property



End Class

Public Class WatchedFolder : Inherits ObservableObject
Expand Down
9 changes: 7 additions & 2 deletions CompactGUI/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,13 @@
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RefreshWatchedCommand}" Background="Transparent" Foreground="#FFBFC7CE">
<ui:FontIcon Glyph="&#xE9F3;" FontSize="14" />
</Button>

<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">

<TextBlock FontSize="14" Foreground="#FFBFC7CE" HorizontalAlignment="Right" Margin="0,2,0,220">
<Run Text="Disk space saved: " />
<Run Text="{Binding Watcher.TotalSaved, Mode=OneWay, Converter={StaticResource BytesToReadableConverter}}" />
</TextBlock>

<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">
<ui:ListView.ItemContainerStyle>
<Style TargetType="ui:ListViewItem">
<Setter Property="Margin" Value="0,0,0,10"/>
Expand Down

0 comments on commit f321d31

Please sign in to comment.