OSDN Git Service

AppliStation-GUI,タスク進捗ダイアログの自動クローズ機能を追加。
authorttp <ttp@users.sourceforge.jp>
Sat, 6 Sep 2008 13:36:51 +0000 (13:36 +0000)
committerttp <ttp@users.sourceforge.jp>
Sat, 6 Sep 2008 13:36:51 +0000 (13:36 +0000)
 * 正常に終了したあと3秒後に自動的に閉じるようにした
 * 閉じないようにするには、ユーザが「正常終了時に自動で閉じる(&A)」にチェックを入れる操作が必要

git-svn-id: http://localhost/svn/AppliStation/trunk@967 34ed2c89-c49f-4a4b-abdb-c318350108cf

AppliStation/AppliStation.Util/ExecutionProgressViewer.Designer.cs
AppliStation/AppliStation.Util/ExecutionProgressViewer.cs
AppliStation/AppliStation.Util/ExecutionProgressViewer.resx

index 3979fd2..1c625ae 100644 (file)
@@ -29,6 +29,7 @@ namespace AppliStation.Util
                /// </summary>\r
                private void InitializeComponent()\r
                {\r
+                       this.components = new System.ComponentModel.Container();\r
                        this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
                        this.progressSubLabel = new System.Windows.Forms.Label();\r
                        this.subtitleLabel = new System.Windows.Forms.Label();\r
@@ -36,9 +37,12 @@ namespace AppliStation.Util
                        this.progressLabel = new System.Windows.Forms.Label();\r
                        this.progressBarSub = new System.Windows.Forms.ProgressBar();\r
                        this.bottomPanel = new System.Windows.Forms.FlowLayoutPanel();\r
+                       this.autoCloseCheckBox = new System.Windows.Forms.CheckBox();\r
                        this.okButton = new System.Windows.Forms.Button();\r
                        this.cancelButton = new System.Windows.Forms.Button();\r
                        this.logBox = new System.Windows.Forms.RichTextBox();\r
+                       this.autoCloseTimer = new System.Windows.Forms.Timer(this.components);\r
+                       this.toolTip = new System.Windows.Forms.ToolTip(this.components);\r
                        this.tableLayoutPanel1.SuspendLayout();\r
                        this.bottomPanel.SuspendLayout();\r
                        this.SuspendLayout();\r
@@ -122,18 +126,31 @@ namespace AppliStation.Util
                        // bottomPanel\r
                        // \r
                        this.bottomPanel.AutoSize = true;\r
+                       this.bottomPanel.Controls.Add(this.autoCloseCheckBox);\r
                        this.bottomPanel.Controls.Add(this.okButton);\r
                        this.bottomPanel.Controls.Add(this.cancelButton);\r
                        this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Right;\r
-                       this.bottomPanel.Location = new System.Drawing.Point(279, 286);\r
+                       this.bottomPanel.Location = new System.Drawing.Point(100, 286);\r
                        this.bottomPanel.Name = "bottomPanel";\r
-                       this.bottomPanel.Size = new System.Drawing.Size(162, 29);\r
+                       this.bottomPanel.Size = new System.Drawing.Size(341, 29);\r
                        this.bottomPanel.TabIndex = 4;\r
                        // \r
+                       // autoCloseCheckBox\r
+                       // \r
+                       this.autoCloseCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+                       this.autoCloseCheckBox.AutoSize = true;\r
+                       this.autoCloseCheckBox.Checked = true;\r
+                       this.autoCloseCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;\r
+                       this.autoCloseCheckBox.Location = new System.Drawing.Point(3, 6);\r
+                       this.autoCloseCheckBox.Name = "autoCloseCheckBox";\r
+                       this.autoCloseCheckBox.Size = new System.Drawing.Size(173, 16);\r
+                       this.autoCloseCheckBox.TabIndex = 2;\r
+                       this.autoCloseCheckBox.Text = "正常終了時に自動で閉じる(&A)";\r
+                       // \r
                        // okButton\r
                        // \r
                        this.okButton.Enabled = false;\r
-                       this.okButton.Location = new System.Drawing.Point(3, 3);\r
+                       this.okButton.Location = new System.Drawing.Point(182, 3);\r
                        this.okButton.Name = "okButton";\r
                        this.okButton.Size = new System.Drawing.Size(75, 23);\r
                        this.okButton.TabIndex = 0;\r
@@ -144,7 +161,7 @@ namespace AppliStation.Util
                        // cancelButton\r
                        // \r
                        this.cancelButton.Enabled = false;\r
-                       this.cancelButton.Location = new System.Drawing.Point(84, 3);\r
+                       this.cancelButton.Location = new System.Drawing.Point(263, 3);\r
                        this.cancelButton.Name = "cancelButton";\r
                        this.cancelButton.Size = new System.Drawing.Size(75, 23);\r
                        this.cancelButton.TabIndex = 1;\r
@@ -154,7 +171,6 @@ namespace AppliStation.Util
                        // \r
                        // logBox\r
                        // \r
-                       this.logBox.BackColor = System.Drawing.SystemColors.Control;\r
                        this.logBox.DetectUrls = false;\r
                        this.logBox.Dock = System.Windows.Forms.DockStyle.Fill;\r
                        this.logBox.ForeColor = System.Drawing.SystemColors.ControlText;\r
@@ -166,6 +182,11 @@ namespace AppliStation.Util
                        this.logBox.TabIndex = 8;\r
                        this.logBox.Text = "";\r
                        // \r
+                       // autoCloseTimer\r
+                       // \r
+                       this.autoCloseTimer.Interval = 3000;\r
+                       this.autoCloseTimer.Tick += new System.EventHandler(this.AutoCloseTimerTick);\r
+                       // \r
                        // ExecutionProgressViewer\r
                        // \r
                        this.AcceptButton = this.okButton;\r
@@ -177,11 +198,16 @@ namespace AppliStation.Util
                        this.Name = "ExecutionProgressViewer";\r
                        this.Text = "AppliStation";\r
                        this.Shown += new System.EventHandler(this.ExecutionProgressViewerShown);\r
+                       this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ExecutionProgressViewerFormClosed);\r
                        this.tableLayoutPanel1.ResumeLayout(false);\r
                        this.tableLayoutPanel1.PerformLayout();\r
                        this.bottomPanel.ResumeLayout(false);\r
