OSDN Git Service

AppliStation-GUI,ヘッダ部を右クリックしたときの動作を変更し、コラム表示などのメニューが表示されるようにした。
[applistation/AppliStation.git] / AppliStation / InstallationConfirmForm.cs
index 5422480..017f58e 100644 (file)
@@ -12,19 +12,35 @@ namespace AppliStation
        /// </summary>\r
        public partial class InstallationConfirmForm : Form\r
        {\r
-               private Installation[] requiredInstallations = null;\r
-               \r
                private Installation[] selectedInstallations = null;\r
                \r
+               private Installation[] updateInstallations = null;\r
+               \r
+               private Installation[] requiredInstallations = null;\r
+               \r
                private PackageListsManager pkgListMan;\r
 \r
                public IEnumerable<Installation> Installations {\r
                        get {\r
-                               return NaGet.Utils.MeargeEnumerable<Installation>(requiredInstallations, selectedInstallations);\r
+                               return NaGet.Utils.MergeEnumerable<Installation>(requiredInstallations, selectedInstallations);\r
                        }\r
                        set {\r
+                               List<Installation> selectedInstList = new List<Installation>();\r
+                               List<Installation> updateInstList = new List<Installation>();\r
+                               \r
                                requiredInstallations = null;\r
-                               selectedInstallations = NaGet.Utils.IEnumerable2Array<Installation>(value);\r
+                               foreach (Installation inst in value) {\r
+                                       Package instPkg = pkgListMan.InstalledPkgList.GetPackageForName(inst.InstalledPackage.Name) ??\r
+                                               pkgListMan.SystemInstalledPkgList.GetPackageForName(inst.InstalledPackage.Name);\r
+                                       \r
+                                       if (instPkg != null) {\r
+                                               updateInstList.Add(inst);\r
+                                       } else {\r
+                                               selectedInstList.Add(inst);\r
+                                       }\r
+                               }\r
+                               selectedInstallations = selectedInstList.ToArray();\r
+                               updateInstallations = updateInstList.ToArray();\r
                                \r
                                updateInstsListView();\r
                        }\r
@@ -72,6 +88,7 @@ namespace AppliStation
                        \r
                        addInstsListItemPerGroup(requiredInstallations, instsListView.Groups["requires"], true);\r
                        addInstsListItemPerGroup(selectedInstallations, instsListView.Groups["install"], false);\r
+                       addInstsListItemPerGroup(updateInstallations, instsListView.Groups["update"], false);\r
                        \r
                        InstsListViewItemChecked(instsListView, null);\r
                        instsListView.Refresh();\r
@@ -105,6 +122,7 @@ namespace AppliStation
                                itemData[versionColumnHeader.Index]        = pkg.Version;\r
                                itemData[currentVersionColumnHeader.Index] = (curPkg != null)? curPkg.Version : "-";\r
                                // itemData[silentInstColumnHeader.Index] の設定は instViewUpdateSilentInstallView で\r
+                               itemData[pkgListNameColumnHeader.Index]    = pkg.PackageListName;\r
                                \r
                                ListViewItem item = new ListViewItem(itemData);\r
                                item.Tag = inst;\r
@@ -130,7 +148,7 @@ namespace AppliStation
                /// <summary>\r
                /// アイテムのサイレントインストール部分の表示の更新を行う。\r
                /// </summary>\r
-               /// <param name="item">対象のインストーラのリストアイテム</param>\r
+               /// <param name="item">対象ã\81®ã\82¤ã\83³ã\82¹ã\83\88ã\83¼ã\83©ã\83¼ã\81®ã\83ªã\82¹ã\83\88ã\82¢ã\82¤ã\83\86ã\83 </param>\r
                private void instViewUpdateSilentInstallView(ListViewItem item)\r
                {\r
                        Installation inst = (Installation) item.Tag;\r
@@ -190,9 +208,12 @@ namespace AppliStation
                {\r
                        System.Windows.Forms.ListView.CheckedListViewItemCollection checkeds = instsListView.CheckedItems;\r
                        \r
+                       runasCheckBox.Checked = GetShouldUseRunas();\r
+                       updateUseRunas();\r
+                                               \r
                        okButton.Enabled = (checkeds != null) && (checkeds.Count > 0);\r
                        \r
-                       updateDependeciesIsNeeded();\r
+                       checkUnselectedDependencies();\r
                }\r
                                \r
                void InstsListViewContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)\r
@@ -283,18 +304,35 @@ namespace AppliStation
                        }\r
                }\r
                \r
-               private void updateDependeciesIsNeeded()\r
+               /// <summary>\r
+               /// 依存関係を確認してGUIに反映させる。\r
+               /// 選択されていないが依存関係上必要なソフトを探し出す。\r
+               /// </summary>\r
+               /// <returns>選択されていないが依存関係上必要なソフトの個数(何もない場合はゼロ)</returns>\r
+               private uint checkUnselectedDependencies()\r
                {\r
+                       uint retVal = 0;\r
+                       \r
+                       List<Package> instPkgs = new List<Package>();\r
+                       foreach (Installation inst in Installations) {\r
+                               instPkgs.Add(inst.InstalledPackage);\r
+                       }\r
+                       \r
                        List<Package> pkg = new List<Package>();\r
-                       foreach (Installation inst in DependeciesResolver.CreateRequiresInstallations(CheckedInstallations, pkgListMan)) {\r
+                       foreach (Installation inst in DependeciesResolver.CreateRequiresInstallations(CheckedInstallations, pkgListMan, instPkgs)) {\r
                                pkg.Add(inst.InstalledPackage);\r
                        }\r
                        \r
                        foreach (ListViewItem item in instsListView.Items) {\r
-                               if (pkg.IndexOf(((Installation) item.Tag).InstalledPackage) >= 0) {\r
-                                       item.Checked = true;\r
+                               if ((pkg.IndexOf(((Installation) item.Tag).InstalledPackage) >= 0) && !item.Checked) {\r
+                                       item.ForeColor = Color.Red;\r
+                                       retVal++;\r
+                               } else {\r
+                                       item.ForeColor = Color.Empty;\r
                                }\r
+                       \r
                        }\r
+                       return retVal;\r
                }\r
                \r
                /// <summary>\r
@@ -339,7 +377,7 @@ namespace AppliStation
                                return false;   \r
                        }\r
                        \r
-                       // ひとつでもPCターゲットなインストーラがあれば必要とする\r
+                       // ã\81²ã\81¨ã\81¤ã\81§ã\82\82PCã\82¿ã\83¼ã\82²ã\83\83ã\83\88ã\81ªã\82¤ã\83³ã\82¹ã\83\88ã\83¼ã\83©ã\83¼ã\81\8cã\81\82ã\82\8cã\81°å¿\85è¦\81ã\81¨ã\81\99ã\82\8b\r
                        foreach (Installation inst in CheckedInstallations) {\r
                                if (inst.TargetPC) return true;\r
                        }\r
@@ -354,15 +392,9 @@ namespace AppliStation
                \r
                private void updateUseRunas()\r
                {\r
-                       if (UseRunas) {\r
-                               System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallationConfirmForm));\r
-                               okButton.Image = ((System.Drawing.Bitmap)(resources.GetObject("okButton.Image")));\r
-                       } else {\r
-                               okButton.Image = null;\r
-                       }\r
+                       AppliStation.Util.NativeMethods.Button_SetElevationRequiredState(okButton, UseRunas);\r
                }\r
                \r
                #endregion\r
-\r
        }\r
 }\r