mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add colors.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
@@ -18,4 +18,8 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
10
Aaru.Tui/Models/FileModel.cs
Normal file
10
Aaru.Tui/Models/FileModel.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Aaru.Tui.Models;
|
||||
|
||||
public class FileModel
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public IBrush ForegroundBrush { get; set; } // Add this property for ListBox Foreground binding
|
||||
}
|
||||
@@ -1,17 +1,23 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reflection;
|
||||
using System.Windows.Input;
|
||||
using Aaru.Helpers;
|
||||
using Aaru.Tui.Models;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Color = Avalonia.Media.Color;
|
||||
|
||||
namespace Aaru.Tui.ViewModels.Windows;
|
||||
|
||||
public sealed class MainWindowViewModel : ViewModelBase
|
||||
public sealed partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty]
|
||||
ObservableCollection<string> _files = [];
|
||||
public string _copyright;
|
||||
[ObservableProperty]
|
||||
ObservableCollection<FileModel> _files = [];
|
||||
[ObservableProperty]
|
||||
public string _informationalVersion;
|
||||
|
||||
@@ -24,6 +30,8 @@ public sealed class MainWindowViewModel : ViewModelBase
|
||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
?.InformationalVersion ??
|
||||
"?.?.?";
|
||||
|
||||
Copyright = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>()?.Copyright ?? "";
|
||||
}
|
||||
|
||||
public ICommand ExitCommand { get; }
|
||||
@@ -36,10 +44,47 @@ public sealed class MainWindowViewModel : ViewModelBase
|
||||
|
||||
public void LoadComplete()
|
||||
{
|
||||
Files.Add("..");
|
||||
var parentDirectory = new FileModel
|
||||
{
|
||||
Filename = "..",
|
||||
Path = Path.GetRelativePath(Directory.GetCurrentDirectory(), ".."),
|
||||
ForegroundBrush =
|
||||
new SolidColorBrush(Color.Parse(DirColorsParser.Instance.DirectoryColor ??
|
||||
DirColorsParser.Instance.NormalColor))
|
||||
};
|
||||
|
||||
Files.Add(parentDirectory);
|
||||
|
||||
foreach(FileModel model in Directory
|
||||
.GetDirectories(Directory.GetCurrentDirectory(), "*", SearchOption.TopDirectoryOnly)
|
||||
.Select(directory => new FileModel
|
||||
{
|
||||
Path = directory,
|
||||
Filename = Path.GetFileName(directory),
|
||||
ForegroundBrush =
|
||||
new SolidColorBrush(Color.Parse(DirColorsParser.Instance.DirectoryColor ??
|
||||
DirColorsParser.Instance.NormalColor))
|
||||
}))
|
||||
Files.Add(model);
|
||||
|
||||
foreach(string file in
|
||||
Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.TopDirectoryOnly))
|
||||
Files.Add(Path.GetFileName(file));
|
||||
Directory.GetFiles(Directory.GetCurrentDirectory(), "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
var model = new FileModel
|
||||
{
|
||||
Path = file,
|
||||
Filename = Path.GetFileName(file)
|
||||
};
|
||||
|
||||
string extension = Path.GetExtension(file);
|
||||
|
||||
model.ForegroundBrush =
|
||||
new SolidColorBrush(Color.Parse(DirColorsParser.Instance.ExtensionColors.TryGetValue(extension,
|
||||
out string? hex)
|
||||
? hex
|
||||
: DirColorsParser.Instance.NormalColor));
|
||||
|
||||
Files.Add(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:console="https://github.com/jinek/consolonia"
|
||||
xmlns:windows="clr-namespace:Aaru.Tui.ViewModels.Windows"
|
||||
xmlns:models="clr-namespace:Aaru.Tui.Models"
|
||||
x:Class="Aaru.Tui.Views.Windows.MainWindow"
|
||||
RequestedThemeVariant="Dark"
|
||||
Title="Aaru">
|
||||
@@ -22,7 +23,15 @@
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
<ListBox Grid.Column="0"
|
||||
ItemsSource="{Binding Files, Mode=OneWay}"
|
||||
BorderThickness="1">
|
||||
BorderThickness="1"
|
||||
Background="Transparent">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="models:FileModel">
|
||||
<TextBox Text="{Binding Filename}"
|
||||
Foreground="{Binding ForegroundBrush, Mode=OneWay}"
|
||||
Background="Transparent" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.BorderBrush>
|
||||
<console:LineBrush LineStyle="DoubleLine"
|
||||
Brush="Blue" />
|
||||
@@ -39,8 +48,15 @@
|
||||
<StackPanel Grid.Row="0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center">
|
||||
<TextBlock Text="Aaru Data Preservation Suite" />
|
||||
<TextBlock Text="{Binding InformationalVersion}" />
|
||||
<TextBlock Text="Aaru Data Preservation Suite"
|
||||
Foreground="Red"
|
||||
FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding InformationalVersion}"
|
||||
Foreground="Green"
|
||||
FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Copyright}"
|
||||
Foreground="Blue"
|
||||
FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@@ -4,7 +4,7 @@ using Avalonia.Interactivity;
|
||||
|
||||
namespace Aaru.Tui.Views.Windows;
|
||||
|
||||
public class MainWindow : Window
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user