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:
59
src/Explorer.App/DetailsColumnLayout.cs
Normal file
59
src/Explorer.App/DetailsColumnLayout.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user