From 334fa56070605e0daf8a1a26b2fe3abb51188fd9 Mon Sep 17 00:00:00 2001 From: zsyg <3872006562@qq.com> Date: Wed, 2 Jul 2025 09:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=E6=BD=9C?= =?UTF-8?q?=E5=9C=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AppSearch.cs | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ AppStore.csproj | 4 ++++ renexe.bat | 4 ++-- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 AppSearch.cs diff --git a/AppSearch.cs b/AppSearch.cs new file mode 100644 index 0000000..ac88f75 --- /dev/null +++ b/AppSearch.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace AppStore +{ + public static class AppSearch + { + /// + /// 搜索应用卡片 + /// + /// 包含应用卡片的FlowLayoutPanel + /// 搜索文本 + public static void SearchApps(FlowLayoutPanel flowPanel, string searchText) + { + if (flowPanel == null || string.IsNullOrWhiteSpace(searchText)) + { + ShowAllApps(flowPanel); + return; + } + + foreach (Control control in flowPanel.Controls) + { + if (control is AppCard appCard) + { + bool isMatch = IsMatchSearch(appCard.AppName, searchText); + control.Visible = isMatch; + } + } + } + + /// + /// 显示所有应用卡片 + /// + public static void ShowAllApps(FlowLayoutPanel? flowPanel) + { + if (flowPanel == null) return; + + foreach (Control control in flowPanel.Controls) + { + control.Visible = true; + } + } + + /// + /// 检查应用名称是否匹配搜索文本 + /// + private static bool IsMatchSearch(string appName, string searchText) + { + if (string.IsNullOrEmpty(appName)) return false; + + // 不区分大小写比较 + return appName.Contains(searchText, StringComparison.OrdinalIgnoreCase); + } + } +} diff --git a/AppStore.csproj b/AppStore.csproj index aa4d5db..fae7734 100644 --- a/AppStore.csproj +++ b/AppStore.csproj @@ -33,4 +33,8 @@ + + + + diff --git a/renexe.bat b/renexe.bat index 2201459..86e2431 100644 --- a/renexe.bat +++ b/renexe.bat @@ -1,2 +1,2 @@ -ren bin\Release\net8.0-windows\win-x86\publish\AppStore.exe kortapp.exe -ren bin\Release\net8.0-windows\win-x64\publish\AppStore.exe kortapp.exe \ No newline at end of file +ren bin\Release\net8.0-windows\win-x86\publish\AppStore.exe kortapp-z.exe +ren bin\Release\net8.0-windows\win-x64\publish\AppStore.exe kortapp-z.exe \ No newline at end of file