#0054 关于页面新增库版本的显示
This commit is contained in:
@@ -0,0 +1,170 @@
|
|||||||
|
using System;
|
||||||
|
using Prism.Mvvm;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace XplorePlane.ViewModels
|
||||||
|
{
|
||||||
|
public class LibraryVersionItem : BindableBase
|
||||||
|
{
|
||||||
|
public string Category { get; set; } = "";
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string Version { get; set; } = "";
|
||||||
|
public string Path { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LibraryVersionsViewModel : BindableBase
|
||||||
|
{
|
||||||
|
public ObservableCollection<LibraryVersionItem> Libraries { get; } = new();
|
||||||
|
|
||||||
|
public string AppVersion { get; }
|
||||||
|
|
||||||
|
public LibraryVersionsViewModel()
|
||||||
|
{
|
||||||
|
var appAsm = Assembly.GetEntryAssembly();
|
||||||
|
AppVersion = appAsm?.GetName().Version?.ToString() ?? "未知";
|
||||||
|
|
||||||
|
LoadLibraryVersions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadLibraryVersions()
|
||||||
|
{
|
||||||
|
AddAssemblyInfo("通信/公共库", "XP.Common");
|
||||||
|
AddAssemblyInfo("通信/公共库", "BR.AN.PviServices");
|
||||||
|
AddAssemblyInfo("通信/公共库", "Prism.DryIoc");
|
||||||
|
AddAssemblyInfo("通信/公共库", "Prism");
|
||||||
|
AddAssemblyInfo("通信/公共库", "DryIoc");
|
||||||
|
AddAssemblyInfo("通信/公共库", "Serilog");
|
||||||
|
AddAssemblyInfo("通信/公共库", "System.Data.SQLite");
|
||||||
|
AddAssemblyInfo("通信/公共库", "Microsoft.Data.Sqlite");
|
||||||
|
|
||||||
|
AddAssemblyInfo("图像处理库", "Emgu.CV");
|
||||||
|
AddAssemblyInfo("图像处理库", "Emgu.CV.Bitmap");
|
||||||
|
AddAssemblyInfo("图像处理库", "Microsoft.ML.OnnxRuntime");
|
||||||
|
AddAssemblyInfo("图像处理库", "XP.ImageProcessing.Core");
|
||||||
|
AddAssemblyInfo("图像处理库", "XP.ImageProcessing.Processors");
|
||||||
|
AddAssemblyInfo("图像处理库", "XP.ImageProcessing.CfgControl");
|
||||||
|
AddAssemblyInfo("图像处理库", "XP.ImageProcessing.RoiControl");
|
||||||
|
|
||||||
|
AddAssemblyInfo("相机库", "Basler.Pylon");
|
||||||
|
AddAssemblyInfo("相机库", "XP.Camera");
|
||||||
|
|
||||||
|
AddAssemblyInfo("UI 框架", "Fluent");
|
||||||
|
AddAssemblyInfo("UI 框架", "Telerik.Windows.Controls");
|
||||||
|
AddAssemblyInfo("UI 框架", "Telerik.Windows.Controls.GridView");
|
||||||
|
AddAssemblyInfo("UI 框架", "Telerik.Windows.Controls.Chart");
|
||||||
|
AddAssemblyInfo("UI 框架", "Telerik.Windows.Controls.Docking");
|
||||||
|
AddAssemblyInfo("UI 框架", "MahApps.Metro");
|
||||||
|
|
||||||
|
AddAssemblyInfo("硬件库", "XP.Hardware.RaySource");
|
||||||
|
AddAssemblyInfo("运行时", "System.Runtime", useLoaded: true);
|
||||||
|
|
||||||
|
AddOpenCvNativeVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddAssemblyInfo(string category, string assemblyName, bool useLoaded = false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Assembly? asm = null;
|
||||||
|
|
||||||
|
if (useLoaded)
|
||||||
|
{
|
||||||
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
if (a.GetName().Name == assemblyName)
|
||||||
|
{
|
||||||
|
asm = a;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
if (a.GetName().Name == assemblyName)
|
||||||
|
{
|
||||||
|
asm = a;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (asm == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
asm = Assembly.Load(assemblyName);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (asm != null)
|
||||||
|
{
|
||||||
|
var name = asm.GetName();
|
||||||
|
var fileVersion = FileVersionInfo.GetVersionInfo(asm.Location);
|
||||||
|
|
||||||
|
Libraries.Add(new LibraryVersionItem
|
||||||
|
{
|
||||||
|
Category = category,
|
||||||
|
Name = name.Name ?? assemblyName,
|
||||||
|
Version = fileVersion.FileVersion ?? name.Version?.ToString() ?? "未知",
|
||||||
|
Path = asm.Location
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Libraries.Add(new LibraryVersionItem
|
||||||
|
{
|
||||||
|
Category = category,
|
||||||
|
Name = assemblyName,
|
||||||
|
Version = "未加载",
|
||||||
|
Path = ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Libraries.Add(new LibraryVersionItem
|
||||||
|
{
|
||||||
|
Category = category,
|
||||||
|
Name = assemblyName,
|
||||||
|
Version = "读取失败",
|
||||||
|
Path = ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddOpenCvNativeVersion()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
var versionFile = Path.Combine(baseDir, "version_string.inc");
|
||||||
|
if (File.Exists(versionFile))
|
||||||
|
{
|
||||||
|
var content = File.ReadAllText(versionFile);
|
||||||
|
var match = System.Text.RegularExpressions.Regex.Match(content, @"OpenCV\s+([\d.]+)");
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
Libraries.Add(new LibraryVersionItem
|
||||||
|
{
|
||||||
|
Category = "图像处理库",
|
||||||
|
Name = "OpenCV (Native/cvextern)",
|
||||||
|
Version = match.Groups[1].Value,
|
||||||
|
Path = Path.Combine(baseDir, "cvextern.dll")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="XplorePlane.Views.LibraryVersionsView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="clr-namespace:XplorePlane.ViewModels">
|
||||||
|
<UserControl.DataContext>
|
||||||
|
<vm:LibraryVersionsViewModel />
|
||||||
|
</UserControl.DataContext>
|
||||||
|
<UserControl.Resources>
|
||||||
|
<Style x:Key="CategoryHeader" TargetType="TextBlock">
|
||||||
|
<Setter Property="FontSize" Value="14" />
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold" />
|
||||||
|
<Setter Property="Foreground" Value="#1565C0" />
|
||||||
|
<Setter Property="Margin" Value="0,12,0,4" />
|
||||||
|
</Style>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<Grid Margin="16">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="0" Margin="0,0,0,12">
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,0,0,4"
|
||||||
|
FontSize="18"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Text="引用库版本信息" />
|
||||||
|
<TextBlock
|
||||||
|
FontSize="12"
|
||||||
|
Foreground="Gray"
|
||||||
|
Text="{Binding AppVersion, StringFormat='应用程序版本: {0}'}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<DataGrid
|
||||||
|
x:Name="LibraryGrid"
|
||||||
|
Grid.Row="1"
|
||||||
|
AlternatingRowBackground="#F9F9F9"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
BorderBrush="#E0E0E0"
|
||||||
|
BorderThickness="1"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserDeleteRows="False"
|
||||||
|
ColumnHeaderHeight="32"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
IsReadOnly="True"
|
||||||
|
ItemsSource="{Binding Libraries}"
|
||||||
|
RowHeight="28"
|
||||||
|
SelectionMode="Single">
|
||||||
|
<DataGrid.GroupStyle>
|
||||||
|
<GroupStyle>
|
||||||
|
<GroupStyle.ContainerStyle>
|
||||||
|
<Style TargetType="GroupItem">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="GroupItem">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Style="{StaticResource CategoryHeader}" Text="{Binding Name}" />
|
||||||
|
<ItemsPresenter />
|
||||||
|
</StackPanel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</GroupStyle.ContainerStyle>
|
||||||
|
</GroupStyle>
|
||||||
|
</DataGrid.GroupStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="220"
|
||||||
|
Binding="{Binding Name}"
|
||||||
|
Header="库名称" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding Version}"
|
||||||
|
Header="版本" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using XplorePlane.ViewModels;
|
||||||
|
|
||||||
|
namespace XplorePlane.Views
|
||||||
|
{
|
||||||
|
public partial class LibraryVersionsView : UserControl
|
||||||
|
{
|
||||||
|
public LibraryVersionsView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
Loaded += (s, e) =>
|
||||||
|
{
|
||||||
|
if (DataContext is LibraryVersionsViewModel vm)
|
||||||
|
{
|
||||||
|
var view = CollectionViewSource.GetDefaultView(vm.Libraries);
|
||||||
|
if (view.GroupDescriptions.Count == 0)
|
||||||
|
{
|
||||||
|
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<Window
|
||||||
|
x:Class="XplorePlane.Views.LibraryVersionsWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="库版本信息"
|
||||||
|
Width="850"
|
||||||
|
Height="600"
|
||||||
|
ResizeMode="CanResizeWithGrip"
|
||||||
|
WindowStartupLocation="CenterOwner">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style x:Key="CategoryHeader" TargetType="TextBlock">
|
||||||
|
<Setter Property="FontSize" Value="14" />
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold" />
|
||||||
|
<Setter Property="Foreground" Value="#1565C0" />
|
||||||
|
<Setter Property="Margin" Value="0,12,0,4" />
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<Grid Margin="16">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="0" Margin="0,0,0,12">
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,0,0,4"
|
||||||
|
FontSize="18"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Text="引用库版本信息" />
|
||||||
|
<TextBlock
|
||||||
|
FontSize="12"
|
||||||
|
Foreground="Gray"
|
||||||
|
Text="{Binding AppVersion, StringFormat='应用程序版本: {0}'}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<DataGrid
|
||||||
|
Grid.Row="1"
|
||||||
|
AlternatingRowBackground="#F9F9F9"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
BorderBrush="#E0E0E0"
|
||||||
|
BorderThickness="1"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserDeleteRows="False"
|
||||||
|
ColumnHeaderHeight="32"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
IsReadOnly="True"
|
||||||
|
ItemsSource="{Binding Libraries}"
|
||||||
|
RowHeight="28"
|
||||||
|
SelectionMode="Single">
|
||||||
|
<DataGrid.GroupStyle>
|
||||||
|
<GroupStyle>
|
||||||
|
<GroupStyle.ContainerStyle>
|
||||||
|
<Style TargetType="GroupItem">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="GroupItem">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Style="{StaticResource CategoryHeader}" Text="{Binding Name}" />
|
||||||
|
<ItemsPresenter />
|
||||||
|
</StackPanel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</GroupStyle.ContainerStyle>
|
||||||
|
</GroupStyle>
|
||||||
|
</DataGrid.GroupStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="220"
|
||||||
|
Binding="{Binding Name}"
|
||||||
|
Header="库名称" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding Version}"
|
||||||
|
Header="版本" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="0,12,0,0"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Width="80"
|
||||||
|
Height="28"
|
||||||
|
Click="CloseButton_Click"
|
||||||
|
Content="关闭"
|
||||||
|
IsCancel="True" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using XplorePlane.ViewModels;
|
||||||
|
|
||||||
|
namespace XplorePlane.Views
|
||||||
|
{
|
||||||
|
public partial class LibraryVersionsWindow : Window
|
||||||
|
{
|
||||||
|
public LibraryVersionsWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new LibraryVersionsViewModel();
|
||||||
|
Loaded += OnLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is LibraryVersionsViewModel vm)
|
||||||
|
{
|
||||||
|
var view = CollectionViewSource.GetDefaultView(vm.Libraries);
|
||||||
|
view.GroupDescriptions.Clear();
|
||||||
|
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Window
|
<Window
|
||||||
x:Class="XplorePlane.Views.MainWindow"
|
x:Class="XplorePlane.Views.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
@@ -411,6 +411,7 @@
|
|||||||
<telerik:RadRibbonButton
|
<telerik:RadRibbonButton
|
||||||
Size="Large"
|
Size="Large"
|
||||||
SmallImage="/Assets/Icons/tools.png"
|
SmallImage="/Assets/Icons/tools.png"
|
||||||
|
Click="LibraryVersions_Click"
|
||||||
Text="关于 XplorePlane" />
|
Text="关于 XplorePlane" />
|
||||||
</telerik:RadRibbonGroup>
|
</telerik:RadRibbonGroup>
|
||||||
<telerik:RadRibbonGroup Header="帮助">
|
<telerik:RadRibbonGroup Header="帮助">
|
||||||
|
|||||||
@@ -52,5 +52,11 @@ namespace XplorePlane.Views
|
|||||||
var window = new CameraSettingsWindow(vm) { Owner = this };
|
var window = new CameraSettingsWindow(vm) { Owner = this };
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LibraryVersions_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var window = new LibraryVersionsWindow { Owner = this };
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user