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>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -18,4 +18,8 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</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.Collections.ObjectModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Aaru.Helpers;
|
||||||
|
using Aaru.Tui.Models;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Media;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Color = Avalonia.Media.Color;
|
||||||
|
|
||||||
namespace Aaru.Tui.ViewModels.Windows;
|
namespace Aaru.Tui.ViewModels.Windows;
|
||||||
|
|
||||||
public sealed class MainWindowViewModel : ViewModelBase
|
public sealed partial class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
ObservableCollection<string> _files = [];
|
public string _copyright;
|
||||||
|
[ObservableProperty]
|
||||||
|
ObservableCollection<FileModel> _files = [];
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public string _informationalVersion;
|
public string _informationalVersion;
|
||||||
|
|
||||||
@@ -24,6 +30,8 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||||
?.InformationalVersion ??
|
?.InformationalVersion ??
|
||||||
"?.?.?";
|
"?.?.?";
|
||||||
|
|
||||||
|
Copyright = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>()?.Copyright ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand ExitCommand { get; }
|
public ICommand ExitCommand { get; }
|
||||||
@@ -36,10 +44,47 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
public void LoadComplete()
|
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
|
foreach(string file in
|
||||||
Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.TopDirectoryOnly))
|
Directory.GetFiles(Directory.GetCurrentDirectory(), "*", SearchOption.TopDirectoryOnly))
|
||||||
Files.Add(Path.GetFileName(file));
|
{
|
||||||
|
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:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:console="https://github.com/jinek/consolonia"
|
xmlns:console="https://github.com/jinek/consolonia"
|
||||||
xmlns:windows="clr-namespace:Aaru.Tui.ViewModels.Windows"
|
xmlns:windows="clr-namespace:Aaru.Tui.ViewModels.Windows"
|
||||||
|
xmlns:models="clr-namespace:Aaru.Tui.Models"
|
||||||
x:Class="Aaru.Tui.Views.Windows.MainWindow"
|
x:Class="Aaru.Tui.Views.Windows.MainWindow"
|
||||||
RequestedThemeVariant="Dark"
|
RequestedThemeVariant="Dark"
|
||||||
Title="Aaru">
|
Title="Aaru">
|
||||||
@@ -22,7 +23,15 @@
|
|||||||
<Grid ColumnDefinitions="*,*">
|
<Grid ColumnDefinitions="*,*">
|
||||||
<ListBox Grid.Column="0"
|
<ListBox Grid.Column="0"
|
||||||
ItemsSource="{Binding Files, Mode=OneWay}"
|
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>
|
<ListBox.BorderBrush>
|
||||||
<console:LineBrush LineStyle="DoubleLine"
|
<console:LineBrush LineStyle="DoubleLine"
|
||||||
Brush="Blue" />
|
Brush="Blue" />
|
||||||
@@ -39,8 +48,15 @@
|
|||||||
<StackPanel Grid.Row="0"
|
<StackPanel Grid.Row="0"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
HorizontalAlignment="Center">
|
HorizontalAlignment="Center">
|
||||||
<TextBlock Text="Aaru Data Preservation Suite" />
|
<TextBlock Text="Aaru Data Preservation Suite"
|
||||||
<TextBlock Text="{Binding InformationalVersion}" />
|
Foreground="Red"
|
||||||
|
FontWeight="Bold" />
|
||||||
|
<TextBlock Text="{Binding InformationalVersion}"
|
||||||
|
Foreground="Green"
|
||||||
|
FontWeight="Bold" />
|
||||||
|
<TextBlock Text="{Binding Copyright}"
|
||||||
|
Foreground="Blue"
|
||||||
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Avalonia.Interactivity;
|
|||||||
|
|
||||||
namespace Aaru.Tui.Views.Windows;
|
namespace Aaru.Tui.Views.Windows;
|
||||||
|
|
||||||
public class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user