Show Git, Cloud, and created date in Details, and hide Free space except on drives.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 22:07:35 +02:00
parent ff070beba4
commit b72c375e87
10 changed files with 371 additions and 17 deletions

View File

@@ -0,0 +1,59 @@
using System.Windows;
using System.Windows.Controls;
namespace Explorer.App;
public static class DetailsColumnLayout
{
public static readonly DependencyProperty ShowFreeSpaceProperty =
DependencyProperty.RegisterAttached(
"ShowFreeSpace",
typeof(bool),
typeof(DetailsColumnLayout),
new PropertyMetadata(true, OnShowFreeSpaceChanged));
public static void SetShowFreeSpace(ListView element, bool value)
=> element.SetValue(ShowFreeSpaceProperty, value);
public static bool GetShowFreeSpace(ListView element)
=> (bool)element.GetValue(ShowFreeSpaceProperty);
private static void OnShowFreeSpaceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ListView list)
{
Apply(list);
list.Loaded -= OnLoaded;
list.Loaded += OnLoaded;
}
}
private static void OnLoaded(object sender, RoutedEventArgs e)
{
if (sender is ListView list)
{
Apply(list);
}
}
private static void Apply(ListView list)
{
if (list.View is not GridView view)
{
return;
}
var show = GetShowFreeSpace(list);
foreach (var column in view.Columns)
{
var title = column.Header?.ToString() ?? "";
title = title.Replace(" ▲", "", StringComparison.Ordinal).Replace(" ▼", "", StringComparison.Ordinal).Trim();
if (title == "Free space")
{
column.Width = show ? 110 : 0;
}
}
ListViewLayout.Stretch(list);
}
}