Console size scan
This commit is contained in:
@@ -3,7 +3,7 @@ using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using FileTime.App.ContainerSizeScanner;
|
||||
using FileTime.GuiApp.App.Helper;
|
||||
using FileTime.App.Core.Helpers;
|
||||
|
||||
namespace FileTime.GuiApp.App.Converters;
|
||||
|
||||
@@ -16,18 +16,12 @@ public class ItemSizeToBrushConverter : IMultiValueConverter
|
||||
{
|
||||
if (values is [ISizePreviewItem previewItem, ContainerPreview sizeContainerViewModel])
|
||||
{
|
||||
var items = sizeContainerViewModel.TopItems;
|
||||
var i = 0;
|
||||
for (; i < items.Count; i++)
|
||||
{
|
||||
if (items[i].Name == previewItem.Name) break;
|
||||
}
|
||||
|
||||
var hue = (360d * i / (items.Count < 1 ? 1 : items.Count)) + HueDiff;
|
||||
if (hue > 360) hue -= 360;
|
||||
if (hue < 0) hue += 360;
|
||||
|
||||
var (r, g, b) = ColorHelper.HlsToRgb(hue, Lightness, 1);
|
||||
var (r, g, b) = SizePreviewItemHelper.GetItemColor(
|
||||
sizeContainerViewModel.TopItems,
|
||||
previewItem,
|
||||
HueDiff,
|
||||
Lightness
|
||||
);
|
||||
|
||||
var task = Dispatcher.UIThread.InvokeAsync(() => new SolidColorBrush(Color.FromRgb(r, g, b)));
|
||||
task.Wait();
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
namespace FileTime.GuiApp.App.Helper;
|
||||
|
||||
public static class ColorHelper
|
||||
{
|
||||
// Convert an HLS value into an RGB value.
|
||||
public static (byte r, byte g, byte b) HlsToRgb(double h, double l, double s)
|
||||
{
|
||||
double p2;
|
||||
if (l <= 0.5) p2 = l * (1 + s);
|
||||
else p2 = l + s - l * s;
|
||||
|
||||
var p1 = 2 * l - p2;
|
||||
double doubleR, doubleG, doubleB;
|
||||
if (s == 0)
|
||||
{
|
||||
doubleR = l;
|
||||
doubleG = l;
|
||||
doubleB = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
doubleR = QqhToRgb(p1, p2, h + 120);
|
||||
doubleG = QqhToRgb(p1, p2, h);
|
||||
doubleB = QqhToRgb(p1, p2, h - 120);
|
||||
}
|
||||
|
||||
// Convert RGB to the 0 to 255 range.
|
||||
return ((byte) (doubleR * 255.0),
|
||||
(byte) (doubleG * 255.0),
|
||||
(byte) (doubleB * 255.0));
|
||||
}
|
||||
|
||||
private static double QqhToRgb(double q1, double q2, double hue)
|
||||
{
|
||||
if (hue > 360) hue -= 360;
|
||||
else if (hue < 0) hue += 360;
|
||||
|
||||
if (hue < 60) return q1 + (q2 - q1) * hue / 60;
|
||||
if (hue < 180) return q2;
|
||||
if (hue < 240) return q1 + (q2 - q1) * (240 - hue) / 60;
|
||||
return q1;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,52 @@
|
||||
<UserControl
|
||||
Background="{Binding ViewMode.Value, Converter={StaticResource ItemViewModeToBackgroundConverter}}"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d"
|
||||
x:Class="FileTime.GuiApp.App.Views.ItemView"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="appcore:IItemViewModel"
|
||||
x:Name="ItemRoot"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:appcore="using:FileTime.App.Core.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:guiappvm="using:FileTime.GuiApp.App.ViewModels"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:traits="clr-namespace:FileTime.App.Core.Models.Traits;assembly=FileTime.App.Core.Abstraction"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
x:Name="ItemRoot"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="appcore:IItemViewModel"
|
||||
Background="{Binding ViewMode.Value, Converter={StaticResource ItemViewModeToBackgroundConverter}}"
|
||||
mc:Ignorable="d">
|
||||
<Grid
|
||||
ColumnDefinitions="20,*,Auto"
|
||||
x:Name="RootGrid"
|
||||
Margin="3"
|
||||
x:Name="RootGrid">
|
||||
ColumnDefinitions="20,*,Auto">
|
||||
<Grid.Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="Foreground" Value="{Binding DataContext.ViewMode.Value, Converter={StaticResource ItemViewModeToForegroundConverter}, ElementName=ItemRoot}" x:CompileBindings="False" />
|
||||
<Setter x:CompileBindings="False" Property="Foreground" Value="{Binding DataContext.ViewMode.Value, Converter={StaticResource ItemViewModeToForegroundConverter}, ElementName=ItemRoot}" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Image
|
||||
Width="18"
|
||||
Height="18"
|
||||
HorizontalAlignment="Left"
|
||||
Source="{Binding Converter={StaticResource ItemToImageConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Width="18" />
|
||||
Source="{Binding Converter={StaticResource ItemToImageConverter}}" />
|
||||
|
||||
<ItemsControl
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="5,0,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center">
|
||||
<ItemsControl.ItemsSource>
|
||||
<MultiBinding Converter="{StaticResource NamePartShrinkerConverter}">
|
||||
<MultiBinding.Bindings>
|
||||
<Binding Path="DisplayName^" />
|
||||
<Binding ElementName="RootGrid" Path="Bounds.Width" />
|
||||
<Binding ElementName="ItemRoot" Path="ShowAttributes" />
|
||||
<Binding
|
||||
ElementName="RootGrid"
|
||||
Path="Bounds.Width" />
|
||||
<Binding
|
||||
ElementName="ItemRoot"
|
||||
Path="ShowAttributes" />
|
||||
</MultiBinding.Bindings>
|
||||
</MultiBinding>
|
||||
</ItemsControl.ItemsSource>
|
||||
@@ -54,52 +58,50 @@
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="guiappvm:ItemNamePartViewModel">
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding Text}" TextDecorations="{Binding TextDecorations}" />
|
||||
<TextBlock
|
||||
Text="{Binding Text}"
|
||||
TextDecorations="{Binding TextDecorations}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<Grid Grid.Column="2" IsVisible="{Binding ShowAttributes, ElementName=ItemRoot}">
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Grid
|
||||
Grid.Column="2"
|
||||
IsVisible="{Binding ShowAttributes, ElementName=ItemRoot}">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Width="50"
|
||||
Classes="SmallText"
|
||||
IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type appcore:IElementViewModel}}"
|
||||
Text="{Binding BaseItem.DisplayName, Converter={StaticResource GetFileExtensionConverter}}"
|
||||
Width="50" />
|
||||
<Grid DataContext="{Binding BaseItem}" IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}">
|
||||
Text="{Binding BaseItem.DisplayName, Converter={StaticResource GetFileExtensionConverter}}" />
|
||||
<Grid
|
||||
DataContext="{Binding BaseItem}"
|
||||
IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}">
|
||||
<TextBlock
|
||||
Width="60"
|
||||
x:DataType="traits:ISizeProvider"
|
||||
Classes="SmallText"
|
||||
Text="{Binding Size.Value, Converter={StaticResource FormatSizeConverter}}"
|
||||
TextAlignment="Right"
|
||||
Width="60"
|
||||
x:DataType="traits:ISizeProvider" />
|
||||
</Grid>
|
||||
<Grid IsVisible="{Binding BaseItem, Converter={StaticResource IsNotTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}">
|
||||
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}"
|
||||
Text="{Binding Size.Value, Converter={StaticResource FormatSizeConverter}}"
|
||||
TextAlignment="Right"
|
||||
Width="60"
|
||||
x:DataType="traits:ISizeProvider" />
|
||||
TextAlignment="Right" />
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Width="95"
|
||||
Classes="SmallText"
|
||||
Text="{Binding ModifiedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=yyyy-MM-dd}"
|
||||
TextAlignment="Right"
|
||||
Width="95" />
|
||||
TextAlignment="Right" />
|
||||
<TextBlock
|
||||
Width="35"
|
||||
Classes="SmallText"
|
||||
Text="{Binding ModifiedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=hh:mm}"
|
||||
TextAlignment="Right"
|
||||
Width="35" />
|
||||
TextAlignment="Right" />
|
||||
<TextBlock
|
||||
Width="45"
|
||||
Classes="SmallText"
|
||||
Text="{Binding BaseItem.Attributes}"
|
||||
TextAlignment="Right"
|
||||
Width="45" />
|
||||
TextAlignment="Right" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public class ItemPreview
|
||||
SupportsDelete.True,
|
||||
true,
|
||||
"attr",
|
||||
0,
|
||||
null!,
|
||||
PointInTime.Present,
|
||||
new ObservableCollection<Exception>(),
|
||||
|
||||
@@ -10,7 +10,6 @@ using FileTime.GuiApp.App.Font;
|
||||
using FileTime.GuiApp.App.ViewModels;
|
||||
using FileTime.GuiApp.App.Views;
|
||||
using FileTime.Server;
|
||||
using FileTime.Server.Common;
|
||||
using FileTime.Tools.Compression;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
Reference in New Issue
Block a user