增加诊断信息对话框
This commit is contained in:
117
SpineViewer/Dialogs/DiagnosticsDialog.Designer.cs
generated
Normal file
117
SpineViewer/Dialogs/DiagnosticsDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,117 @@
|
||||
namespace SpineViewer.Dialogs
|
||||
{
|
||||
partial class DiagnosticsDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DiagnosticsDialog));
|
||||
panel1 = new Panel();
|
||||
tableLayoutPanel1 = new TableLayoutPanel();
|
||||
button_Copy = new Button();
|
||||
propertyGrid = new PropertyGrid();
|
||||
panel1.SuspendLayout();
|
||||
tableLayoutPanel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(tableLayoutPanel1);
|
||||
panel1.Dock = DockStyle.Fill;
|
||||
panel1.Location = new Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Padding = new Padding(50, 15, 50, 10);
|
||||
panel1.Size = new Size(901, 452);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
tableLayoutPanel1.AutoSize = true;
|
||||
tableLayoutPanel1.ColumnCount = 1;
|
||||
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel1.Controls.Add(button_Copy, 0, 1);
|
||||
tableLayoutPanel1.Controls.Add(propertyGrid, 0, 0);
|
||||
tableLayoutPanel1.Dock = DockStyle.Fill;
|
||||
tableLayoutPanel1.Location = new Point(50, 15);
|
||||
tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
tableLayoutPanel1.RowCount = 2;
|
||||
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel1.RowStyles.Add(new RowStyle());
|
||||
tableLayoutPanel1.Size = new Size(801, 427);
|
||||
tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// button_Copy
|
||||
//
|
||||
button_Copy.Anchor = AnchorStyles.None;
|
||||
button_Copy.AutoSize = true;
|
||||
button_Copy.Location = new Point(326, 390);
|
||||
button_Copy.Margin = new Padding(3, 10, 3, 3);
|
||||
button_Copy.Name = "button_Copy";
|
||||
button_Copy.Padding = new Padding(10, 0, 10, 0);
|
||||
button_Copy.Size = new Size(148, 34);
|
||||
button_Copy.TabIndex = 12;
|
||||
button_Copy.Text = "复制到剪贴板";
|
||||
button_Copy.UseVisualStyleBackColor = true;
|
||||
button_Copy.Click += button_Copy_Click;
|
||||
//
|
||||
// propertyGrid
|
||||
//
|
||||
propertyGrid.Dock = DockStyle.Fill;
|
||||
propertyGrid.HelpVisible = false;
|
||||
propertyGrid.Location = new Point(3, 3);
|
||||
propertyGrid.Name = "propertyGrid";
|
||||
propertyGrid.Size = new Size(795, 374);
|
||||
propertyGrid.TabIndex = 13;
|
||||
propertyGrid.ToolbarVisible = false;
|
||||
//
|
||||
// DiagnosticsDialog
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(11F, 24F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(901, 452);
|
||||
Controls.Add(panel1);
|
||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "DiagnosticsDialog";
|
||||
ShowInTaskbar = false;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "诊断信息";
|
||||
panel1.ResumeLayout(false);
|
||||
panel1.PerformLayout();
|
||||
tableLayoutPanel1.ResumeLayout(false);
|
||||
tableLayoutPanel1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private TableLayoutPanel tableLayoutPanel1;
|
||||
private Button button_Copy;
|
||||
private PropertyGrid propertyGrid;
|
||||
}
|
||||
}
|
||||
91
SpineViewer/Dialogs/DiagnosticsDialog.cs
Normal file
91
SpineViewer/Dialogs/DiagnosticsDialog.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Reflection;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SpineViewer.Dialogs
|
||||
{
|
||||
public partial class DiagnosticsDialog : Form
|
||||
{
|
||||
public DiagnosticsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
propertyGrid.SelectedObject = new DiagnosticsInformation();
|
||||
}
|
||||
|
||||
private class DiagnosticsInformation
|
||||
{
|
||||
[Category("Versions")]
|
||||
public string WindowsVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var registryKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion";
|
||||
var productName = Registry.GetValue(registryKeyPath, "ProductName", "Unknown") as string;
|
||||
var editionId = Registry.GetValue(registryKeyPath, "EditionID", "Unknown") as string;
|
||||
var osVersion = Environment.OSVersion.ToString();
|
||||
return $"{productName}, {editionId}, {osVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Versions")]
|
||||
public string Version
|
||||
{
|
||||
get => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||
}
|
||||
|
||||
[Category("Versions")]
|
||||
public string DotNetVersion
|
||||
{
|
||||
get => Environment.Version.ToString();
|
||||
}
|
||||
|
||||
[Category("Versions")]
|
||||
public string SFMLVersion
|
||||
{
|
||||
get => typeof(SFML.ObjectBase).Assembly.GetName().Version.ToString();
|
||||
}
|
||||
|
||||
[Category("Hardwares")]
|
||||
public string CPU
|
||||
{
|
||||
get => Registry.GetValue(@"HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", "Unknown").ToString();
|
||||
}
|
||||
|
||||
[Category("Hardwares")]
|
||||
public string Memory
|
||||
{
|
||||
get => $"{new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory / 1024f / 1024f / 1024f:F1} GB";
|
||||
}
|
||||
|
||||
[Category("Hardwares")]
|
||||
public string GPU
|
||||
{
|
||||
get
|
||||
{
|
||||
var searcher = new ManagementObjectSearcher("SELECT Name FROM Win32_VideoController");
|
||||
return string.Join("; ", searcher.Get().Cast<ManagementObject>().Select(mo => mo["Name"].ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button_Copy_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectedObject = propertyGrid.SelectedObject as DiagnosticsInformation;
|
||||
var properties = selectedObject.GetType().GetProperties();
|
||||
var result = string.Join(Environment.NewLine, properties.Select(p => $"{p.Name}\t{p.GetValue(selectedObject)?.ToString()}"));
|
||||
Clipboard.SetText(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
3267
SpineViewer/Dialogs/DiagnosticsDialog.resx
Normal file
3267
SpineViewer/Dialogs/DiagnosticsDialog.resx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user