OSDN Git Service

version 1.1.7.0
[kybernetes/Kybernetes.git] / main / view / BaseForm.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Windows.Forms;\r
4 using com.andoutomo.kybernetes.control;\r
5 using com.andoutomo.kybernetes.data.DAO;\r
6 using System.Drawing;\r
7 using com.andoutomo.kybernetes.data.accessor;\r
8 using System.Runtime.InteropServices;\r
9 using com.andoutomo.kybernetes.data;\r
10 \r
11 \r
12 namespace com.andoutomo.kybernetes.view\r
13 {\r
14     public partial class BaseForm : Form\r
15     {\r
16         public BaseForm()\r
17         {\r
18             InitializeComponent();\r
19 \r
20             List<string> initialText = new List<string>();\r
21             initialText.Add("#####################################################");\r
22             initialText.Add("# " + AppInfoContainer.Title + " " + AppInfoContainer.Description);\r
23             initialText.Add("# Version " + AppInfoContainer.VersionNo);\r
24             initialText.Add("# " + AppInfoContainer.CopyRight);\r
25             initialText.Add("# ");\r
26             initialText.Add("#####################################################");\r
27             addMultiText(initialText);\r
28 \r
29             addPrompt();\r
30             history = new CmdHistory();\r
31 \r
32             this.Text = AppInfoContainer.Title + " " + AppInfoContainer.Description;\r
33             Echo = true;\r
34             txtInput.Focus();\r
35         }\r
36         private CmdHistory history;\r
37 \r
38         /// <summary>\r
39         /// カテゴリ設定ダイアログを表示します。\r
40         /// </summary>\r
41         /// <param name="arg"></param>\r
42         public void invokeCategSettingDialog(List<CategoryData> arg)\r
43         {\r
44             CategorySetting categSetting = new CategorySetting();\r
45             categSetting.StartPosition = FormStartPosition.CenterParent;\r
46             categSetting.setCategoryList(arg);\r
47             categSetting.ShowDialog();\r
48         }\r
49 \r
50         /// <summary>\r
51         /// バージョン情報を表示します\r
52         /// </summary>\r
53         public void invokeCreditDialog()\r
54         {\r
55             Credit creditForm = new Credit();\r
56             creditForm.StartPosition = FormStartPosition.CenterParent;\r
57 \r
58             creditForm.ShowDialog();\r
59         }\r
60         /// <summary>\r
61         /// エクスポート用のファイルダイアログを開いて選択したファイルパスを返します。\r
62         /// </summary>\r
63         /// <returns></returns>\r
64         public string invokeExpDialog()\r
65         {\r
66             DialogResult result = this.expData.ShowDialog();\r
67             if (result == DialogResult.OK)\r
68             {\r
69                 return this.expData.FileName;\r
70             }\r
71             else\r
72             {\r
73                 return string.Empty;\r
74             }\r
75         }\r
76         /// <summary>\r
77         /// ダンプ用のファイルダイアログを開いて選択したファイルパスを返します。\r
78         /// </summary>\r
79         /// <returns></returns>\r
80         public string invokeDmpDialog()\r
81         {\r
82             DialogResult result = this.dmpData.ShowDialog();\r
83             if (result == DialogResult.OK)\r
84             {\r
85                 return this.dmpData.FileName;\r
86             }\r
87             return string.Empty;\r
88         }\r
89         /// <summary>\r
90         /// バッチ呼び出しダイアログを呼び出します。\r
91         /// </summary>\r
92         /// <returns></returns>\r
93         public string invokeShellDialog()\r
94         {\r
95 \r
96             DialogResult result = this.selSh.ShowDialog();\r
97             if (result == DialogResult.OK)\r
98             {\r
99                 return this.selSh.FileName;\r
100             }\r
101             return string.Empty;\r
102         }\r
103 \r
104         /// <summary>\r
105         /// タイムエリア設定画面を表示します。\r
106         /// </summary>\r
107         /// <param name="arg"></param>\r
108         public void invokeTimeareaSettingDialog(List<TimeAreaData> arg)\r
109         {\r
110             TimeAreaSetting setting = new TimeAreaSetting();\r
111             setting.StartPosition = FormStartPosition.CenterParent;\r
112             setting.setTimeareaList(arg);\r
113             setting.ShowDialog();\r
114         }\r
115 \r
116         /// <summary>\r
117         /// コンソールに文字列を表示します。\r
118         /// </summary>\r
119         /// <param name="args">表示したい文字列</param>\r
120         public void addText(string args)\r
121         {\r
122             rConsole.AppendText(args + System.Environment.NewLine);\r
123             KybernetesLogger.Log.trace(args);\r
124         }\r
125 \r
126         /// <summary>\r
127         /// コンソールに複数文章を追加します。\r
128         /// </summary>\r
129         /// <param name="messages">追加したい文章群</param>\r
130         public void addMultiText(List<string> messages)\r
131         {\r
132             foreach (string message in messages)\r
133             {\r
134                 addText(message);\r
135             }\r
136             rConsole.AppendText(System.Environment.NewLine);\r
137         }\r
138         private void addPrompt()\r
139         {\r
140             rConsole.AppendText("> ");\r
141         }\r
142 \r
143         public int getPanelSize()\r
144         {\r
145             return this.pnlTask.Width;\r
146         }\r
147         /// <summary>\r
148         /// コンソールをクリアします。\r
149         /// </summary>\r
150         public void clearText()\r
151         {\r
152             rConsole.Clear();\r
153             rTotalConsole.Clear();\r
154             rEstConsole.Clear();\r
155         }\r
156 \r
157         private bool exitSwitch = false;\r
158         public bool ExitSwitch\r
159         {\r
160             set { exitSwitch = value; }\r
161         }\r
162 \r
163         private int lastRow = 17;\r
164         /// <summary>\r
165         /// パネルを追加します。\r
166         /// </summary>\r
167         /// <param name="data"></param>\r
168         public void addPanel(TaskData data)\r
169         {\r
170             Panel targetPanel = new PanelController(this).createRow(lastRow, data);\r
171 \r
172             pnlTask.Controls.Add(targetPanel);\r
173             lastRow += targetPanel.Height - 1;\r
174         }\r
175         /// <summary>\r
176         /// インデックスパネルを追加します\r
177         /// </summary>\r
178         /// <param name="timeArea"></param>\r
179         public void addIndexPanel(string timeArea)\r
180         {\r
181             Panel targetPanel = new IndexPanelController().createRow(timeArea, this.pnlTask.Width, lastRow, frColor);\r
182 \r
183             pnlTask.Controls.Add(targetPanel);\r
184             lastRow += targetPanel.Height - 1;\r
185         }\r
186 \r
187 \r
188         /// <summary>\r
189         /// パネルがダブルクリックされた時に対応します。IDをテキストボックスに転記します。\r
190         /// </summary>\r
191         /// <param name="data"></param>\r
192         public void AddIDToText(string data)\r
193         {\r
194             this.txtInput.Text += data + " ";\r
195             txtInput.Focus();\r
196             this.txtInput.Select(this.txtInput.Text.Length, 0);\r
197         }\r
198 \r
199         /// <summary>\r
200         /// パネルをクリアします。\r
201         /// </summary>\r
202         public void clearPanel()\r
203         {\r
204             this.pnlTask.AutoScrollPosition = new Point(0, 0);\r
205 \r
206             int dummy = pnlTask.Controls.Count;\r
207             for (int h = dummy; h > 0; h--)\r
208             {\r
209                 Control ctrl = pnlTask.Controls[h - 1];\r
210 \r
211                 for (int i = ctrl.Controls.Count; i > 0; i--)\r
212                 {\r
213                     ctrl.Controls[i - 1].Dispose();\r
214                 }\r
215                 ctrl.Dispose();\r
216             }\r
217 \r
218             pnlTask.Controls.Clear();\r
219 \r
220             //先頭行は足す\r
221             pnlTask.Controls.Add(new CaptionPanelController().createRow(this.pnlTask.Width, frColor));\r
222             lastRow = 17;\r
223 \r
224         }\r
225         /// <summary>\r
226         /// コマンド内容を表示するかどうかを決定します。\r
227         /// </summary>\r
228         public bool Echo\r
229         {\r
230             get;\r
231             set;\r
232         }\r
233         /// <summary>\r
234         /// コマンド入力を受け付けます。\r
235         /// </summary>\r
236         /// <param name="sender"></param>\r
237         /// <param name="e"></param>\r
238         private void txtInput_KeyDown(object sender, KeyEventArgs e)\r
239         {\r
240             int currentYPosition;\r
241             int currentScrollHeight = this.pnlTask.Height - 25;\r
242             switch (e.KeyCode)\r
243             {\r
244                 case Keys.Enter:\r
245                     e.SuppressKeyPress = true;\r
246                     doCommand();\r
247 \r
248                     break;\r
249 \r
250                 case Keys.Space:\r
251                     if (e.Control)\r
252                     {\r
253                         e.SuppressKeyPress = true;\r
254                         if (txtInput.ImeMode == ImeMode.Off)\r
255                         {\r
256                             txtInput.ImeMode = ImeMode.On;\r
257                         }\r
258                         else\r
259                         {\r
260                             txtInput.ImeMode = ImeMode.Off;\r
261                         }\r
262                     }\r
263                     break;\r
264                 case Keys.Escape:\r
265                     e.SuppressKeyPress = true;\r
266                     history.resetPosition();\r
267                     txtInput.Clear();\r
268                     break;\r
269                 case Keys.Up:\r
270                     e.SuppressKeyPress = true;\r
271 \r
272                     txtInput.Text = history.prevCommand();\r
273                     txtInput.Select(this.txtInput.Text.Length, 0);\r
274 \r
275                     break;\r
276                 case Keys.Down:\r
277                     e.SuppressKeyPress = true;\r
278 \r
279                     txtInput.Text = history.nextCommand();\r
280                     txtInput.Select(this.txtInput.Text.Length, 0);\r
281 \r
282                     break;\r
283                 case Keys.PageDown:\r
284                     currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);\r
285                     if (e.Control)\r
286                     {\r
287                         this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition + 25);\r
288                     }\r
289                     else\r
290                     {\r
291                         this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition + currentScrollHeight);\r
292                     }\r
293                     break;\r
294 \r
295                 case Keys.PageUp:\r
296                     currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);\r
297                     if (e.Control)\r
298                     {\r
299                         this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition - 25);\r
300                     }\r
301                     else\r
302                     {\r
303                         this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition - currentScrollHeight);\r
304                     }\r
305                     break;\r
306                 case Keys.Tab:\r
307                     if (e.Control)\r
308                     {\r
309                         tabChange();\r
310                     }\r
311                     break;\r
312             }\r
313         }\r
314         /// <summary>\r
315         /// コマンドを実行します\r
316         /// </summary>\r
317         private void doCommand()\r
318         {\r
319             rConsole.Focus();\r
320 \r
321             if (Echo)\r
322             {\r
323                 addText(txtInput.Text);\r
324             }\r
325             KybernetesLogger.Log.trace("[dispatch]" + txtInput.Text);\r
326 \r
327 \r
328             string result = wkOnCmdDispatch(txtInput.Text.Trim());\r
329             if (!string.IsNullOrEmpty(result))\r
330             {\r
331                 addText(result);\r
332             }\r
333 \r
334             addPrompt();\r
335             if (!string.IsNullOrEmpty(txtInput.Text))\r
336             {\r
337                 history.stackCmd(txtInput.Text);\r
338             }\r
339             txtInput.Clear();\r
340             txtInput.ImeMode = ImeMode.Off;\r
341             //panelResize();\r
342             if (exitSwitch == true)\r
343             {\r
344                 this.Close();\r
345             }\r
346             txtInput.Focus();\r
347         }\r
348 \r
349         /// <summary>\r
350         /// 文字入力ボックスを表示します。\r
351         /// </summary>\r
352         /// <param name="prompt"></param>\r
353         /// <returns></returns>\r
354         public string showInputBox(string prompt)\r
355         {\r
356             return this.showInputBox(prompt, string.Empty);\r
357         }\r
358         /// <summary>\r
359         /// 文字入力ボックスを表示します。\r
360         /// </summary>\r
361         /// <param name="prompt"></param>\r
362         /// <param name="defaultData"></param>\r
363         /// <returns></returns>\r
364         public string showInputBox(string prompt, string defaultData)\r
365         {\r
366             return showInputBox(prompt, defaultData, ImeMode.Off);\r
367         }\r
368         /// <summary>\r
369         /// 文字入力ボックスを表示します。\r
370         /// </summary>\r
371         /// <param name="prompt"></param>\r
372         /// <param name="defaultData"></param>\r
373         /// <param name="imeMode"></param>\r
374         /// <returns></returns>\r
375         public string showInputBox(string prompt, string defaultData, ImeMode imeMode)\r
376         {\r
377             InputBox inputBox = new InputBox(prompt, defaultData);\r
378             inputBox.StartPosition = FormStartPosition.CenterParent;\r
379             inputBox.ImeMode = imeMode;\r
380             inputBox.Owner = this;\r
381 \r
382 \r
383             DialogResult res = inputBox.ShowDialog();\r
384             if (res == DialogResult.OK)\r
385             {\r
386                 return InputDialogData;\r
387             }\r
388             return null;\r
389         }\r
390         /// <summary>\r
391         /// 文字入力ボックスを表示します。\r
392         /// </summary>\r
393         /// <param name="prompt"></param>\r
394         /// <param name="imeMode"></param>\r
395         /// <returns></returns>\r
396         public string showInputBox(string prompt, ImeMode imeMode)\r
397         {\r
398 \r
399             return showInputBox(prompt, string.Empty, imeMode);\r
400         }\r
401 \r
402         /// <summary>\r
403         /// 文字入力ボックスを表示します。プロンプトなし版です。\r
404         /// </summary>\r
405         /// <returns></returns>\r
406         public string showInputBox()\r
407         {\r
408             return showInputBox("");\r
409         }\r
410 \r
411 \r
412         /// <summary>\r
413         /// プロンプトで指定した値を(プロンプトがここに)格納します。\r
414         /// </summary>\r
415         public string InputDialogData\r
416         {\r
417             private get;\r
418             set;\r
419         }\r
420 \r
421         /// <summary>\r
422         /// ドロップダウン式リストを表示します。\r
423         /// </summary>\r
424         /// <param name="prompt"></param>\r
425         /// <returns></returns>\r
426         public string showDropBoxInputBox(List<SimpleDataBean> list, string prompt,out bool isOK)\r
427         {\r
428             DropBoxInputBox inputBox = new DropBoxInputBox(prompt);\r
429             inputBox.StartPosition = FormStartPosition.CenterParent;\r
430             inputBox.setDropData(list);\r
431 \r
432             inputBox.Owner = this;\r
433 \r
434             DialogResult res = inputBox.ShowDialog();\r
435             if (res == DialogResult.OK)\r
436             {\r
437                 isOK = true;\r
438                 return InputDialogData;\r
439             }\r
440             isOK = false;\r
441             return null;\r
442         }\r
443         /// <summary>\r
444         /// ドロップダウン式リストを表示します。デフォルト表示を追加しています。\r
445         /// </summary>\r
446         /// <param name="list"></param>\r
447         /// <param name="prompt"></param>\r
448         /// <param name="defaultData"></param>\r
449         /// <returns></returns>\r
450         public string showDropBoxInputBox(List<SimpleDataBean> list, string prompt, string defaultData ,out bool isOK)\r
451         {\r
452             DropBoxInputBox inputBox = new DropBoxInputBox(prompt, defaultData);\r
453             inputBox.StartPosition = FormStartPosition.CenterParent;\r
454             inputBox.setDropData(list);\r
455 \r
456             inputBox.Owner = this;\r
457 \r
458             DialogResult res = inputBox.ShowDialog();\r
459             if (res == DialogResult.OK)\r
460             {\r
461                 isOK = true;\r
462                 return InputDialogData;\r
463             }\r
464             isOK = false;\r
465             return null;\r
466         }\r
467         /// <summary>\r
468         /// ファイル選択ダイアログつきインプットボックスを表示します。\r
469         /// </summary>\r
470         /// <param name="prompt"></param>\r
471         /// <returns></returns>\r
472         public string showFileInputBox(string prompt)\r
473         {\r
474             FileInputBox inputBox = new FileInputBox(prompt);\r
475             inputBox.StartPosition = FormStartPosition.CenterParent;\r
476             inputBox.Owner = this;\r
477             DialogResult res = inputBox.ShowDialog();\r
478             if (res == DialogResult.OK)\r
479             {\r
480                 return InputDialogData;\r
481             }\r
482             return null;\r
483         }\r
484 \r
485 \r
486 \r
487         /// <summary>\r
488         /// マウスでコンソールをドラッグした時に、選択対象をクリップボードにコピーします。\r
489         /// </summary>\r
490         /// <param name="sender"></param>\r
491         /// <param name="e"></param>\r
492         private void rConsole_MouseUp(object sender, MouseEventArgs e)\r
493         {\r
494 \r
495             Clipboard.SetDataObject(rConsole.SelectedText.Trim());\r
496             //txtInput.Text += rConsole.SelectedText.Trim();\r
497             txtInput.Focus();\r
498             //選択状態を解除する\r
499             this.txtInput.Select(this.txtInput.Text.Length, 0);\r
500         }\r
501         /// <summary>\r
502         /// 選択対象をクリップボードにコピーします。サブコンソール版です。\r
503         /// </summary>\r
504         /// <param name="sender"></param>\r
505         /// <param name="e"></param>\r
506         private void rSubConsole_MouseUp(object sender, MouseEventArgs e)\r
507         {\r
508             Clipboard.SetDataObject(rEstConsole.SelectedText.Trim());\r
509 \r
510             txtInput.Focus();\r
511             this.txtInput.Select(this.txtInput.Text.Length, 0);\r
512         }\r
513 \r
514         /// <summary>\r
515         /// 背景色設定を呼び出します。コンテンツすべてが対象です。\r
516         /// </summary>\r
517         public bool setPnlBackground()\r
518         {\r
519             DialogResult res = this.BGColorDlg.ShowDialog();\r
520             if (res == System.Windows.Forms.DialogResult.OK)\r
521             {\r
522                 pnlTask.BackColor = BGColorDlg.Color;\r
523                 rEstConsole.BackColor = BGColorDlg.Color;\r
524                 rConsole.BackColor = BGColorDlg.Color;\r
525                 rTotalConsole.BackColor = BGColorDlg.Color;\r
526                 txtInput.BackColor = BGColorDlg.Color;\r
527                 return true;\r
528             }\r
529             else { return false; }\r
530 \r
531         }\r
532         /// <summary>\r
533         /// 前景色設定を呼び出します.\r
534         /// </summary>\r
535         /// <returns></returns>\r
536         public bool setPnlForeground()\r
537         {\r
538             DialogResult res = this.FRColorDlg.ShowDialog();\r
539             if (res == System.Windows.Forms.DialogResult.OK)\r
540             {\r
541                 frColor = FRColorDlg.Color;\r
542                 rEstConsole.ForeColor = FRColorDlg.Color;\r
543                 rConsole.ForeColor = FRColorDlg.Color;\r
544                 rTotalConsole.ForeColor = FRColorDlg.Color;\r
545                 txtInput.ForeColor = FRColorDlg.Color;\r
546                 return true;\r
547             }\r
548             else { return false; }\r
549         }\r
550         private Color frColor = Color.White;\r
551         /// <summary>\r
552         /// スプリッターが動いた時に、入力ボックスにフォーカスを移します。\r
553         /// </summary>\r
554         /// <param name="sender"></param>\r
555         /// <param name="e"></param>\r
556         private void splBase_SplitterMoved(object sender, SplitterEventArgs e)\r
557         {\r
558             txtInput.Focus();\r
559         }\r
560         \r
561         /// <summary>\r
562         /// タイマーを呼び出します。\r
563         /// タイマーはモードレスダイアログとして表示されます。\r
564         /// </summary>\r
565         /// <returns></returns>\r
566         public void showTimer(int second)\r
567         {\r
568             ClockForm form;\r
569             if (second > 0)\r
570             {\r
571                 form = new ClockForm(second * 60);\r
572             }\r
573             else\r
574             {\r
575                 form = new ClockForm();\r
576             }\r
577             form.Owner = this;\r
578             form.Show();\r
579         }\r
580         /// <summary>\r
581         /// タイマーを呼び出します。タイトルも付けます。\r
582         /// </summary>\r
583         /// <param name="second"></param>\r
584         /// <param name="title"></param>\r
585         public void showTimer(int second, string title)\r
586         {\r
587             ClockForm form;\r
588             if (second > 0)\r
589             {\r
590                 form = new ClockForm(second * 60, title);\r
591             }\r
592             else\r
593             {\r
594                 form = new ClockForm(title);\r
595             }\r
596             form.Owner = this;\r
597             form.Show();\r
598         }\r
599         #region 点滅ロジック\r
600         [DllImport("user32.dll")]\r
601         static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);\r
602 \r
603         /// <summary>\r
604         /// 画面点滅制御用Struct\r
605         /// </summary>\r
606         [StructLayout(LayoutKind.Sequential)]\r
607         struct FLASHWINFO\r
608         {\r
609             public UInt32 cbSize;    // FLASHWINFO構造体のサイズ\r
610             public IntPtr hwnd;      // 点滅対象のウィンドウ・ハンドル\r
611             public UInt32 dwFlags;   // 以下の「FLASHW_XXX」のいずれか\r
612             public UInt32 uCount;    // 点滅する回数\r
613             public UInt32 dwTimeout; // 点滅する間隔(ミリ秒単位)\r
614         }\r
615 \r
616 \r
617         //private const UInt32 FLASHW_STOP = 0;        // 点滅を止める\r
618         //private const UInt32 FLASHW_CAPTION = 1;     // タイトルバーを点滅させる\r
619         //private const UInt32 FLASHW_TRAY = 2;        // タスクバー・ボタンを点滅させる\r
620         private const UInt32 FLASHW_ALL = 3;         // タスクバー・ボタンとタイトルバーを点滅させる\r
621         //private const UInt32 FLASHW_TIMER = 4;       // FLASHW_STOPが指定されるまでずっと点滅させる\r
622         //private const UInt32 FLASHW_TIMERNOFG = 12;  // ウィンドウが最前面に来るまでずっと点滅させる\r
623 \r
624         /// <summary>\r
625         /// タスクバーを点滅させる\r
626         /// </summary>\r
627         public void showAlert()\r
628         {\r
629             FLASHWINFO fInfo = new FLASHWINFO();\r
630             fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));\r
631             fInfo.hwnd = this.Handle;\r
632             fInfo.dwFlags = FLASHW_ALL;\r
633             fInfo.uCount = 5; // 点滅回数\r
634             fInfo.dwTimeout = 0;\r
635 \r
636             FlashWindowEx(ref fInfo);\r
637         }\r
638         #endregion\r
639         /// <summary>\r
640         /// バッチコマンド用です。ちょっと迂遠ですが、バッチで読み込んだコマンドを\r
641         /// フォームで受け取り、さらにもう一回ディスパッチをフォームから依頼します。\r
642         /// </summary>\r
643         /// <param name="command"></param>\r
644         public void cmdForBatch(string command)\r
645         {\r
646             this.addText(wkOnCmdDispatch(command));\r
647         }\r
648 \r
649         /// <summary>\r
650         /// コマンド実行時のハンドラです。\r
651         /// </summary>\r
652         /// <param name="sender"></param>\r
653         /// <param name="e"></param>\r
654         public delegate void CmdDispatchEventHandler(object sender, CmdDispatchEventArg e);\r
655 \r
656         /// <summary>\r
657         /// コマンドイベントです。コマンド実行時処理をここに設定してください。\r
658         /// </summary>\r
659         public event CmdDispatchEventHandler onCmdDispatch;\r
660         /// <summary>\r
661         /// コマンドディスパッチを実施し、戻り値(CmdDispatchEventArg.Result)から\r
662         /// 画面表示用のテキストを受領します。\r
663         /// </summary>\r
664         /// <param name="command"></param>\r
665         /// <returns></returns>\r
666         string wkOnCmdDispatch(string command)\r
667         {\r
668             if (onCmdDispatch != null)\r
669             {\r
670                 CmdDispatchEventArg args = new CmdDispatchEventArg();\r
671                 args.Command = command;\r
672 \r
673                 onCmdDispatch(this, args);\r
674 \r
675                 return args.Result;\r
676             }\r
677             else\r
678             {\r
679                 throw new KybernetesApplicationException();\r
680             }\r
681         }\r
682         /// <summary>\r
683         /// 時間予測コンソールに文字を追加します。\r
684         /// </summary>\r
685         /// <param name="estTimeStr"></param>\r
686         public void showOnEstConsole(List<EstTextSet> estTimeStr)\r
687         {\r
688             this.rEstConsole.Text = string.Empty;\r
689             foreach (EstTextSet str in estTimeStr)\r
690             {\r
691                 this.rEstConsole.AppendText(str.Text);\r
692                 int currentSelectionStart = rEstConsole.SelectionStart - str.Text.Length;\r
693                 \r
694                 Color tmpColor = str.TxtColor;\r
695                 if (tmpColor == Color.Transparent)\r
696                 {\r
697                     //tmpColor = this.frColor;\r
698                     tmpColor =rEstConsole.ForeColor;\r
699                 }\r
700 \r
701                 //色を変更する\r
702                 rEstConsole.Select(currentSelectionStart, str.Text.Length);\r
703                 rEstConsole.SelectionColor = tmpColor;\r
704                 rEstConsole.Select(rEstConsole.Text.Length, 0);\r
705             }\r
706         }\r
707         /// <summary>\r
708         /// 合計時間コンソールに文字を追加します。\r
709         /// </summary>\r
710         /// <param name="dataList"></param>\r
711         public void showOnTotalConsole(List<EstTextSet> dataList)\r
712         {\r
713             this.rTotalConsole.Text = string.Empty;\r
714             Font baseFont = rTotalConsole.SelectionFont;\r
715 \r
716             foreach (EstTextSet data in dataList)\r
717             {\r
718                 this.rTotalConsole.AppendText(data.Text);\r
719                 int currentSelectionStart = rTotalConsole.SelectionStart - data.Text.Length;\r
720 \r
721                 Color tmpColor = data.TxtColor;\r
722                 if (tmpColor == Color.Transparent)\r
723                 {\r
724                     tmpColor = rTotalConsole.ForeColor;\r
725                 }\r
726                 //色変更する\r
727                 rTotalConsole.Select(currentSelectionStart,data.Text.Length);\r
728                 rTotalConsole.SelectionColor = tmpColor;\r
729                 rTotalConsole.Select(rTotalConsole.Text.Length, 0);\r
730             }\r
731 \r
732             baseFont.Dispose();\r
733 \r
734         }\r
735 \r
736         /// <summary>\r
737         /// 取得したデータを元にタスクパネルにタスクを表示します。\r
738         /// </summary>\r
739         /// <param name="taskList"></param>\r
740         public void showOnPanel(List<TaskData> taskList)\r
741         {\r
742 \r
743             clearPanel();\r
744             string wkAreaForIndex = "";\r
745             DateComponent wkIndexDate = new DateComponent("19000101");\r
746             bool wkIsComplete = false;\r
747             foreach (TaskData data in taskList)\r
748             {\r
749                 //data.Today = todayDate;\r
750                 if (!data.isComplete)\r
751                 {\r
752                     //日付が違う場合\r
753                     if (wkIndexDate.calculateDateDiff(data.DoDate) != 0 || wkIsComplete)\r
754                     {\r
755                         string wkBranc = " ";\r
756                         addIndexPanel(wkBranc);\r
757                     }\r
758                     if (wkAreaForIndex != data.TimeArea || wkIndexDate.calculateDateDiff(data.DoDate) != 0 || wkIsComplete)\r
759                     {\r
760                         string wkIndex = "-- " + data.TimeArea + " -- on " + data.DoDate.getDateString("yyyy/MM/dd");\r
761                         addIndexPanel(wkIndex);\r
762                     }\r
763 \r
764                     wkAreaForIndex = data.TimeArea;\r
765                     wkIndexDate = data.DoDate;\r
766                     wkIsComplete = false;\r
767                 }\r
768                 else\r
769                 {\r
770                     //直前の日付が未来のときのみ\r
771                     if (wkIndexDate.calculateDateDiff(data.DoDate) > 0)\r
772                     {\r
773                         string wkBranc = " ";\r
774                         addIndexPanel(wkBranc);\r
775                     }\r
776                     wkAreaForIndex = data.TimeArea;\r
777                     wkIndexDate = data.DoDate;\r
778                     wkIsComplete = true;\r
779                 }\r
780                 addPanel(data);\r
781 \r
782             }\r
783         }\r
784         \r
785         private void splConsole_SplitterMoved(object sender, SplitterEventArgs e)\r
786         {\r
787             txtInput.Focus();\r
788         }\r
789 \r
790         private void tabInfo_SelectedIndexChanged(object sender, EventArgs e)\r
791         {\r
792             txtInput.Focus();\r
793         }\r
794 \r
795         private void tabInfo_MouseUp(object sender, MouseEventArgs e)\r
796         {\r
797             txtInput.Focus();\r
798         }\r
799 \r
800         private void rForcastConsole_MouseUp(object sender, MouseEventArgs e)\r
801         {\r
802             Clipboard.SetDataObject(rTotalConsole.SelectedText.Trim());\r
803 \r
804             txtInput.Focus();\r
805             this.txtInput.Select(this.txtInput.Text.Length, 0);\r
806         }\r
807 \r
808         public TaskData taskFromTemplate\r
809         {\r
810             private get;\r
811             set;\r
812         }\r
813         public TaskData showTemplateTaskBox(List<TemplateData> dataList)\r
814         {\r
815             TemplateBox tempBox = new TemplateBox();\r
816             tempBox.setTemplateData(dataList);\r
817             tempBox.Owner = this;\r
818             \r
819             DialogResult res = tempBox.ShowDialog();\r
820 \r
821             if (res == DialogResult.OK)\r
822             {\r
823                 return taskFromTemplate;\r
824             }\r
825             return null;\r
826         }\r
827 \r
828         private void tabChange()\r
829         {\r
830 \r
831             if (tabInfo.SelectedIndex == 0)\r
832             {\r
833                 tabInfo.SelectedIndex = 1;\r
834             }\r
835             else\r
836             {\r
837                 tabInfo.SelectedIndex = 0;\r
838             }\r
839         }\r
840 \r
841 \r
842 \r
843     }\r
844     /// <summary>\r
845     /// 見積もり用コンソールの文字列クラス\r
846     /// </summary>\r
847     public class EstTextSet\r
848     {\r
849         public string Text\r
850         {\r
851             get;\r
852             private set;\r
853         }\r
854         public Color TxtColor\r
855         {\r
856             get;\r
857             private set;\r
858         }\r
859         public EstTextSet(string text, Color prtxtColor)\r
860         {\r
861             this.Text = text;\r
862             this.TxtColor = prtxtColor;\r
863         }\r
864         public EstTextSet(string text): this(text, Color.Transparent) { }\r
865 \r
866         public EstTextSet(): this(System.Environment.NewLine) { }\r
867     }\r
868 \r
869 }