From efb4e11796d07736aacd4cee548071ca51373eee Mon Sep 17 00:00:00 2001 From: panwenbo Date: Tue, 9 Jan 2024 17:27:45 +0800 Subject: [PATCH] =?UTF-8?q?One.Toolbox=20=E6=96=B0=E5=A2=9E=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BD=93=E5=89=8D=E7=B3=BB=E7=BB=9F=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84IP=EF=BC=9B=20=E5=85=B6=E4=BB=96=E5=86=85=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96=EF=BC=9B=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- One.Core/Helpers/NetHelpers/NetHelper.cs | 22 +- One.Toolbox/One.Toolbox.csproj | 4 +- .../ViewModels/BingImage/BingImageVM.cs | 12 +- .../ViewModels/Dashboard/DashboardVM.cs | 14 ++ .../Views/Dashboard/DashboardPage.xaml | 176 +++++++------ One.Toolbox/Views/Pages/WinUSBPage.xaml | 111 --------- One.Toolbox/Views/Pages/WinUSBPage.xaml.cs | 232 ------------------ 7 files changed, 129 insertions(+), 442 deletions(-) delete mode 100644 One.Toolbox/Views/Pages/WinUSBPage.xaml delete mode 100644 One.Toolbox/Views/Pages/WinUSBPage.xaml.cs diff --git a/One.Core/Helpers/NetHelpers/NetHelper.cs b/One.Core/Helpers/NetHelpers/NetHelper.cs index 440a836..9a1f98e 100644 --- a/One.Core/Helpers/NetHelpers/NetHelper.cs +++ b/One.Core/Helpers/NetHelpers/NetHelper.cs @@ -11,22 +11,20 @@ namespace One.Core.Helpers.NetHelpers public class NetHelper { /// 获取本机所有IPv4地址 - public static List GetIPv4AdList() + /// + public static List GetIPv4AddressList() { - string hostName = Dns.GetHostName();//本机名 + string hostName = Dns.GetHostName(); IPAddress[] addressList = Dns.GetHostAddresses(hostName);//会返回所有地址,包括IPv4和IPv6 - List address4List = new List(); - foreach (IPAddress ipa in addressList) + List ipv4AddressList = new List(); + foreach (IPAddress ipAddress in addressList) { - if (ipa.AddressFamily == AddressFamily.InterNetwork) + if (ipAddress.AddressFamily == AddressFamily.InterNetwork) { - //LocalIP = ipa; - //return ipa.ToString(); - address4List.Add(ipa); - //return ipa; + ipv4AddressList.Add(ipAddress); } } - return address4List; + return ipv4AddressList; } /// 获取本机所有IPv6地址 @@ -48,7 +46,7 @@ public static List GetIPv6AdList() return address4List; } - /// 获取当前使用的IP,Ping baidu + /// 通过Ping baidu 获取当前使用的IP /// public static string GetLocalIP() { @@ -272,6 +270,8 @@ public IPAddress BroadcastPoint get { return GetBroadcastPoint(); } } + /// This function calculates and returns the broadcast point IP address based on the given IP address and IPv4 mask. + /// The broadcast point IP address as an instance of IPAddress, or null if either the IP or the IPv4 mask is null. private IPAddress GetBroadcastPoint() { if (IP != null && IPv4Mask != null) diff --git a/One.Toolbox/One.Toolbox.csproj b/One.Toolbox/One.Toolbox.csproj index a20e4d3..7eef8ad 100644 --- a/One.Toolbox/One.Toolbox.csproj +++ b/One.Toolbox/One.Toolbox.csproj @@ -7,7 +7,7 @@ enable true True - 2.6.5 + 2.6.6 enable zh-Hans;en-us Icon.ico @@ -33,13 +33,11 @@ - all - diff --git a/One.Toolbox/ViewModels/BingImage/BingImageVM.cs b/One.Toolbox/ViewModels/BingImage/BingImageVM.cs index bb11c6c..ba6e498 100644 --- a/One.Toolbox/ViewModels/BingImage/BingImageVM.cs +++ b/One.Toolbox/ViewModels/BingImage/BingImageVM.cs @@ -25,7 +25,7 @@ public override void OnNavigatedEnter() [ObservableProperty] private ObservableCollection obImageListInfo = new ObservableCollection(); - private List ImageList = new List(); + private List ImageList = []; //public ObservableCollection ObImageListInfo { get; set; } = new ObservableCollection(); async void InitData() @@ -143,7 +143,7 @@ private List FilterImageInfoAndSave(BingImageOriginalModel b return listVM; } - private async Task DownloadImage(UsefullImageInfoVM usefullImageInfos) + private static async Task DownloadImage(UsefullImageInfoVM usefullImageInfos) { //查看图片是否已经下载,path为路径 if (File.Exists(usefullImageInfos.LocalImagePath)) @@ -165,14 +165,12 @@ private async Task DownloadImage(UsefullImageInfoVM usefullImageInfos) { return; } - //创造图片 - using (FileStream fileStream = new FileStream(usefullImageInfos.LocalImagePath, FileMode.Create)) + + using (var fileStream = new FileStream(usefullImageInfos.LocalImagePath, FileMode.Create)) + using (var binaryWriter = new BinaryWriter(fileStream)) { - BinaryWriter binaryWriter = new BinaryWriter(fileStream); - //写入图片信息 binaryWriter.Write(timeline); } - return; } } \ No newline at end of file diff --git a/One.Toolbox/ViewModels/Dashboard/DashboardVM.cs b/One.Toolbox/ViewModels/Dashboard/DashboardVM.cs index 04db3a8..163d432 100644 --- a/One.Toolbox/ViewModels/Dashboard/DashboardVM.cs +++ b/One.Toolbox/ViewModels/Dashboard/DashboardVM.cs @@ -29,6 +29,8 @@ void InitData() Text = a.hitokoto; Author = "--" + a.from; }); + + _ = Task.Run(GetCurrentUseIP); } private void Register() @@ -89,4 +91,16 @@ private static async Task GetEveryDayYiyan() return timeline; } + + #region StatusBar + + [ObservableProperty] + private string currentUseIP; + + private void GetCurrentUseIP() + { + CurrentUseIP = One.Core.Helpers.NetHelpers.NetHelper.GetLocalIP(); + } + + #endregion StatusBar } \ No newline at end of file diff --git a/One.Toolbox/Views/Dashboard/DashboardPage.xaml b/One.Toolbox/Views/Dashboard/DashboardPage.xaml index c73b3a9..9ad9bba 100644 --- a/One.Toolbox/Views/Dashboard/DashboardPage.xaml +++ b/One.Toolbox/Views/Dashboard/DashboardPage.xaml @@ -11,83 +11,103 @@ d:Height="548" d:Width="733" mc:Ignorable="d"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -