OSDN Git Service

AppliStation-GUI,検索用テキストボックスをToolStripWeb2LikeTextBoxとして独立コンポーネントとして分離
[applistation/AppliStation.git] / AppliStation / PackageListViewForm.cs
index 474c2ea..ff86c68 100644 (file)
@@ -215,23 +215,18 @@ namespace AppliStation
                        }\r
                        \r
                        updatePackageFilterToolStripMenuItemCheckState();\r
-                       searchTextBoxUpdate(false);\r
+                       searchTextBox.FireTextChangedTrigger();\r
+                       PackageListViewUpdate();\r
                }\r
                \r
                #endregion\r
                \r
-               private string oldSearchKeywords = null;\r
                void PackageListViewUpdate()\r
                {\r
-                       string searchKeywords = this.SearchKeyword;\r
-                       if (oldSearchKeywords == searchKeywords) { // \8dX\90V\82³\82ê\82Ä\82¢\82È\82¢\8fê\8d\87\82Í\8c\9f\8dõ\82µ\82È\82¢\r
-                               return;\r
-                       }\r
-                       \r
                        this.packageListView.Items.Clear();\r
                        \r
                        if (currentPackageFilter == PackageFilterIndex.All || currentPackageFilter == PackageFilterIndex.NotInstalled) {\r
-                               foreach (Package pkg in pkgListsMan.AvailablePkgList.Search(searchKeywords)) {\r
+                               foreach (Package pkg in pkgListsMan.AvailablePkgList.Search(searchTextBox.Text)) {\r
                                        if (Installation.GetPreferInstallerIndex(pkg) >= 0) { // \83C\83\93\83X\83g\81[\83\8b\89Â\94\\r
                                                if (currentPackageFilter == PackageFilterIndex.NotInstalled &&\r
                                                    (pkgListsMan.InstalledPkgList.GetPackageForName(pkg.Name) != null||\r
@@ -249,7 +244,7 @@ namespace AppliStation
                        }\r
                        \r
                        if (currentPackageFilter == PackageFilterIndex.All || currentPackageFilter == PackageFilterIndex.InstalledAS) {\r
-                               foreach (Package pkg in pkgListsMan.InstalledPkgList.Search(this.SearchKeyword)) {\r
+                               foreach (Package pkg in pkgListsMan.InstalledPkgList.Search(searchTextBox.Text)) {\r
                                        ListViewItem item = new ListViewItem(new string[]{pkg.Name, pkg.Version, pkg.Summary});\r
                                        item.Tag = pkg;\r
                                        item.ToolTipText = pkg.Summary;\r
@@ -260,7 +255,7 @@ namespace AppliStation
                        }\r
                        \r
                        if (currentPackageFilter == PackageFilterIndex.All || currentPackageFilter == PackageFilterIndex.InstalledSys) {\r
-                               foreach (Package pkg in pkgListsMan.SystemInstalledPkgList.Search(this.SearchKeyword)) {\r
+                               foreach (Package pkg in pkgListsMan.SystemInstalledPkgList.Search(searchTextBox.Text)) {\r
                                        ListViewItem item = new ListViewItem(new string[]{pkg.Name, pkg.Version, pkg.Summary});\r
                                        item.Tag = pkg;\r
                                        item.ToolTipText = pkg.Summary;\r
@@ -274,8 +269,6 @@ namespace AppliStation
                        detailBox.Refresh();\r
                        \r
                        //this.packageListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);\r
-                       \r
-                       oldSearchKeywords = searchKeywords; // \89ß\8b\8e\82Ì\8c\9f\8dõ\83L\81[\83\8f\81[\83h\82Æ\82µ\82Ä\8ao\82¦\82Ä\82¨\82­\r
                }\r
                \r
                void PackageDetailBoxLinkClicked(object sender, LinkClickedEventArgs e)\r
@@ -313,72 +306,20 @@ namespace AppliStation
                \r
                #region searchTextBox\82Ü\82í\82è\r
                \r
-               private bool searchTextBoxIsEmpty = true;\r
-               \r
-               private Timer searchUpdateTimer = null;\r
-               \r
-               string SearchKeyword {\r
-                       get {\r
-                               return searchTextBoxIsEmpty? string.Empty : searchTextBox.Text;\r
-                       }\r
-               }\r
-               \r
-               void SearchTextBoxEnter(object sender, EventArgs e)\r
-               {\r
-                       if (searchTextBoxIsEmpty) {\r
-                               searchTextBox.Text = string.Empty;\r
-                               searchTextBox.ForeColor = DefaultForeColor;\r
-                               searchTextBoxIsEmpty = false;\r
-                       }\r
-               }\r
-               \r
-               void SearchTextBoxLeave(object sender, EventArgs e)\r
-               {\r
-                       if (string.IsNullOrEmpty(searchTextBox.Text)) {\r
-                               searchTextBox.Text = "\8c\9f\8dõ";\r
-                               searchTextBox.ForeColor = SystemColors.GrayText;\r
-                               searchTextBoxIsEmpty = true;\r
-                       }\r
-               }\r
-               \r
-               void SearchTextBoxTextChanged(object sender, EventArgs e)\r
-               {\r
-                       if (searchTextBox.Focused) {\r
-                               searchTextBoxUpdate(false);\r
-                       }\r
-               }\r
-               \r
                void SearchTextBoxKeyPress(object sender, KeyPressEventArgs e)\r
                {\r
                        switch (e.KeyChar) {\r
                                case (char)Keys.Enter:\r
-                                       searchTextBoxUpdate(true);\r
+                                       searchTextBox.FireTextChangedTrigger();\r
                                        break;\r
                                case (char)Keys.Escape:\r
-                                       searchTextBox.Text = "";\r
+                                       searchTextBox.Text = string.Empty;\r
                                        break;\r
                        }\r
                }\r
                \r
-               private void searchTextBoxUpdate(bool force)\r
+               void SearchTextBoxTextChangedTriggerFired(object sender, EventArgs e)\r
                {\r
-                       if (! this.Created) return;\r
-                       \r
-                       if (searchUpdateTimer != null) {\r
-                               searchUpdateTimer.Stop();\r
-                       } else {\r
-                               searchUpdateTimer = new Timer();\r
-                               searchUpdateTimer.Tick += searchUpdateTimerTick;\r
-                       }\r
-                       searchUpdateTimer.Interval = (force)? 10 : 500;\r
-                       searchUpdateTimer.Start();\r
-               }\r
-               \r
-               private void searchUpdateTimerTick(object sender, EventArgs e)\r
-               {\r
-                       searchUpdateTimer.Stop();\r
-                       searchUpdateTimer = null;\r
-                       \r
                        PackageListViewUpdate();\r
                }\r
                \r