Skip to content

Commit

Permalink
update to allow checking different drives
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandhall committed Mar 1, 2022
1 parent fa88771 commit c24a5eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
RUNNER_TEMP: ${{ runner.temp }}
GITHUB_WORKSPACE: ${{ github.workspace }}
- name: Publish binaries
run: gh release upload 'v1.0.1' "${{ env.RUNNER_TEMP }}\\build.zip" --clobber
run: gh release upload 'v1.0.2' "${{ env.RUNNER_TEMP }}\\build.zip" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUNNER_TEMP: ${{ runner.temp }}
3 changes: 1 addition & 2 deletions FolderSize/FolderInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ await Task.WhenAll(SubFolders.Select(async f =>
OnPropertyChanged(nameof(DisplayTick));
}, token.Token);
}
catch (Exception ex)
catch
{
Debug.WriteLine(ex.Message);
Task = Task.CompletedTask;
}
}
Expand Down
1 change: 1 addition & 0 deletions FolderSize/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</ListView.ItemTemplate>
</ListView>
<StackPanel Name="OverallSize" Grid.Row="2" Grid.Column="0" Orientation="Horizontal">
<ComboBox SelectionChanged="Drives_OnSelected" Name="Drives"></ComboBox>
<TextBlock Margin="20 0 0 0" VerticalAlignment="Center" Text="{Binding SizeString, UpdateSourceTrigger=PropertyChanged}"></TextBlock>
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Visibility="{Binding DisplayTick, Converter={StaticResource BooleanToVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}">✔️</TextBlock>
</StackPanel>
Expand Down
30 changes: 21 additions & 9 deletions FolderSize/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace FolderSize
{

public partial class MainWindow : Window, IDisposable
{
private FolderInfo _folderInfo;
Expand All @@ -27,14 +26,17 @@ public partial class MainWindow : Window, IDisposable
public MainWindow()
{
InitializeComponent();
GatherData();
DriveInfo
.GetDrives()
.Select(d => new ComboBoxItem{Content = $"{d.Name} ({FileSizeFormatter.FormatSize(d.TotalSize)})", Tag = d.Name, IsSelected = d.Name==@"C:\"})
.ToList()
.ForEach(i => Drives.Items.Add(i));
}

private void GatherData()
private void GatherData(string path)
{
_cancellationTokenSource = new CancellationTokenSource();
var path = @"C:\";


var rootFolderInfo = new FolderInfo(path, _dictionary, new TokenBox(_cancellationTokenSource.Token));

UpdateBinding(rootFolderInfo);
Expand Down Expand Up @@ -68,16 +70,20 @@ private void FolderUp_OnClick(object sender, RoutedEventArgs e)
}

private void Refresh_OnClick(object sender, RoutedEventArgs e)
{
ClearAllData();
GatherData((Drives.SelectedItem as ComboBoxItem)?.Tag?.ToString()??@"C:\");
}

private void ClearAllData()
{
_cancellationTokenSource?.Cancel();
_cancellationTokenSource?.Dispose();

UpdateBinding(null);

_list.Clear();
_dictionary.Clear();

GatherData();
}

public void Dispose()
Expand All @@ -90,5 +96,11 @@ private void Explore_OnClick(object sender, RoutedEventArgs e)
{
Process.Start("explorer.exe", _folderInfo?.Name ?? @"C:\");
}

private void Drives_OnSelected(object sender, RoutedEventArgs e)
{
ClearAllData();
GatherData(((sender as ComboBox)?.SelectedItem as ComboBoxItem)?.Tag?.ToString()??@"C:\");
}
}
}

0 comments on commit c24a5eb

Please sign in to comment.