Skip to content

Commit ab80827

Browse files
committed
Add LogFolderSize in label
1 parent 3396904 commit ab80827

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

Flow.Launcher/SettingWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,9 +2524,10 @@
25242524
Click="OpenSettingFolder"
25252525
Content="{DynamicResource settingfolder}" />
25262526
<Button
2527+
Name="ClearLogFolderBtn"
25272528
Margin="0,0,12,0"
25282529
Click="ClearLogFolder"
2529-
Content="{DynamicResource clearlogfolder}" />
2530+
Content="{Binding CheckLogFolder, UpdateSourceTrigger=PropertyChanged}" />
25302531
<Button Click="OpenLogFolder" Content="{DynamicResource logfolder}" />
25312532
</StackPanel>
25322533
<TextBlock Style="{StaticResource Glyph}">

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ private void ClearLogFolder(object sender, RoutedEventArgs e)
279279
{
280280
file.Delete();
281281
}
282+
ClearLogFolderBtn.Content = viewModel.CheckLogFolder;
282283
}
283284
else
284285
{

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,39 @@ public FamilyTypeface SelectedResultFontFaces
555555
public string Github => Constant.GitHub;
556556
public static string Version => Constant.Version;
557557
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
558+
public string CheckLogFolder
559+
{
560+
get
561+
{
562+
DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(DataLocation.DataDirectory(), Constant.Logs, Constant.Version));
563+
long size = 0;
564+
foreach (FileInfo fi in dirInfo.GetFiles("*", SearchOption.AllDirectories))
565+
{
566+
size += fi.Length;
567+
}
568+
return string.Format(_translater.GetTranslation("clearlogfolder")) + " (" + FormatBytes(size) + ")" ;
569+
}
570+
set
571+
{
572+
}
573+
574+
}
575+
576+
public string FormatBytes(long bytes)
577+
{
578+
const int scale = 1024;
579+
string[] orders = new string[] { "GB", "MB", "KB", "Bytes" };
580+
long max = (long)Math.Pow(scale, orders.Length - 1);
581+
582+
foreach (string order in orders)
583+
{
584+
if (bytes > max)
585+
return string.Format("{0:##.##} {1}", decimal.Divide(bytes, max), order);
586+
587+
max /= scale;
588+
}
589+
return "0 Bytes";
590+
}
558591
#endregion
559592
}
560593
}

0 commit comments

Comments
 (0)