+                       this.bottomPanel.PerformLayout();\r
                        this.ResumeLayout(false);\r
                }\r
+               private System.Windows.Forms.ToolTip toolTip;\r
+               private System.Windows.Forms.Timer autoCloseTimer;\r
+               private System.Windows.Forms.CheckBox autoCloseCheckBox;\r
                private System.Windows.Forms.Button cancelButton;\r
                private System.Windows.Forms.Button okButton;\r
                private System.Windows.Forms.RichTextBox logBox;\r
index 9f704ba..7f2d33d 100644 (file)
@@ -38,6 +38,8 @@ namespace AppliStation.Util
                        InitializeComponent();\r
                        \r
                        this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);\r
+                       toolTip.SetToolTip(autoCloseCheckBox,\r
+                                          string.Format("エラーがなく正常に終了した場合、{0}秒後に自動的にこのダイアログを閉じます", autoCloseTimer.Interval/1000));\r
                }\r
                                \r
                private void onDownloadEvent(object sender, DownloadEventArgs a)\r
@@ -103,6 +105,9 @@ namespace AppliStation.Util
                                        if (taskSet.Done) {\r
                                                okButton.Enabled = true;\r
                                                cancelButton.Enabled = false;\r
+                                               \r
+                                               // タスクが完了したらしばらく待って閉じるために、自動クローズタイマーを起動する\r
+                                               autoCloseTimer.Start();\r
                                        }\r
                                        break;\r
                                case NaGetTaskSetEventType.STARTED_TASKSET:\r
@@ -128,6 +133,7 @@ namespace AppliStation.Util
                                        \r
                                        NativeMethods.ProgressBar_SetState(progressBar, 2); // VistaProgress色:エラー\r
                                        \r
+                                       autoCloseCheckBox.Enabled = false;\r
                                        okButton.Enabled = true;\r
                                        cancelButton.Enabled = false;\r
                                        break;\r
@@ -138,6 +144,7 @@ namespace AppliStation.Util
                                        \r
                                        NativeMethods.ProgressBar_SetState(progressBar, 1); // VistaProgress色:中断\r
                                        \r
+                                       autoCloseCheckBox.Enabled = false;\r
                                        okButton.Enabled = true;\r
                                        cancelButton.Enabled = false;\r
                                        break;\r
@@ -146,6 +153,7 @@ namespace AppliStation.Util
                                        logBox.AppendText("  [エラー] " + e.TaskMessage + System.Environment.NewLine);\r
                                        logBox.SelectionColor = logBox.ForeColor;\r
                                        \r
+                                       autoCloseCheckBox.Enabled = false;\r
                                        break;\r
                        }\r
                        \r
@@ -237,6 +245,7 @@ namespace AppliStation.Util
                \r
                void CancelButtonClickConcrete(object sender, EventArgs e)\r
                {\r
+                       autoCloseCheckBox.Enabled = false;\r
                        if (taskSet != null && taskSet.Running && taskSet.Cancelable) {\r
                                cancelButton.Enabled = false;\r
                                \r
@@ -250,5 +259,32 @@ namespace AppliStation.Util
                {\r
                        this.BringToFront();\r
                }\r
+               \r
+               void ExecutionProgressViewerFormClosed(object sender, FormClosedEventArgs e)\r
+               {\r
+                       autoCloseTimer.Enabled = false;\r
+               }\r
+               \r
+               void AutoCloseTimerTick(object sender, EventArgs e)\r
+               {\r
+                       autoCloseTimer.Stop();\r
+                       \r
+                       if (InvokeRequired) {\r
+                               Invoke(new EventHandler(AutoCloseTimerTickConcrete), sender, e);\r
+                       } else {\r
+                               AutoCloseTimerTickConcrete(sender,e);\r
+                       }\r
+               }\r
+               \r
+               void AutoCloseTimerTickConcrete(object sender, EventArgs e)\r
+               {\r
+                       // autoCloseCheckBoxが有効(正常終了)かつチェックのときに限り、OKボタンを自動的にクリック\r
+                       if (autoCloseCheckBox.Enabled && autoCloseCheckBox.Checked && okButton.Enabled) {\r
+                               OkButtonClick(sender, e);\r
+                       } else if (! autoCloseCheckBox.Enabled) {\r
+                               // タイマーの時間がすぎて、そのとき自動で閉じないようにしていしてあるならば、手動で閉じるように\r
+                               autoCloseCheckBox.Enabled = false;\r
+                       }\r
+               }\r
        }\r
 }\r
index 5ea0895..633fd8a 100644 (file)
   <resheader name="writer">\r
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
   </resheader>\r
+  <metadata name="autoCloseTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>150, 17</value>\r
+  </metadata>\r
+  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+    <value>34</value>\r
+  </metadata>\r
 </root>
\ No newline at end of file