X-Git-Url: http://git.sourceforge.jp/view?p=applistation%2FAppliStation.git;a=blobdiff_plain;f=AppliStation%2FPackageListViewForm.cs;h=a66d9a69137f1bdb64f72e25524780ca4c63f860;hp=6ee1e35bda607bbb921f93d54644f59c4cdeb1d9;hb=202377d120df8670eca37760385d1f3616b6f8a1;hpb=3772523f398b455aca01e4afb7cffd614a9fe704 diff --git a/AppliStation/PackageListViewForm.cs b/AppliStation/PackageListViewForm.cs index 6ee1e35..a66d9a6 100644 --- a/AppliStation/PackageListViewForm.cs +++ b/AppliStation/PackageListViewForm.cs @@ -108,6 +108,7 @@ namespace AppliStation webResourceToolStripMenuItem.Visible = (pkgCount == 1); uninstallToolStripMenuItem.Visible = uninstallBtnEnabled; installToolStripMenuItem.Visible = installBtnEnabled; + downloadToolStripMenuItem.Visible = (pkgCount > 0); // detailBoxのメッセージ設定 switch (pkgCount) { @@ -231,7 +232,7 @@ namespace AppliStation { AppliStation.Util.ExecutionProgressViewer prog = new AppliStation.Util.ExecutionProgressViewer(); prog.Shown += delegate(object sender2, EventArgs e2) { - NaGet.SubCommands.NaGetUpdate tasks = new NaGet.SubCommands.NaGetUpdate(pkgListsMan, downloadPackageListsFlag); + NaGet.SubCommands.NaGetUpdate2 tasks = new NaGet.SubCommands.NaGetUpdate2(pkgListsMan, downloadPackageListsFlag); prog.SetTaskSet(tasks); prog.Refresh(); prog.StartTaskSet(); @@ -315,11 +316,30 @@ namespace AppliStation void SoftCollectionFileExportToolStripMenuItemClick(object sender, EventArgs e) { string pwd = Directory.GetCurrentDirectory(); + string[] softtargets = new string[]{ + "PCにインストールされたソフト", + "AppliStation内でインストールされたソフト", + "インストールされたソフトすべて;PCとAppliStationにインストールされたソフトの両方" + }; + int softtargetid = softtargets.Length - 1; + + { + AppliStation.Util.OptionDialog optdialog = AppliStation.Util.OptionDialog.createCommandSelectionDialog( + "ソフトコレクションファイルに出力するソフトの種類を選択してください。", "エクスポート", "エクスポートするソフト", + System.Drawing.SystemIcons.Question, + softtargets, softtargets.Length-1); + if (optdialog.ShowDialog(this) != DialogResult.OK) { + return; // canceled + } else if (optdialog.UserInputValue != null) { + softtargetid = (int) optdialog.UserInputValue; + } + } SaveFileDialog fd = new SaveFileDialog(); fd.Filter = "ソフトコレクションファイル (*.txt)|*.txt"; fd.DefaultExt = "txt"; fd.CheckPathExists = true; + fd.OverwritePrompt = true; fd.ShowDialog(); if (fd.FileNames.Length > 0) { string filepath = Path.GetFullPath(fd.FileName); @@ -327,10 +347,28 @@ namespace AppliStation PackageCollectionFileData collectionData = new PackageCollectionFileData(); - collectionData.loadPackages(pkgListsMan.GetAllInstalledPackages()); + switch (softtargetid) { + case 0: // PCにインストール + collectionData.loadPackages(pkgListsMan.SystemInstalledPkgList.GetEnumerator()); + break; + case 1: // AppliStation内にインストール + collectionData.loadPackages(pkgListsMan.InstalledPkgList.GetEnumerator()); + break; + case 2: // すべて + default: + collectionData.loadPackages(pkgListsMan.GetAllInstalledPackages()); + break; + } try { collectionData.saveAs(fd.FileName); + } catch (UnauthorizedAccessException) { + if ((File.GetAttributes(fd.FileName) & FileAttributes.ReadOnly) != 0) { + MessageBox.Show("読み取り専用属性が設定されています。\n別のファイルを指定してください。", "エクスポート", MessageBoxButtons.OK, MessageBoxIcon.Error); + } else { + MessageBox.Show("ファイルへの書き込みが許可されていません。\n別のファイルを指定してください。", "エクスポート", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + return; } catch (IOException) { MessageBox.Show("ファイルの書き込みに失敗しました", "エクスポート", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -378,7 +416,7 @@ namespace AppliStation { AppliStation.Util.ExecutionProgressViewer prog = new AppliStation.Util.ExecutionProgressViewer(); prog.Shown += delegate(object sender2, EventArgs e2) { - NaGet.SubCommands.NaGetInstall tasks = new NaGet.SubCommands.NaGetInstall(pkgListsMan, insts); + NaGet.SubCommands.NaGetInstall2 tasks = new NaGet.SubCommands.NaGetInstall2(pkgListsMan, insts); prog.SetTaskSet(tasks); prog.Refresh(); prog.StartTaskSet(); @@ -448,7 +486,7 @@ namespace AppliStation { AppliStation.Util.ExecutionProgressViewer prog = new AppliStation.Util.ExecutionProgressViewer(); prog.Shown += delegate(object sender2, EventArgs e2) { - NaGet.SubCommands.NaGetUninstall tasks = new NaGet.SubCommands.NaGetUninstall(pkgListsMan, pkgs); + NaGet.SubCommands.NaGetUninstall2 tasks = new NaGet.SubCommands.NaGetUninstall2(pkgListsMan, pkgs); prog.SetTaskSet(tasks); prog.Refresh(); prog.StartTaskSet(); @@ -514,6 +552,27 @@ namespace AppliStation } } + internal void downloadActionInvoke(Installation[] pkgs) + { + AppliStation.Util.ExecutionProgressViewer prog = new AppliStation.Util.ExecutionProgressViewer(); + prog.Shown += delegate(object sender2, EventArgs e2) { + NaGet.SubCommands.NaGetDownloadToCache2 tasks = new NaGet.SubCommands.NaGetDownloadToCache2(pkgListsMan, pkgs); + prog.SetTaskSet(tasks); + prog.Refresh(); + prog.StartTaskSet(); + }; + prog.Text = string.Format("キャッシュへのダウンロード"); + prog.ShowDialog(this); + } + + void DownloadToolStripMenuItemClick(object sender, EventArgs e) + { + Installation[] insts = Installation.ConvertInstallations( NaGet.Utils.IEnumerable2Array(packageListView.SelectedPackages) ); + + downloadActionInvoke(insts); + + UpdatePackageList(); + } void WebOfficialMenuItemClick(object sender, EventArgs e) { @@ -658,30 +717,10 @@ namespace AppliStation // webGoogleSearchMenuItem always active. } - private IEnumerable getUpdatedPackages(PackageList installedPkgList, PackageList avaiablePkgList, IComparer verComp) - { - foreach (InstalledPackage pkg in installedPkgList) { - Package avaiablePkg = avaiablePkgList.GetPackageForName(pkg.Name); - - if (avaiablePkg != null) { - if (verComp.Compare(pkg.Version, avaiablePkg.Version) < 0 && - installedPkgList.GetPackageForPackage(pkg.Name, avaiablePkg.Version) == null) { - - yield return avaiablePkg; - } - } - } - } - void UpgradeToolStripButtonClick(object sender, EventArgs e) { - List pkgs; - VersionComparetor verComp = new VersionComparetor(); - PackageList avaiablePackageList = pkgListsMan.AvailablePkgList; - - pkgs = NaGet.Utils.MergeList( - getUpdatedPackages(pkgListsMan.InstalledPkgList, avaiablePackageList, verComp), - getUpdatedPackages(pkgListsMan.SystemInstalledPkgList, avaiablePackageList, verComp) + List pkgs = new List( + UpgradeFinder.GetUpgradePackages(pkgListsMan) ); if (pkgs.Count <= 0) {