diff --git a/README.en.md b/README.en.md index a08c9fda4..df4def8c7 100644 --- a/README.en.md +++ b/README.en.md @@ -26,14 +26,12 @@ English | [简体中文](./README.md) 5. Some game tools - Currently there is a forced game borderless windowing, CSGO fix VAC shield. + ## 🖥 Operating Environment - Windows 10 1607+ - Windows 8.1 / Windows Server 2012 R2 - - Prerequisites - - Microsoft Visual C++ 2015-2019 Redistributable [64 bit](https://aka.ms/vs/16/release/vc_redist.x64.exe) / [32 bit](https://aka.ms/vs/16/release/vc_redist.x86.exe) - Windows 7 SP1 [ESU](https://docs.microsoft.com/troubleshoot/windows-client/windows-7-eos-faq/windows-7-extended-security-updates-faq) - Prerequisites - - Microsoft Visual C++ 2015-2019 Redistributable [64 bit](https://aka.ms/vs/16/release/vc_redist.x64.exe) / [32 bit](https://aka.ms/vs/16/release/vc_redist.x86.exe) - KB3063858 [64 bit](https://www.microsoft.com/download/details.aspx?id=47442) / [32 bit](https://www.microsoft.com/download/details.aspx?id=47409) - ~~macOS 10.13 High Sierra Or Higher~~ ## 🌎 Roadmap diff --git a/README.md b/README.md index 8fafc9460..63973a62d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ +
+ [English](./README.en.md) | 简体中文 ## ✨ 功能 @@ -33,14 +35,13 @@ 5. 其他游戏工具 - 目前已有强制游戏无边框窗口化,CSGO 修复 VAC 屏蔽 + + ## 🖥 系统要求 - Windows 10 1607+ - Windows 8.1 / Windows Server 2012 R2 - - 先决条件 - - Microsoft Visual C++ 2015-2019 Redistributable [64 位](https://aka.ms/vs/16/release/vc_redist.x64.exe) / [32 位](https://aka.ms/vs/16/release/vc_redist.x86.exe) - Windows 7 SP1 [ESU](https://docs.microsoft.com/zh-cn/troubleshoot/windows-client/windows-7-eos-faq/windows-7-extended-security-updates-faq) - 先决条件 - - Microsoft Visual C++ 2015-2019 Redistributable [64 位](https://aka.ms/vs/16/release/vc_redist.x64.exe) / [32 位](https://aka.ms/vs/16/release/vc_redist.x86.exe) - KB3063858 [64 位](https://www.microsoft.com/zh-cn/download/details.aspx?id=47442) / [32 位](https://www.microsoft.com/zh-cn/download/details.aspx?id=47409) - ~~macOS 10.13 High Sierra 或更高版本~~ ## 🌎 路线图 diff --git a/SteamToolsV1.2+.sln b/SteamToolsV1.2+.sln index c75298a57..8936e4ab2 100644 --- a/SteamToolsV1.2+.sln +++ b/SteamToolsV1.2+.sln @@ -65,6 +65,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Application.SteamToo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Application.SteamTools.Client.Desktop.Platform.Windows", "System.Application.SteamTools.Client.Desktop.Platform.Windows\System.Application.SteamTools.Client.Desktop.Platform.Windows.csproj", "{141532E1-540E-4E50-8723-96936C191281}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win7Troubleshoot", "Win7Troubleshoot\Win7Troubleshoot.csproj", "{60530AF8-4790-4A85-BCE2-C5673E9C601B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -149,6 +151,10 @@ Global {141532E1-540E-4E50-8723-96936C191281}.Debug|Any CPU.Build.0 = Debug|Any CPU {141532E1-540E-4E50-8723-96936C191281}.Release|Any CPU.ActiveCfg = Release|Any CPU {141532E1-540E-4E50-8723-96936C191281}.Release|Any CPU.Build.0 = Release|Any CPU + {60530AF8-4790-4A85-BCE2-C5673E9C601B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60530AF8-4790-4A85-BCE2-C5673E9C601B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60530AF8-4790-4A85-BCE2-C5673E9C601B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60530AF8-4790-4A85-BCE2-C5673E9C601B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -179,6 +185,7 @@ Global {D4CF08F5-8EAB-48FB-AAA3-1A221F7B2A82} = {B43459A1-709B-4623-9677-AAC2FEE4FBA3} {948C1EA8-12DB-4F8A-A190-8615DFBD9FE4} = {B43459A1-709B-4623-9677-AAC2FEE4FBA3} {141532E1-540E-4E50-8723-96936C191281} = {B43459A1-709B-4623-9677-AAC2FEE4FBA3} + {60530AF8-4790-4A85-BCE2-C5673E9C601B} = {1460800B-D9ED-4147-B1E7-ABF502BEF59A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3833E7C5-69BC-4CB3-92CE-A8854AA35D8A} diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/linux-x64.pubxml b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/linux-x64.pubxml index 7a12665dc..8ba9fff69 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/linux-x64.pubxml +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/linux-x64.pubxml @@ -11,7 +11,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem linux-x64 true - false + true True link false diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/osx-x64.pubxml b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/osx-x64.pubxml index b928399b5..8b78f4ee8 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/osx-x64.pubxml +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/osx-x64.pubxml @@ -11,7 +11,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem osx-x64 true - false + true True link false diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/win-x64.pubxml b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/win-x64.pubxml index ff61d88a3..84c3f7d68 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/win-x64.pubxml +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Properties/PublishProfiles/win-x64.pubxml @@ -11,10 +11,20 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem win-x64 true - false + true + true + True link + true + + false + false + false false + false + false + true none false diff --git a/System.Common.ClientLib.Droid/Application/Services/Implementation/PlatformTelephonyServiceImpl.cs b/System.Common.ClientLib.Droid/Application/Services/Implementation/PlatformTelephonyServiceImpl.cs index 114533805..d4ee4e171 100644 --- a/System.Common.ClientLib.Droid/Application/Services/Implementation/PlatformTelephonyServiceImpl.cs +++ b/System.Common.ClientLib.Droid/Application/Services/Implementation/PlatformTelephonyServiceImpl.cs @@ -15,7 +15,7 @@ namespace System.Application.Services.Implementation { var telephony = XEPlatform.AppContext.GetSystemService(Context.TelephonyService); var value = telephony.Line1Number; - return PhoneNumberHelper.GetCNMainlandPhoneNumber11(value); + return PhoneNumberHelper.GetChineseMainlandPhoneNumber11(value); } } } \ No newline at end of file diff --git a/System.Common.CoreLib/Application/PhoneNumberHelper.cs b/System.Common.CoreLib/Application/PhoneNumberHelper.cs index a2a35dfdc..33888ac51 100644 --- a/System.Common.CoreLib/Application/PhoneNumberHelper.cs +++ b/System.Common.CoreLib/Application/PhoneNumberHelper.cs @@ -45,7 +45,7 @@ namespace System.Application /// /// /// - public static string? GetCNMainlandPhoneNumber11(string? value) + public static string? GetChineseMainlandPhoneNumber11(string? value) { if (!string.IsNullOrWhiteSpace(value)) { diff --git a/Win7Troubleshoot/App.config b/Win7Troubleshoot/App.config new file mode 100644 index 000000000..91833b4e8 --- /dev/null +++ b/Win7Troubleshoot/App.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Win7Troubleshoot/DownloadLinks.cs b/Win7Troubleshoot/DownloadLinks.cs new file mode 100644 index 000000000..f7b92c755 --- /dev/null +++ b/Win7Troubleshoot/DownloadLinks.cs @@ -0,0 +1,8 @@ +namespace Win7Troubleshoot +{ + public static class DownloadLinks + { + public const string KB3063858_x64 = "https://www.microsoft.com/{0}/download/details.aspx?id=47442"; + public const string KB3063858_x86 = "https://www.microsoft.com/{0}/download/details.aspx?id=47409"; + } +} \ No newline at end of file diff --git a/Win7Troubleshoot/EnvironmentEx.cs b/Win7Troubleshoot/EnvironmentEx.cs new file mode 100644 index 000000000..e136044d5 --- /dev/null +++ b/Win7Troubleshoot/EnvironmentEx.cs @@ -0,0 +1,69 @@ +// https://www.codeproject.com/questions/641314/check-64-or-32-bit-in-net-3-5 +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace Win7Troubleshoot +{ + public static class EnvironmentEx + { + [DllImport("kernel32", SetLastError = true, CallingConvention = CallingConvention.Winapi)] + internal extern static IntPtr LoadLibrary(string libraryName); + + [DllImport("kernel32", SetLastError = true, CallingConvention = CallingConvention.Winapi)] + internal extern static IntPtr GetProcAddress(IntPtr hwnd, string procedureName); + + delegate bool IsWow64ProcessDelegate([In] IntPtr handle, [Out] out bool isWow64Process); + + public static bool Is64BitOperatingSystem + { + get + { + if (IntPtr.Size == 8 || (IntPtr.Size == 4 && Is32BitProcessOn64BitProcessor())) + { + return true; + } + else + { + return false; + } + } + } + + static IsWow64ProcessDelegate GetIsWow64ProcessDelegate() + { + IntPtr handle = LoadLibrary("kernel32"); + + if (handle != IntPtr.Zero) + { + IntPtr fnPtr = GetProcAddress(handle, "IsWow64Process"); + + if (fnPtr != IntPtr.Zero) + { + return (IsWow64ProcessDelegate)Marshal.GetDelegateForFunctionPointer((IntPtr)fnPtr, typeof(IsWow64ProcessDelegate)); + } + } + + return null; + } + + static bool Is32BitProcessOn64BitProcessor() + { + IsWow64ProcessDelegate fnDelegate = GetIsWow64ProcessDelegate(); + + if (fnDelegate == null) + { + return false; + } + + bool retVal = fnDelegate.Invoke(Process.GetCurrentProcess().Handle, out var isWow64); + + if (retVal == false) + { + return false; + } + + return isWow64; + } + } +} \ No newline at end of file diff --git a/Win7Troubleshoot/Program.cs b/Win7Troubleshoot/Program.cs new file mode 100644 index 000000000..f5ed3d3d9 --- /dev/null +++ b/Win7Troubleshoot/Program.cs @@ -0,0 +1,143 @@ +/* 适用于 Windwos 7 OS 的 疑难解答助手 + * 主要逻辑:if 安装了补丁 KB3063858 + * 直接运行主程序 + * else 本地化文本提示未安装补丁,引导用户进行下载 + * 例如:输入 y 跳转微软官方下载中心下载补丁安装后再使用本应用程序,输入 n 退出 + * Win7 自带 net35 可能魔改版删除了此功能,那就没办法了 + * 可在 控制面板\程序\程序和功能 - 打开或关闭 Windows 功能 - Microsoft .NET Framework 3.5.1 根据左边的勾选框,非空心即代表已安装 + * 对于本程序 + * 在配置文件 exe.config supportedRuntime 项中可添加net4x的支持 + */ + +using System; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Threading; +using System.Windows.Forms; +using Win7Troubleshoot.Properties; + +namespace Win7Troubleshoot +{ + static class Program + { + internal static Mutex? mutex; + + [STAThread] +#pragma warning disable IDE0060 // 删除未使用的参数 + static void Main(string[] args) +#pragma warning restore IDE0060 // 删除未使用的参数 + { + mutex = new Mutex(true, Process.GetCurrentProcess().ProcessName, out var isNotRunning); + if (isNotRunning) + { + try + { + if (Environment.OSVersion.Platform != PlatformID.Win32NT) + throw new PlatformNotSupportedException(); + var r = IsWin7SP1OrNotSupportedPlatform(); + if (r.HasValue) + { + if (r.Value) // Win7SP1 + { + if (!CheckInstalled_KB3063858()) + { + if (MessageBox.Show( + SR.Not_Installed_KB3063858, + SR.Error, + MessageBoxButtons.YesNo, + MessageBoxIcon.Error) == DialogResult.Yes) + { + Open_KB3063858_DownloadLink(); + } + return; + } + } + else // NotSupportedPlatform - For example, WinXP/Win2000 + { + MessageBox.Show( + SR.NotSupportedPlatformError, + SR.Error, + MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + } + AppRun(); + } + catch (Exception e) + { + MessageBox.Show( + e.ToString(), + SR.Error, + MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + /// + /// 在浏览器中打开补丁KB3063858的下载地址 + /// + static void Open_KB3063858_DownloadLink() + { + var downloadLink = EnvironmentEx.Is64BitOperatingSystem ? + DownloadLinks.KB3063858_x64 : DownloadLinks.KB3063858_x86; + downloadLink = string.Format(downloadLink, CultureInfo.CurrentCulture.Name); + Process.Start(downloadLink); + } + + /// + /// 检查是否安装了补丁KB3063858 + /// + /// + static bool CheckInstalled_KB3063858() + { + const string KB3063858 = "KB3063858"; + using var p = new Process(); + p.StartInfo.FileName = "cmd"; + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardInput = true; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + p.StartInfo.CreateNoWindow = true; + p.Start(); + p.StandardInput.WriteLine("wmic qfe&exit"); + p.StandardInput.AutoFlush = true; + var str = p.StandardOutput.ReadToEnd(); + p.WaitForExit(); + return str.Contains(KB3063858); + } + + /// + /// 启动主APP + /// + static void AppRun() + { + var fileName = Process.GetCurrentProcess().MainModule.FileName; + fileName = fileName.Replace(".win7", string.Empty, StringComparison.OrdinalIgnoreCase); + if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) return; + Process.Start(fileName); + } + + /// + /// 返回结果: + /// 当前运行的操作系统为 Win7SP1 + /// 当前运行的操作系统不支持 + /// 当前运行的操作系统为Win8或更高 + /// + /// + static bool? IsWin7SP1OrNotSupportedPlatform() + { + if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1) + { + return Environment.OSVersion.ServicePack == "Service Pack 1"; + } + if (Environment.OSVersion.Version.Major < 6) + { + return false; + } + return null; + } + } +} \ No newline at end of file diff --git a/Win7Troubleshoot/Properties/SR.Designer.cs b/Win7Troubleshoot/Properties/SR.Designer.cs new file mode 100644 index 000000000..56f6bddba --- /dev/null +++ b/Win7Troubleshoot/Properties/SR.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Win7Troubleshoot.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class SR { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal SR() { + } + + /// + /// 返回此类使用的缓存的 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("Win7Troubleshoot.Properties.SR", typeof(SR).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; + } + } + + /// + /// 查找类似 错误 的本地化字符串。 + /// + internal static string Error { + get { + return ResourceManager.GetString("Error", resourceCulture); + } + } + + /// + /// 查找类似 操作系统中缺少必要的补丁 KB3063858 导致程序无法运行,是否使用浏览器打开下载地址并手动安装? 的本地化字符串。 + /// + internal static string Not_Installed_KB3063858 { + get { + return ResourceManager.GetString("Not_Installed_KB3063858", resourceCulture); + } + } + + /// + /// 查找类似 操作系统最低需要 Windows 7 SP1 的本地化字符串。 + /// + internal static string NotSupportedPlatformError { + get { + return ResourceManager.GetString("NotSupportedPlatformError", resourceCulture); + } + } + } +} diff --git a/Win7Troubleshoot/Properties/SR.en.resx b/Win7Troubleshoot/Properties/SR.en.resx new file mode 100644 index 000000000..06fa7a5dc --- /dev/null +++ b/Win7Troubleshoot/Properties/SR.en.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Error + + + The minimum requirement of operating system is Windows 7 SP1 + + + Due to the lack of necessary patch KB3063858 in the operating system, the program cannot run. Do you want to open the download address with a browser and install it manually? + + \ No newline at end of file diff --git a/Win7Troubleshoot/Properties/SR.resx b/Win7Troubleshoot/Properties/SR.resx new file mode 100644 index 000000000..75e6df952 --- /dev/null +++ b/Win7Troubleshoot/Properties/SR.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 错误 + + + 操作系统最低需要 Windows 7 SP1 + + + 操作系统中缺少必要的补丁 KB3063858 导致程序无法运行,是否使用浏览器打开下载地址并手动安装? + + \ No newline at end of file diff --git a/Win7Troubleshoot/Properties/SR.zh-Hant.resx b/Win7Troubleshoot/Properties/SR.zh-Hant.resx new file mode 100644 index 000000000..b8334cb68 --- /dev/null +++ b/Win7Troubleshoot/Properties/SR.zh-Hant.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 錯誤 + + + 作業系統最低需要Windows 7 SP1 + + + 作業系統中缺少必要的補丁 KB3063858 導致程式無法運行,是否使用瀏覽器打開下載地址並手動安裝? + + \ No newline at end of file diff --git a/Win7Troubleshoot/StringExtensions.cs b/Win7Troubleshoot/StringExtensions.cs new file mode 100644 index 000000000..b8a8a1ede --- /dev/null +++ b/Win7Troubleshoot/StringExtensions.cs @@ -0,0 +1,105 @@ +using System.Diagnostics; +using System.Text; + +// ReSharper disable once CheckNamespace +namespace System +{ + public static partial class StringExtensions + { + /// + /// Returns a new string in which all occurrences of a specified string in the current instance are replaced with another + /// specified string according the type of search to use for the specified string. + /// + /// The string performing the replace method. + /// The string to be replaced. + /// The string replace all occurrences of . + /// If value is equal to null, than all occurrences of will be removed from the . + /// One of the enumeration values that specifies the rules for the search. + /// A string that is equivalent to the current string except that all instances of are replaced with . + /// If is not found in the current instance, the method returns the current instance unchanged. + [DebuggerStepThrough] + public static string Replace(this string str, + string oldValue, string @newValue, + StringComparison comparisonType) + { + // https://stackoverflow.com/questions/6275980/string-replace-ignoring-case + + // Check inputs. + if (str == null) + { + // Same as original .NET C# string.Replace behavior. + throw new ArgumentNullException(nameof(str)); + } + if (str.Length == 0) + { + // Same as original .NET C# string.Replace behavior. + return str; + } + if (oldValue == null) + { + // Same as original .NET C# string.Replace behavior. + throw new ArgumentNullException(nameof(oldValue)); + } + if (oldValue.Length == 0) + { + // Same as original .NET C# string.Replace behavior. + throw new ArgumentException("String cannot be of zero length."); + } + + //if (oldValue.Equals(newValue, comparisonType)) + //{ + //This condition has no sense + //It will prevent method from replacesing: "Example", "ExAmPlE", "EXAMPLE" to "example" + //return str; + //} + + // Prepare string builder for storing the processed string. + // Note: StringBuilder has a better performance than String by 30-40%. + StringBuilder resultStringBuilder = new StringBuilder(str.Length); + + // Analyze the replacement: replace or remove. + bool isReplacementNullOrEmpty = string.IsNullOrEmpty(@newValue); + + // Replace all values. + const int valueNotFound = -1; + int foundAt; + int startSearchFromIndex = 0; + while ((foundAt = str.IndexOf(oldValue, startSearchFromIndex, comparisonType)) != valueNotFound) + { + // Append all characters until the found replacement. + int @charsUntilReplacment = foundAt - startSearchFromIndex; + bool isNothingToAppend = @charsUntilReplacment == 0; + if (!isNothingToAppend) + { + resultStringBuilder.Append(str, startSearchFromIndex, @charsUntilReplacment); + } + + // Process the replacement. + if (!isReplacementNullOrEmpty) + { + resultStringBuilder.Append(@newValue); + } + + // Prepare start index for the next search. + // This needed to prevent infinite loop, otherwise method always start search + // from the start of the string. For example: if an oldValue == "EXAMPLE", newValue == "example" + // and comparisonType == "any ignore case" will conquer to replacing: + // "EXAMPLE" to "example" to "example" to "example" … infinite loop. + startSearchFromIndex = foundAt + oldValue.Length; + if (startSearchFromIndex == str.Length) + { + // It is end of the input string: no more space for the next search. + // The input string ends with a value that has already been replaced. + // Therefore, the string builder with the result is complete and no further action is required. + return resultStringBuilder.ToString(); + } + } + + // Append the last part to the result. + int @charsUntilStringEnd = str.Length - startSearchFromIndex; + resultStringBuilder.Append(str, startSearchFromIndex, @charsUntilStringEnd); + + return resultStringBuilder.ToString(); + } + } +} \ No newline at end of file diff --git a/Win7Troubleshoot/Win7Troubleshoot.csproj b/Win7Troubleshoot/Win7Troubleshoot.csproj new file mode 100644 index 000000000..fc8a992f3 --- /dev/null +++ b/Win7Troubleshoot/Win7Troubleshoot.csproj @@ -0,0 +1,39 @@ + + + + WinExe + AnyCPU + net35 + ..\System.Application.SteamTools.Client.Desktop.Avalonia.App\Assets\Icon.ico + Steam++.Win7 + ..\System.Application.SteamTools.Client.Desktop.Avalonia.App\Properties\app.manifest + + + + + Properties\AssemblyInfo.cs + + + Properties\ThisAssembly.cs + + + + + + + + + + True + True + SR.resx + + + + + + ResXFileCodeGenerator + SR.Designer.cs + + + \ No newline at end of file diff --git a/resources/screenshots.jpg b/resources/screenshots.jpg new file mode 100644 index 000000000..9cb41783b Binary files /dev/null and b/resources/screenshots.jpg differ