diff --git a/VPet-Simulator.Core/Properties/Resources.Designer.cs b/VPet-Simulator.Core/Properties/Resources.Designer.cs deleted file mode 100644 index 67e3277..0000000 --- a/VPet-Simulator.Core/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace VPet_Simulator.Core.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VPet_Simulator.Core.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 重写当前线程的 CurrentUICulture 属性,对 - /// 使用此强类型资源类的所有资源查找执行重写。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/VPet-Simulator.Core/Properties/Resources.resx b/VPet-Simulator.Core/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/VPet-Simulator.Core/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VPet-Simulator.Core/Properties/Settings.Designer.cs b/VPet-Simulator.Core/Properties/Settings.Designer.cs deleted file mode 100644 index 750a753..0000000 --- a/VPet-Simulator.Core/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace VPet_Simulator.Core.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/VPet-Simulator.Core/Properties/Settings.settings b/VPet-Simulator.Core/Properties/Settings.settings deleted file mode 100644 index 033d7a5..0000000 --- a/VPet-Simulator.Core/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj index 6ad6c6c..31dad19 100644 --- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj +++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj @@ -1,6 +1,6 @@  - net462;net6.0-windows + net8.0-windows VPet_Simulator.Core latest true diff --git a/VPet-Simulator.Tool/Program.cs b/VPet-Simulator.Tool/Program.cs index 1a32566..101e636 100644 --- a/VPet-Simulator.Tool/Program.cs +++ b/VPet-Simulator.Tool/Program.cs @@ -5,8 +5,6 @@ using System.IO; using System.Linq; using System.Security.Cryptography; using System.Xml.Linq; -using VPet_Simulator.Core; -using static VPet_Simulator.Core.GraphCore; namespace VPet_Simulator.Tool { diff --git a/VPet-Simulator.Tool/VPet-Simulator.Tool.csproj b/VPet-Simulator.Tool/VPet-Simulator.Tool.csproj index 34cee4d..290b0c2 100644 --- a/VPet-Simulator.Tool/VPet-Simulator.Tool.csproj +++ b/VPet-Simulator.Tool/VPet-Simulator.Tool.csproj @@ -26,7 +26,4 @@ Resources.Designer.cs - - - \ No newline at end of file diff --git a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj index 796126e..aa9263b 100644 --- a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj +++ b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj @@ -1,6 +1,6 @@  - net462 + net8.0-windows Library VPet_Simulator.Windows.Interface false diff --git a/VPet-Simulator.Windows/Function/CoreMOD.cs b/VPet-Simulator.Windows/Function/CoreMOD.cs index e5f7a32..1ab3d2d 100644 --- a/VPet-Simulator.Windows/Function/CoreMOD.cs +++ b/VPet-Simulator.Windows/Function/CoreMOD.cs @@ -249,7 +249,7 @@ namespace VPet_Simulator.Windows continue; LoadedDLL.Add(path); Assembly dll = Assembly.LoadFrom(tmpfi.FullName); - var certificate = dll.GetModules()?.First()?.GetSignerCertificate(); + var certificate = Win32.GetCertificateFromSignedFile(path); if (certificate != null) { if (certificate.Subject == "CN=\"Shenzhen Lingban Computer Technology Co., Ltd.\", O=\"Shenzhen Lingban Computer Technology Co., Ltd.\", L=Shenzhen, S=Guangdong Province, C=CN, SERIALNUMBER=91440300MA5H8REU3K, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.1=Shenzhen, OID.1.3.6.1.4.1.311.60.2.1.2=Guangdong Province, OID.1.3.6.1.4.1.311.60.2.1.3=CN" diff --git a/VPet-Simulator.Windows/Function/Win32.cs b/VPet-Simulator.Windows/Function/Win32.cs index e2c801b..bacf00e 100644 --- a/VPet-Simulator.Windows/Function/Win32.cs +++ b/VPet-Simulator.Windows/Function/Win32.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; @@ -9,6 +11,111 @@ namespace VPet_Simulator.Windows { static partial class Win32 { + [DllImport("Crypt32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern bool CryptQueryObject( + int dwObjectType, + string pvObject, + int dwExpectedContentTypeFlags, + int dwExpectedFormatTypeFlags, + int dwFlags, + IntPtr pdwMsgAndCertEncodingType, + IntPtr pdwContentType, + IntPtr pdwFormatType, + IntPtr phStore, + IntPtr phMsg, + ref IntPtr ppvContext + ); + + private const int CERT_QUERY_OBJECT_FILE = 0x00000001; + private const int CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = 0x00004000; + private const int CERT_QUERY_FORMAT_FLAG_BINARY = 0x00000002; + + public static X509Certificate2? GetCertificateFromSignedFile(string filePath) + { + IntPtr certificateContext = IntPtr.Zero; + + if (!CryptQueryObject( + CERT_QUERY_OBJECT_FILE, + filePath, + CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED, + CERT_QUERY_FORMAT_FLAG_BINARY, + 0, + IntPtr.Zero, + IntPtr.Zero, + IntPtr.Zero, + IntPtr.Zero, + IntPtr.Zero, + ref certificateContext)) + { + throw new Win32Exception(Marshal.GetLastWin32Error()); + } + + try + { + return new X509Certificate2(certificateContext); + } + catch + { + return null; + } + //finally + //{ + // if (certificateContext != IntPtr.Zero) + // { + // X509Certificate2Collection certificates = new X509Certificate2Collection(); + // certificates.ImportFromPemFile(filePath); + // foreach (var certificate in certificates) + // { + // Console.WriteLine($"Subject: {certificate.Subject}"); + // Console.WriteLine($"Issuer: {certificate.Issuer}"); + // } + // } + //} + } + + [ComImport] + [Guid("00021401-0000-0000-C000-000000000046")] + internal class ShellLink + { + } + + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("000214F9-0000-0000-C000-000000000046")] + internal interface IShellLink + { + void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd, int fFlags); + void GetIDList(out IntPtr ppidl); + void SetIDList(IntPtr pidl); + void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName); + void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName); + void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath); + void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir); + void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath); + void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs); + void GetHotkey(out short pwHotkey); + void SetHotkey(short wHotkey); + void GetShowCmd(out int piShowCmd); + void SetShowCmd(int iShowCmd); + void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon); + void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon); + void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved); + void Resolve(IntPtr hwnd, int fFlags); + void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile); + } + + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("0000010b-0000-0000-C000-000000000046")] + internal interface IPersistFile + { + void GetClassID(out Guid pClassID); + void IsDirty(); + void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode); + void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, bool fRemember); + void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName); + void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName); + } /// /// 扩展的窗口风格 /// 这是 long 类型的,如果想要使用 int 类型请使用 类 diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 2b9094d..2f628ae 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -1,4 +1,4 @@ -using CSCore.CoreAudioAPI; +using NAudio.CoreAudioApi; using LinePutScript; using LinePutScript.Dictionary; using LinePutScript.Localization.WPF; @@ -28,12 +28,13 @@ using Timer = System.Timers.Timer; using ToolBar = VPet_Simulator.Core.ToolBar; using MessageBox = System.Windows.MessageBox; -using ContextMenu = System.Windows.Forms.ContextMenu; -using MenuItem = System.Windows.Forms.MenuItem; +using ContextMenu = System.Windows.Forms.ContextMenuStrip; +using MenuItem = System.Windows.Forms.ToolStripMenuItem; using Application = System.Windows.Application; using Line = LinePutScript.Line; using static VPet_Simulator.Windows.Interface.ExtensionFunction; using Image = System.Windows.Controls.Image; +using System.Data; #if SteamOutput using VPet.Solution; #endif @@ -79,11 +80,11 @@ namespace VPet_Simulator.Windows /// /// 版本号 /// - public int version { get; } = 109; + public int version { get; } = 11000; /// /// 版本号 /// - public string Version => $"{version / 100}.{version % 100}"; + public string Version => $"{version / 10000}.{version % 10000 / 100}.{version % 100:00}"; public List LowFoodText { get; set; } = new List(); @@ -867,42 +868,10 @@ namespace VPet_Simulator.Windows /// public float AudioPlayingVolume() { - if (AudioPlayingVolumeOK == null) - {//第一调用检查是否支持 - try - { - float vol = 0; - using (var enumerator = new MMDeviceEnumerator()) - { - using (var meter = AudioMeterInformation.FromDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia))) - { - vol = meter.GetPeakValue(); - AudioPlayingVolumeOK = true; - } - } - } - catch - { - AudioPlayingVolumeOK = false; - } - } - else if (AudioPlayingVolumeOK == false) + using (var enumerator = new MMDeviceEnumerator()) { - return -1; - } - try - {//后续容错可能是偶发性 - using (var enumerator = new MMDeviceEnumerator()) - { - using (var meter = AudioMeterInformation.FromDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia))) - { - return meter.GetPeakValue(); - } - } - } - catch - { - return -1; + var device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console); + return device.AudioMeterInformation.MasterPeakValue; } } /// @@ -1661,14 +1630,14 @@ namespace VPet_Simulator.Windows m_menu = new ContextMenu(); - m_menu.Popup += (x, y) => { GameSavesData.Statistics[(gint)"stat_menu_pop"]++; }; - var hitThrough = new MenuItem("鼠标穿透".Translate(), (x, y) => { SetTransparentHitThrough(); }) + m_menu.Opening += (x, y) => { GameSavesData.Statistics[(gint)"stat_menu_pop"]++; }; + var hitThrough = new MenuItem("鼠标穿透".Translate(), null, (x, y) => { SetTransparentHitThrough(); }) { Name = "NotifyIcon_HitThrough", Checked = HitThrough }; - m_menu.MenuItems.Add(hitThrough); - m_menu.MenuItems.Add(new MenuItem("操作教程".Translate(), (x, y) => + m_menu.Items.Add(hitThrough); + m_menu.Items.Add(new MenuItem("操作教程".Translate(), null, (x, y) => { if (LocalizeCore.CurrentCulture == "zh-Hans") ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html"); @@ -1677,25 +1646,25 @@ namespace VPet_Simulator.Windows else ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html"); })); - m_menu.MenuItems.Add(new MenuItem("重置位置与状态".Translate(), (x, y) => + m_menu.Items.Add(new MenuItem("重置位置与状态".Translate(), null, (x, y) => { Main.CleanState(); Main.DisplayToNomal(); Left = (SystemParameters.PrimaryScreenWidth - Width) / 2; Top = (SystemParameters.PrimaryScreenHeight - Height) / 2; })); - m_menu.MenuItems.Add(new MenuItem("反馈中心".Translate(), (x, y) => { new winReport(this).Show(); })); - m_menu.MenuItems.Add(new MenuItem("开发控制台".Translate(), (x, y) => { new winConsole(this).Show(); })); + m_menu.Items.Add(new MenuItem("反馈中心".Translate(), null, (x, y) => { new winReport(this).Show(); })); + m_menu.Items.Add(new MenuItem("开发控制台".Translate(), null, (x, y) => { new winConsole(this).Show(); })); - m_menu.MenuItems.Add(new MenuItem("设置面板".Translate(), (x, y) => + m_menu.Items.Add(new MenuItem("设置面板".Translate(), null, (x, y) => { winSetting.Show(); })); - m_menu.MenuItems.Add(new MenuItem("退出桌宠".Translate(), (x, y) => Close())); + m_menu.Items.Add(new MenuItem("退出桌宠".Translate(), null, (x, y) => Close())); LoadDIY(); - notifyIcon.ContextMenu = m_menu; + notifyIcon.ContextMenuStrip = m_menu; notifyIcon.Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/vpeticon.ico")).Stream); diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 7743a00..0fff92e 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -497,7 +497,7 @@ namespace VPet_Simulator.Windows //uint extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); //SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT); HitThrough = !HitThrough; - notifyIcon.ContextMenu.MenuItems.Find("NotifyIcon_HitThrough", false).First().Checked = HitThrough; + (notifyIcon.ContextMenuStrip.Items.Find("NotifyIcon_HitThrough", false).First() as ToolStripMenuItem).Checked = HitThrough; if (HitThrough) { Win32.User32.SetWindowLongPtr(_hwnd, Win32.GetWindowLongFields.GWL_EXSTYLE, diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj index b788f62..c5dc874 100644 --- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj +++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj @@ -1,6 +1,6 @@  - net462 + net8.0-windows WinExe VPet_Simulator.Windows latest @@ -33,6 +33,7 @@ 1.0.0.0 VPet-Simulator.Windows Copyright © exLB.org 2022 + VPet_Simulator.Windows.App x64 @@ -157,29 +158,6 @@ Resources.Designer.cs - - - {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} - 1 - 0 - 0 - tlbimp - False - True - - - - - False - Microsoft .NET Framework 4.6.2 %28x86 和 x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - @@ -224,18 +202,14 @@ - - - - - - + +