mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 11:14:25 +00:00
Use dark media type logos
This commit is contained in:
@@ -54,6 +54,7 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
|
using Avalonia.Styling;
|
||||||
using Avalonia.Svg;
|
using Avalonia.Svg;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
@@ -105,7 +106,19 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
var genericFolderIcon =
|
var genericFolderIcon =
|
||||||
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/inode-directory.png")));
|
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/inode-directory.png")));
|
||||||
|
|
||||||
var mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.svg");
|
// Check if we're using dark theme
|
||||||
|
bool isDarkTheme = view.ActualThemeVariant == ThemeVariant.Dark;
|
||||||
|
|
||||||
|
// Build the appropriate SVG path based on theme
|
||||||
|
string svgPath = isDarkTheme
|
||||||
|
? $"avares://Aaru.Gui/Assets/Logos/Media/Dark/{imageFormat.Info.MediaType}.svg"
|
||||||
|
: $"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.svg";
|
||||||
|
|
||||||
|
var mediaResource = new Uri(svgPath);
|
||||||
|
|
||||||
|
// Fallback to light theme version if dark version doesn't exist
|
||||||
|
if(isDarkTheme && !AssetLoader.Exists(mediaResource))
|
||||||
|
mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.svg");
|
||||||
|
|
||||||
MediaLogo = AssetLoader.Exists(mediaResource)
|
MediaLogo = AssetLoader.Exists(mediaResource)
|
||||||
? new SvgImage
|
? new SvgImage
|
||||||
@@ -180,8 +193,10 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle))
|
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle))
|
||||||
|
{
|
||||||
MediaTitleText =
|
MediaTitleText =
|
||||||
string.Format(Aaru.Localization.Core.Media_title_0_WithMarkup, imageFormat.Info.MediaTitle);
|
string.Format(Aaru.Localization.Core.Media_title_0_WithMarkup, imageFormat.Info.MediaTitle);
|
||||||
|
}
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaManufacturer))
|
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaManufacturer))
|
||||||
{
|
{
|
||||||
@@ -190,8 +205,10 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaModel))
|
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaModel))
|
||||||
|
{
|
||||||
MediaModelText =
|
MediaModelText =
|
||||||
string.Format(Aaru.Localization.Core.Media_model_0_WithMarkup, imageFormat.Info.MediaModel);
|
string.Format(Aaru.Localization.Core.Media_model_0_WithMarkup, imageFormat.Info.MediaModel);
|
||||||
|
}
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaSerialNumber))
|
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaSerialNumber))
|
||||||
{
|
{
|
||||||
@@ -218,8 +235,10 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.DriveModel))
|
if(!string.IsNullOrWhiteSpace(imageFormat.Info.DriveModel))
|
||||||
|
{
|
||||||
DriveModelText =
|
DriveModelText =
|
||||||
string.Format(Aaru.Localization.Core.Drive_model_0_WithMarkup, imageFormat.Info.DriveModel);
|
string.Format(Aaru.Localization.Core.Drive_model_0_WithMarkup, imageFormat.Info.DriveModel);
|
||||||
|
}
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.DriveSerialNumber))
|
if(!string.IsNullOrWhiteSpace(imageFormat.Info.DriveSerialNumber))
|
||||||
{
|
{
|
||||||
@@ -245,8 +264,9 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(imageFormat.Info.ReadableMediaTags is { Count: > 0 })
|
if(imageFormat.Info.ReadableMediaTags is { Count: > 0 })
|
||||||
foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.Order())
|
{
|
||||||
MediaTagsList.Add(tag.Humanize());
|
foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.Order()) MediaTagsList.Add(tag.Humanize());
|
||||||
|
}
|
||||||
|
|
||||||
if(imageFormat.Info.ReadableSectorTags is { Count: > 0 })
|
if(imageFormat.Info.ReadableSectorTags is { Count: > 0 })
|
||||||
{
|
{
|
||||||
@@ -765,9 +785,8 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(opticalMediaImage.Sessions is { Count: > 0 })
|
if(opticalMediaImage.Sessions is { Count: > 0 })
|
||||||
{
|
foreach(Session session in opticalMediaImage.Sessions)
|
||||||
foreach(Session session in opticalMediaImage.Sessions) Sessions.Add(session);
|
Sessions.Add(session);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -777,9 +796,8 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(opticalMediaImage.Tracks is { Count: > 0 })
|
if(opticalMediaImage.Tracks is { Count: > 0 })
|
||||||
{
|
foreach(Track track in opticalMediaImage.Tracks)
|
||||||
foreach(Track track in opticalMediaImage.Tracks) Tracks.Add(track);
|
Tracks.Add(track);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
|||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
|
using Avalonia.Styling;
|
||||||
using Avalonia.Svg;
|
using Avalonia.Svg;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
@@ -439,8 +440,20 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we're using dark theme
|
||||||
|
bool isDarkTheme = _view.ActualThemeVariant == ThemeVariant.Dark;
|
||||||
|
|
||||||
|
// Build the appropriate SVG path based on theme
|
||||||
|
string svgPath = isDarkTheme
|
||||||
|
? $"avares://Aaru.Gui/Assets/Logos/Media/Dark/{imageFormat.Info.MediaType}.svg"
|
||||||
|
: $"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.svg";
|
||||||
|
|
||||||
// Create image model with appropriate icon based on media type
|
// Create image model with appropriate icon based on media type
|
||||||
var mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.svg");
|
var mediaResource = new Uri(svgPath);
|
||||||
|
|
||||||
|
// Fallback to light theme version if dark version doesn't exist
|
||||||
|
if(isDarkTheme && !AssetLoader.Exists(mediaResource))
|
||||||
|
mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.svg");
|
||||||
|
|
||||||
var imageModel = new ImageModel
|
var imageModel = new ImageModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,18 +81,9 @@
|
|||||||
<Grid Grid.Row="0"
|
<Grid Grid.Row="0"
|
||||||
ColumnDefinitions="Auto,*"
|
ColumnDefinitions="Auto,*"
|
||||||
ColumnSpacing="16">
|
ColumnSpacing="16">
|
||||||
<Border Grid.Column="0"
|
<Image Width="128"
|
||||||
Width="160"
|
Height="128"
|
||||||
Height="160"
|
Source="{Binding MediaLogo, Mode=OneWay}" />
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Background="LightGray"
|
|
||||||
CornerRadius="80"
|
|
||||||
Padding="16">
|
|
||||||
<Image Width="128"
|
|
||||||
Height="128"
|
|
||||||
Source="{Binding MediaLogo, Mode=OneWay}" />
|
|
||||||
</Border>
|
|
||||||
<StackPanel Grid.Column="1"
|
<StackPanel Grid.Column="1"
|
||||||
Spacing="8"
|
Spacing="8"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center">
|
||||||
|
|||||||
@@ -274,14 +274,9 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</StackPanel.ContextMenu>
|
</StackPanel.ContextMenu>
|
||||||
<Border Width="32"
|
<Image Width="24"
|
||||||
Height="32"
|
Height="24"
|
||||||
Background="LightGray"
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
CornerRadius="16">
|
|
||||||
<Image Width="24"
|
|
||||||
Height="24"
|
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
|
||||||
</Border>
|
|
||||||
<TextBlock Text="{Binding FileName, Mode=OneWay}"
|
<TextBlock Text="{Binding FileName, Mode=OneWay}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -290,14 +285,9 @@
|
|||||||
ItemsSource="{Binding Partitions, Mode=OneWay}">
|
ItemsSource="{Binding Partitions, Mode=OneWay}">
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
<Border Width="32"
|
<Image Width="24"
|
||||||
Height="32"
|
Height="24"
|
||||||
Background="LightGray"
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
CornerRadius="16">
|
|
||||||
<Image Width="24"
|
|
||||||
Height="24"
|
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
|
||||||
</Border>
|
|
||||||
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -306,14 +296,9 @@
|
|||||||
ItemsSource="{Binding FileSystems, Mode=OneWay}">
|
ItemsSource="{Binding FileSystems, Mode=OneWay}">
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
<Border Width="32"
|
<Image Width="24"
|
||||||
Height="32"
|
Height="24"
|
||||||
Background="LightGray"
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
CornerRadius="16">
|
|
||||||
<Image Width="24"
|
|
||||||
Height="24"
|
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
|
||||||
</Border>
|
|
||||||
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -322,14 +307,9 @@
|
|||||||
ItemsSource="{Binding Roots, Mode=OneWay}">
|
ItemsSource="{Binding Roots, Mode=OneWay}">
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
<Border Width="32"
|
<Image Width="24"
|
||||||
Height="32"
|
Height="24"
|
||||||
Background="LightGray"
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
CornerRadius="16">
|
|
||||||
<Image Width="24"
|
|
||||||
Height="24"
|
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
|
||||||
</Border>
|
|
||||||
<TextBlock Text="{Binding VolumeName, Mode=OneWay}"
|
<TextBlock Text="{Binding VolumeName, Mode=OneWay}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -338,14 +318,9 @@
|
|||||||
ItemsSource="{Binding Subdirectories, Mode=OneWay}">
|
ItemsSource="{Binding Subdirectories, Mode=OneWay}">
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
<Border Width="32"
|
<Image Width="24"
|
||||||
Height="32"
|
Height="24"
|
||||||
Background="LightGray"
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
CornerRadius="16">
|
|
||||||
<Image Width="24"
|
|
||||||
Height="24"
|
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
|
||||||
</Border>
|
|
||||||
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
Reference in New Issue
Block a user