Add Description for nuget info panel

This commit is contained in:
ema
2026-04-25 10:32:10 +08:00
parent 5a9f12a3dc
commit 608d391e5d
4 changed files with 50 additions and 21 deletions
@@ -52,6 +52,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="1"
@@ -143,18 +144,17 @@
Grid.Row="7"
Grid.Column="1"
Padding="3"
Visibility="Collapsed"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="Project Website" />
Text="Project Website"
Visibility="Collapsed" />
<TextBlock x:Name="projectUrlBlock"
Grid.Row="7"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
Visibility="Collapsed"
TextTrimming="CharacterEllipsis">
<Hyperlink x:Name="projectUrlLink"
RequestNavigate="OnHyperlinkNavigate">
TextTrimming="CharacterEllipsis"
Visibility="Collapsed">
<Hyperlink x:Name="projectUrlLink" RequestNavigate="OnHyperlinkNavigate">
<Run x:Name="projectUrlText" />
</Hyperlink>
</TextBlock>
@@ -163,18 +163,17 @@
Grid.Row="8"
Grid.Column="1"
Padding="3"
Visibility="Collapsed"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="Source Repository" />
Text="Source Repository"
Visibility="Collapsed" />
<TextBlock x:Name="repoUrlBlock"
Grid.Row="8"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
Visibility="Collapsed"
TextTrimming="CharacterEllipsis">
<Hyperlink x:Name="repoUrlLink"
RequestNavigate="OnHyperlinkNavigate">
TextTrimming="CharacterEllipsis"
Visibility="Collapsed">
<Hyperlink x:Name="repoUrlLink" RequestNavigate="OnHyperlinkNavigate">
<Run x:Name="repoUrlText" />
</Hyperlink>
</TextBlock>
@@ -223,9 +222,37 @@
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="Searching..."
TextTrimming="CharacterEllipsis" />
<!-- Description -->
<GroupBox x:Name="descriptionGroupBox"
Grid.Row="12"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="3,3,16,3"
Padding="3"
Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Header="Description">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ScrollViewer.Resources>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
</ScrollViewer.Resources>
<TextBox x:Name="description"
Margin="8,3,16,3"
AcceptsReturn="True"
IsReadOnly="True"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</ScrollViewer>
</GroupBox>
<!-- Dependencies -->
<GroupBox x:Name="dependenciesGroupBox"
Grid.Row="12"
Grid.Row="13"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="3,3,16,16"
@@ -53,6 +53,7 @@ public partial class NugetInfoPanel : UserControl, IAppInfoPanel
totalSizeTitle.Text = TranslationHelper.Get("TOTAL_SIZE", translationFile);
modDateTitle.Text = TranslationHelper.Get("LAST_MODIFIED", translationFile);
dependenciesGroupBox.Header = TranslationHelper.Get("NUGET_DEPENDENCIES", translationFile);
descriptionGroupBox.Header = TranslationHelper.Get("DESCRIPTION", translationFile);
}
public void DisplayInfo(string path)
@@ -105,6 +106,9 @@ public partial class NugetInfoPanel : UserControl, IAppInfoPanel
totalSize.Text = size.ToPrettySize(2);
modDate.Text = last.ToString(CultureInfo.CurrentCulture);
// Description
description.Text = nugetInfo.Description ?? string.Empty;
// Dependencies
if (nugetInfo.Dependencies?.Length > 0)
{
@@ -116,11 +116,10 @@ public static class NugetParser
if (groups.Count > 0)
{
// Collect distinct target frameworks
info.TargetFrameworks = groups
info.TargetFrameworks = [.. groups
.Select(g => g.Attribute("targetFramework")?.Value?.Trim())
.Where(s => !string.IsNullOrEmpty(s))
.Distinct()
.ToArray();
.Distinct()];
// Format all dependencies grouped by framework
var depLines = new List<string>();
@@ -142,20 +141,19 @@ public static class NugetParser
depLines.Add($" {line}");
}
}
info.Dependencies = depLines.ToArray();
info.Dependencies = [.. depLines];
}
else
{
// No groups — direct top-level dependencies
info.Dependencies = depsEl.Elements(ns + "dependency")
info.Dependencies = [.. depsEl.Elements(ns + "dependency")
.Select(d =>
{
string id = d.Attribute("id")?.Value?.Trim() ?? string.Empty;
string ver = d.Attribute("version")?.Value?.Trim() ?? string.Empty;
return string.IsNullOrEmpty(ver) ? id : $"{id} ({ver})";
})
.Where(s => !string.IsNullOrWhiteSpace(s))
.ToArray();
.Where(s => !string.IsNullOrWhiteSpace(s))];
}
}
}
@@ -91,7 +91,7 @@ public sealed class Plugin : IViewer
".appimage" => new Size { Width = 600, Height = 300 },
".rpm" => new Size { Width = 600, Height = 260 },
".wgt" or ".wgtu" => new Size { Width = 600, Height = 345 },
".nupkg" or ".snupkg" => new Size { Width = 660, Height = 580 },
".nupkg" or ".snupkg" => new Size { Width = 700, Height = 580 },
_ => throw new NotSupportedException("Extension is not supported."),
};
context.Title = string.Empty;