Add LogFolderSize in label

This commit is contained in:
DB p 2022-09-27 15:44:00 +09:00
parent 33969041a9
commit ab8082767e
3 changed files with 36 additions and 1 deletions

View file

@ -2524,9 +2524,10 @@
Click="OpenSettingFolder"
Content="{DynamicResource settingfolder}" />
<Button
Name="ClearLogFolderBtn"
Margin="0,0,12,0"
Click="ClearLogFolder"
Content="{DynamicResource clearlogfolder}" />
Content="{Binding CheckLogFolder, UpdateSourceTrigger=PropertyChanged}" />
<Button Click="OpenLogFolder" Content="{DynamicResource logfolder}" />
</StackPanel>
<TextBlock Style="{StaticResource Glyph}">

View file

@ -279,6 +279,7 @@ namespace Flow.Launcher
{
file.Delete();
}
ClearLogFolderBtn.Content = viewModel.CheckLogFolder;
}
else
{

View file

@ -555,6 +555,39 @@ namespace Flow.Launcher.ViewModel
public string Github => Constant.GitHub;
public static string Version => Constant.Version;
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
public string CheckLogFolder
{
get
{
DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(DataLocation.DataDirectory(), Constant.Logs, Constant.Version));
long size = 0;
foreach (FileInfo fi in dirInfo.GetFiles("*", SearchOption.AllDirectories))
{
size += fi.Length;
}
return string.Format(_translater.GetTranslation("clearlogfolder")) + " (" + FormatBytes(size) + ")" ;
}
set
{
}
}
public string FormatBytes(long bytes)
{
const int scale = 1024;
string[] orders = new string[] { "GB", "MB", "KB", "Bytes" };
long max = (long)Math.Pow(scale, orders.Length - 1);
foreach (string order in orders)
{
if (bytes > max)
return string.Format("{0:##.##} {1}", decimal.Divide(bytes, max), order);
max /= scale;
}
return "0 Bytes";
}
#endregion
}
}