OSDN Git Service

AppliStation,ハッシュが非整合の時に尋ねるようにする部分の改良
authorttp <ttp@users.sourceforge.jp>
Sun, 11 May 2008 03:36:15 +0000 (03:36 +0000)
committerttp <ttp@users.sourceforge.jp>
Sun, 11 May 2008 03:36:15 +0000 (03:36 +0000)
git-svn-id: http://localhost/svn/AppliStation/trunk@906 34ed2c89-c49f-4a4b-abdb-c318350108cf

AppliStation/AppliStation.Util/ExecutionProgressViewer.cs
all-get/Main.cs
all-get/Util.cs
na-get-lib/NaGet.SubCommands/NaGetInstall.cs
na-get-lib/NaGet.SubCommands/NaGetTaskSet.cs

index c4de9a1..94dd6d5 100644 (file)
@@ -170,19 +170,28 @@ namespace AppliStation.Util
                        }\r
                }\r
                \r
-               private NaGetTaskQueryResult onTaskQueryRaised(object sender, NaGetTaskSetEventArgs e)\r
+               private NaGetTaskQueryResult onTaskQueryRaised(object sender, NaGetTaskQueryArgs e)\r
                {\r
-                       DialogResult result = MessageBox.Show(e.TaskMessage, this.Text,\r
-                                       MessageBoxButtons.OKCancel,\r
-                                       (e.Type == NaGetTaskSetEventType.WARNING_QUERY)? MessageBoxIcon.Warning : MessageBoxIcon.Question);\r
+                       MessageBoxButtons buttons = MessageBoxButtons.OKCancel;\r
+                       if (e.SelectionFlag == (NaGetTaskQueryResult.CONTINUE | NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
+                               buttons = MessageBoxButtons.AbortRetryIgnore;\r
+                       } else if (e.SelectionFlag == (NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
+                               buttons = MessageBoxButtons.RetryCancel;\r
+                       } else if (e.SelectionFlag == NaGetTaskQueryResult.CONTINUE) {\r
+                               buttons = MessageBoxButtons.OK;\r
+                       }\r
+                       \r
+                       DialogResult result = MessageBox.Show(e.Message, this.Text, buttons);\r
                        \r
                        switch (result) {\r
                                case DialogResult.OK:\r
-                               //case DialogResult.Ignore:\r
+                               case DialogResult.Ignore:\r
                                        return NaGetTaskQueryResult.CONTINUE;\r
                                case DialogResult.Cancel:\r
-                               //case DialogResult.Abort:\r
+                               case DialogResult.Abort:\r
                                        return NaGetTaskQueryResult.CANCEL;\r
+                               case DialogResult.Retry:\r
+                                       return NaGetTaskQueryResult.RETRY;\r
                                default:\r
                                        return NaGetTaskQueryResult.CANCELED_AUTOMATICALLY;\r
                        }\r
index 6d56b46..98b1a44 100644 (file)
@@ -290,9 +290,28 @@ namespace AllGet
                        \r
                        NaGet.SubCommands.NaGetInstall tasks = new NaGet.SubCommands.NaGetInstall(pkgListMan, installations);\r
                        tasks.Downloader = this.downloader;\r
-                       tasks.TaskQueryRaised += delegate(object sender, NaGetTaskSetEventArgs e) {\r
-                               return AllGet.Util.Confirm(e.TaskMessage + " [yN]? ", false)?\r
-                                       NaGetTaskQueryResult.CONTINUE : NaGetTaskQueryResult.CANCEL;\r
+                       tasks.TaskQueryRaised += delegate(object sender, NaGetTaskQueryArgs e) {\r
+                               char result = '\u0000';\r
+                               if (e.SelectionFlag == (NaGetTaskQueryResult.CONTINUE | NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
+                                       result = AllGet.Util.Query(e.Message + " [y/R/n]?", "yrn", 'r');\r
+                               } else if (e.SelectionFlag == (NaGetTaskQueryResult.RETRY | NaGetTaskQueryResult.CANCEL)) {\r
+                                       result = AllGet.Util.Query(e.Message + " [R/n]?", "rn", 'r');\r
+                               } else if (e.SelectionFlag == NaGetTaskQueryResult.CONTINUE) {\r
+                                       result = AllGet.Util.Query(e.Message + " [Y]?", "y", 'y');\r
+                               } else {\r
+                                       result = AllGet.Util.Query(e.Message + " [Y/n]?", "yn", 'y');\r
+                               }\r
+                               \r
+                               switch (result) {\r
+                                       case 'y':\r
+                                               return NaGetTaskQueryResult.CONTINUE;\r
+                                       case 'n':\r
+                                               return NaGetTaskQueryResult.CANCEL;\r
+                                       case 'r':\r
+                                               return NaGetTaskQueryResult.RETRY;\r
+                                       default:\r
+                                               return NaGetTaskQueryResult.CANCELED_AUTOMATICALLY;\r
+                               }\r
                        };\r
                        tasks.TaskSetRaised += delegate(object sender, NaGetTaskSetEventArgs e) { \r
                                switch (e.Type) {\r
index 621a056..1f39428 100644 (file)
@@ -5,34 +5,22 @@ namespace AllGet
        \r
        sealed class Util\r
        {\r
-//             public static char Query(string msg, string selections, char defaultSelection)\r
-//             {\r
-//                     Console.Write(msg);\r
-//                     string response = Console.ReadLine();\r
-//                     response.Trim();\r
-//                     if (response.Length < 1) return defaultSelection;\r
-//                     int resNum = selections.ToLower().IndexOf(response[0]);\r
-//                     if (resNum < 0 || resNum >= selections.Length) {\r
-//                             return Query(msg, selections, defaultSelection);\r
-//                     } else {\r
-//                             return selections[resNum];\r
-//                     }\r
-//             }\r
+               public static char Query(string msg, string selections, char defaultSelection)\r
+               {\r
+                       int resNum = -1;\r
+                       while (resNum < 0) {    \r
+                               Console.Write(msg);\r
+                               string response = Console.ReadLine();\r
+                               response = response.Trim().ToLower();\r
+                               if (response.Length < 1) return defaultSelection;\r
+                               resNum = selections.ToLower().IndexOf(response[0]);\r
+                       }\r
+                       return selections[resNum];\r
+               }\r
                \r
                public static bool Confirm(string msg, bool defaultSelection)\r
                {\r
-                       Console.Write(msg);\r
-                       string response = Console.ReadLine();\r
-                       \r
-                       switch (response.ToLower())\r
-                       {\r
-                               case "y":\r
-                                       return true;\r
-                               case "n":\r
-                                       return false;\r
-                               default:\r
-                                       return defaultSelection;\r
-                       }\r
+                       return Query(msg, "yn", defaultSelection? 'y' : 'n') == 'y';\r
                }\r
        }\r
 }\r
index ca67f78..55631eb 100644 (file)
@@ -136,7 +136,7 @@ namespace NaGet.SubCommands
                                // \83n\83b\83V\83\85\82ª\89ó\82ê\82Ä\82¢\82é\82Æ\82«\82Ì\91Î\8dô\r
                                if (invalid) {\r
                                        string msg = "\82¢\82­\82Â\82©\82Ì\83p\83b\83P\81[\83W\82Å\83t\83@\83C\83\8b\82ª\89ó\82ê\82Ä\82¢\82é\89Â\94\\90«\82ª\82 \82è\82Ü\82·\n\8b­\90§\93I\82É\83C\83\93\83X\83g\81[\83\8b\82ð\91±\8ds\82µ\82Ü\82·\82©?";\r
-                                       NaGetTaskQueryResult result = RaiseTaskSetQueryEvent(NaGetTaskSetEventType.WARNING_QUERY, msg);\r
+                                       NaGetTaskQueryResult result = RaiseTaskSetQueryEvent(msg, NaGetTaskQueryResult.CONTINUE | NaGetTaskQueryResult.CANCEL);\r
                                        \r
                                        if (result != NaGetTaskQueryResult.CONTINUE) {\r
                                                RaiseTaskSetEvent(NaGetTaskSetEventType.CANCELED, "\83p\83b\83P\81[\83W\82Ì\83C\83\93\83X\83g\81[\83\8b\8f\88\97\9d\82ª\83L\83\83\83\93\83Z\83\8b\82³\82ê\82Ü\82µ\82½");\r
index 75a43ac..cebd433 100644 (file)
@@ -2,6 +2,8 @@ using System;
 \r
 namespace NaGet.SubCommands\r
 {\r
+       #region EventHandler<NaGetTaskSetEventArgs>\8aÖ\98A\r
+       \r
        public class NaGetTaskSetEventArgs : NaGetEventArgs\r
        {\r
                public NaGetTaskSetEventType Type;\r
@@ -51,28 +53,59 @@ namespace NaGet.SubCommands
                /// \8dì\8bÆ\82ð\8fI\97¹\r
                /// </summary>\r
                COMPLETED_TASKSET,\r
+       }\r
+       \r
+       #endregion\r
+       \r
+       #region NaGetTaskQueryHandler\8aÖ\98A\r
+       \r
+       public delegate NaGetTaskQueryResult NaGetTaskQueryHandler(object sender, NaGetTaskQueryArgs e);\r
+       \r
+       public class NaGetTaskQueryArgs\r
+       {\r
                /// <summary>\r
-               /// \8e¿\96â\r
+               /// \83^\83X\83N\82Ì\8c»\8bµ\82Ì\83\81\83b\83Z\81[\83W\r
                /// </summary>\r
-               QUERY,\r
+               public string Message;\r
+               \r
                /// <summary>\r
-               /// \8cx\8d\90\82ð\8aÜ\82Þ\8e¿\96â\r
+               /// \89ñ\93\9a\82Ì\8eí\97Þ\82Ì\83t\83\89\83O\r
                /// </summary>\r
-               WARNING_QUERY,\r
+               public NaGetTaskQueryResult SelectionFlag;\r
+               \r
+               public NaGetTaskQueryArgs(string message, NaGetTaskQueryResult selectionFlag)\r
+               {\r
+                       this.Message = message;\r
+                       this.SelectionFlag = selectionFlag;\r
+               }\r
        }\r
        \r
        /// <summary>\r
        /// \8e¿\96â\82Ì\93\9a\82¦\r
        /// </summary>\r
-       public enum NaGetTaskQueryResult\r
+       [Flags()]\r
+       public enum NaGetTaskQueryResult : uint\r
        {\r
-               CONTINUE,\r
-               RETRY,\r
-               CANCEL,\r
-               CANCELED_AUTOMATICALLY,\r
+               /// <summary>\r
+               /// \8cp\91±(=OK)\r
+               /// </summary>\r
+               CONTINUE = 0x01,\r
+               /// <summary>\r
+               /// \8dÄ\8e\8e\8ds\r
+               /// </summary>\r
+               RETRY = 0x02,\r
+               /// <summary>\r
+               /// \83L\83\83\83\93\83Z\83\8b\81A\92\86\8e~\r
+               /// </summary>\r
+               CANCEL = 0x04,\r
+               /// <summary>\r
+               /// \8e©\93®\93I\82È\83L\83\83\83\93\83Z\83\8b(\83\86\81[\83U\82Ì\8eè\82Å\82Í\82È\82¢\82à\82Ì)\r
+               /// </summary>\r
+               CANCELED_AUTOMATICALLY = 0x00,\r
        }\r
        \r
-       public delegate NaGetTaskQueryResult NaGetTaskQueryHandler(object sender, NaGetTaskSetEventArgs e);\r
+       \r
+       #endregion\r
        \r
        /// <summary>\r
        /// NaGet\83^\83X\83N\8f\88\97\9d\82Ì\83p\83b\83N\r
@@ -128,16 +161,10 @@ namespace NaGet.SubCommands
                        }\r
                }\r
                \r
-               protected virtual NaGetTaskQueryResult RaiseTaskSetQueryEvent(NaGetTaskSetEventType type, string message)\r
-               {\r
-                       float percent = (CurrentTaskSetIndex >= 0)? CurrentTaskSetIndex * 100 / TaskSetNames.Length : -1;\r
-                       return RaiseTaskSetQueryEvent(type, message, percent);\r
-               }\r
-               \r
-               protected virtual NaGetTaskQueryResult RaiseTaskSetQueryEvent(NaGetTaskSetEventType type, string message, float percent)\r
+               protected virtual NaGetTaskQueryResult RaiseTaskSetQueryEvent(string message, NaGetTaskQueryResult selection)\r
                {\r
                        if (TaskQueryRaised != null) {\r
-                               return TaskQueryRaised(this, new NaGetTaskSetEventArgs(type, message, percent));\r
+                               return TaskQueryRaised(this, new NaGetTaskQueryArgs(message, selection));\r
                        }\r
                        return NaGetTaskQueryResult.CANCELED_AUTOMATICALLY;\r
                }\r