基本信息
源码名称:WPF login登录界面
源码大小:0.10M
文件格式:.zip
开发语言:C#
更新时间:2018-12-17
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Management;
using System.Net;
using System.Net.Sockets;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using Microsoft.Win32;
namespace LoginWindow
{
/// <summary>
/// Interaction logic for SystemInformationWindow.xaml
/// </summary>
public partial class SystemInformationWindow
{
public SystemInformationWindow()
{
InitializeComponent();
GetSystemInformations();
}
private void SystemInfoWindow_OnKeyUp(object sender, KeyEventArgs e)
{
if (e != null && e.Key == Key.Escape)
{
Close();
}
}
private void MainHeaderThumb_OnDragDelta(object sender, DragDeltaEventArgs e)
{
Left = Left e.HorizontalChange;
Top = Top e.VerticalChange;
}
private void ButtonClose_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void GetSystemInformations()
{
SystemInfoWindowOperatingSystem.Content = GetOsFriendlyName();
SystemInfoWindowNetFrameworkVersion.Content = Get45Or451FromRegistry();
SystemInfoWindowWindowsUserName.Content = Environment.UserName;
SystemInfoWindowDomainName.Content = Environment.UserDomainName;
SystemInfoWindowRam.Content = GetMemory();
SystemInfoWindowProcessor.Content = GetProcessor();
SystemInfoWindowLanIp.Content = GetLanIpAddress();
SystemInfoWindowWanIp.Content = GetWanIpAddress();
SystemInfoWindowRubyVersion.Content = GetAssemblyInformation();
}
public static string GetOsFriendlyName()
{
var searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
foreach (var os in searcher.Get())
{
return os["Caption"].ToString();
}
return string.Empty;
}
private static string Get45Or451FromRegistry()
{
using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\"))
{
var releaseKey = Convert.ToInt32(ndpKey.GetValue("Release"));
if (true)
{
return CheckFor45DotVersion(releaseKey);
}
}
}
// Checking the version using >= will enable forward compatibility,
private static string CheckFor45DotVersion(int releaseKey)
{
if (releaseKey >= 393273)
{
return "4.6 RC or later";
}
if ((releaseKey >= 379893))
{
return "4.5.2 or later";
}
if ((releaseKey >= 378675))
{
return "4.5.1 or later";
}
if ((releaseKey >= 378389))
{
return "4.5 or later";
}
// This line should never execute. A non-null release key should mean
// that 4.5 or later is installed.
//return "No 4.5 or later version detected";
return "Please install .Net Framework Version 4.5 or later!";
}
private static string GetMemory()
{
var query = "SELECT MaxCapacity FROM Win32_PhysicalMemoryArray";
var searcher = new ManagementObjectSearcher(query);
foreach (var wniPart in searcher.Get())
{
UInt32 sizeinKb = Convert.ToUInt32(wniPart.Properties["MaxCapacity"].Value);
UInt32 sizeinMb = sizeinKb / 1024;
UInt32 sizeinGb = sizeinMb / 1024;
//Console.WriteLine("Size in KB: {0}, Size in MB: {1}, Size in GB: {2}", SizeinKB, SizeinMB, SizeinGB);
return sizeinGb " GB";
}
return string.Empty;
}
private static string GetProcessor()
{
var query = "SELECT Name FROM Win32_Processor";
var searcher = new ManagementObjectSearcher(query);
foreach (var wniPart in searcher.Get())
{
return wniPart.Properties["Name"].Value.ToString();
}
return string.Empty;
}
private static string GetLanIpAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
return ip.ToString();
}
}
return string.Empty;
}
private static string GetWanIpAddress()
{
using (var webClient = new WebClient())
{
string wanIpAddress;
try
{
wanIpAddress = IPAddress.Parse(webClient.DownloadString("http://tools.feron.it/php/ip.php")).ToString();
}
catch (Exception)
{
wanIpAddress = "Bitte besuchen Sie die Seite www.wieistmeineip.ch";
}
return wanIpAddress;
}
}
private static string GetAssemblyInformation()
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
}