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
12 namespace com.andoutomo.kybernetes.view
\r
14 public partial class BaseForm : Form
\r
18 InitializeComponent();
\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
30 history = new CmdHistory();
\r
32 this.Text = AppInfoContainer.Title + " " + AppInfoContainer.Description;
\r
36 private CmdHistory history;
\r
39 /// カテゴリ設定ダイアログを表示します。
\r
41 /// <param name="arg"></param>
\r
42 public void invokeCategSettingDialog(List<CategoryData> arg)
\r
44 CategorySetting categSetting = new CategorySetting();
\r
45 categSetting.StartPosition = FormStartPosition.CenterParent;
\r
46 categSetting.setCategoryList(arg);
\r
47 categSetting.ShowDialog();
\r
53 public void invokeCreditDialog()
\r
55 Credit creditForm = new Credit();
\r
56 creditForm.StartPosition = FormStartPosition.CenterParent;
\r
58 creditForm.ShowDialog();
\r
61 /// エクスポート用のファイルダイアログを開いて選択したファイルパスを返します。
\r
63 /// <returns></returns>
\r
64 public string invokeExpDialog()
\r
66 DialogResult result = this.expData.ShowDialog();
\r
67 if (result == DialogResult.OK)
\r
69 return this.expData.FileName;
\r
73 return string.Empty;
\r
77 /// ダンプ用のファイルダイアログを開いて選択したファイルパスを返します。
\r
79 /// <returns></returns>
\r
80 public string invokeDmpDialog()
\r
82 DialogResult result = this.dmpData.ShowDialog();
\r
83 if (result == DialogResult.OK)
\r
85 return this.dmpData.FileName;
\r
87 return string.Empty;
\r
90 /// バッチ呼び出しダイアログを呼び出します。
\r
92 /// <returns></returns>
\r
93 public string invokeShellDialog()
\r
96 DialogResult result = this.selSh.ShowDialog();
\r
97 if (result == DialogResult.OK)
\r
99 return this.selSh.FileName;
\r
101 return string.Empty;
\r
105 /// タイムエリア設定画面を表示します。
\r
107 /// <param name="arg"></param>
\r
108 public void invokeTimeareaSettingDialog(List<TimeAreaData> arg)
\r
110 TimeAreaSetting setting = new TimeAreaSetting();
\r
111 setting.StartPosition = FormStartPosition.CenterParent;
\r
112 setting.setTimeareaList(arg);
\r
113 setting.ShowDialog();
\r
117 /// コンソールに文字列を表示します。
\r
119 /// <param name="args">表示したい文字列</param>
\r
120 public void addText(string args)
\r
122 rConsole.AppendText(args + System.Environment.NewLine);
\r
123 KybernetesLogger.Log.trace(args);
\r
127 /// コンソールに複数文章を追加します。
\r
129 /// <param name="messages">追加したい文章群</param>
\r
130 public void addMultiText(List<string> messages)
\r
132 foreach (string message in messages)
\r
136 rConsole.AppendText(System.Environment.NewLine);
\r
138 private void addPrompt()
\r
140 rConsole.AppendText("> ");
\r
143 public int getPanelSize()
\r
145 return this.pnlTask.Width;
\r
150 public void clearText()
\r
153 rTotalConsole.Clear();
\r
154 rEstConsole.Clear();
\r
157 private bool exitSwitch = false;
\r
158 public bool ExitSwitch
\r
160 set { exitSwitch = value; }
\r
163 private int lastRow = 17;
\r
167 /// <param name="data"></param>
\r
168 public void addPanel(TaskData data)
\r
170 Panel targetPanel = new PanelController(this).createRow(lastRow, data);
\r
172 pnlTask.Controls.Add(targetPanel);
\r
173 lastRow += targetPanel.Height - 1;
\r
176 /// インデックスパネルを追加します
\r
178 /// <param name="timeArea"></param>
\r
179 public void addIndexPanel(string timeArea)
\r
181 Panel targetPanel = new IndexPanelController().createRow(timeArea, this.pnlTask.Width, lastRow, frColor);
\r
183 pnlTask.Controls.Add(targetPanel);
\r
184 lastRow += targetPanel.Height - 1;
\r
189 /// パネルがダブルクリックされた時に対応します。IDをテキストボックスに転記します。
\r
191 /// <param name="data"></param>
\r
192 public void AddIDToText(string data)
\r
194 this.txtInput.Text += data + " ";
\r
196 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r
202 public void clearPanel()
\r
204 this.pnlTask.AutoScrollPosition = new Point(0, 0);
\r
206 int dummy = pnlTask.Controls.Count;
\r
207 for (int h = dummy; h > 0; h--)
\r
209 Control ctrl = pnlTask.Controls[h - 1];
\r
211 for (int i = ctrl.Controls.Count; i > 0; i--)
\r
213 ctrl.Controls[i - 1].Dispose();
\r
218 pnlTask.Controls.Clear();
\r
221 pnlTask.Controls.Add(new CaptionPanelController().createRow(this.pnlTask.Width, frColor));
\r
226 /// コマンド内容を表示するかどうかを決定します。
\r
236 /// <param name="sender"></param>
\r
237 /// <param name="e"></param>
\r
238 private void txtInput_KeyDown(object sender, KeyEventArgs e)
\r
240 int currentYPosition;
\r
241 int currentScrollHeight = this.pnlTask.Height - 25;
\r
245 e.SuppressKeyPress = true;
\r
253 e.SuppressKeyPress = true;
\r
254 if (txtInput.ImeMode == ImeMode.Off)
\r
256 txtInput.ImeMode = ImeMode.On;
\r
260 txtInput.ImeMode = ImeMode.Off;
\r
265 e.SuppressKeyPress = true;
\r
266 history.resetPosition();
\r
270 e.SuppressKeyPress = true;
\r
272 txtInput.Text = history.prevCommand();
\r
273 txtInput.Select(this.txtInput.Text.Length, 0);
\r
277 e.SuppressKeyPress = true;
\r
279 txtInput.Text = history.nextCommand();
\r
280 txtInput.Select(this.txtInput.Text.Length, 0);
\r
283 case Keys.PageDown:
\r
284 currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);
\r
287 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition + 25);
\r
291 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition + currentScrollHeight);
\r
296 currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);
\r
299 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition - 25);
\r
303 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition - currentScrollHeight);
\r
317 private void doCommand()
\r
323 addText(txtInput.Text);
\r
325 KybernetesLogger.Log.trace("[dispatch]" + txtInput.Text);
\r
328 string result = wkOnCmdDispatch(txtInput.Text.Trim());
\r
329 if (!string.IsNullOrEmpty(result))
\r
335 if (!string.IsNullOrEmpty(txtInput.Text))
\r
337 history.stackCmd(txtInput.Text);
\r
340 txtInput.ImeMode = ImeMode.Off;
\r
342 if (exitSwitch == true)
\r
350 /// 文字入力ボックスを表示します。
\r
352 /// <param name="prompt"></param>
\r
353 /// <returns></returns>
\r
354 public string showInputBox(string prompt)
\r
356 return this.showInputBox(prompt, string.Empty);
\r
359 /// 文字入力ボックスを表示します。
\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
366 return showInputBox(prompt, defaultData, ImeMode.Off);
\r
369 /// 文字入力ボックスを表示します。
\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
377 InputBox inputBox = new InputBox(prompt, defaultData);
\r
378 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
379 inputBox.ImeMode = imeMode;
\r
380 inputBox.Owner = this;
\r
383 DialogResult res = inputBox.ShowDialog();
\r
384 if (res == DialogResult.OK)
\r
386 return InputDialogData;
\r
391 /// 文字入力ボックスを表示します。
\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
399 return showInputBox(prompt, string.Empty, imeMode);
\r
403 /// 文字入力ボックスを表示します。プロンプトなし版です。
\r
405 /// <returns></returns>
\r
406 public string showInputBox()
\r
408 return showInputBox("");
\r
413 /// プロンプトで指定した値を(プロンプトがここに)格納します。
\r
415 public string InputDialogData
\r
422 /// ドロップダウン式リストを表示します。
\r
424 /// <param name="prompt"></param>
\r
425 /// <returns></returns>
\r
426 public string showDropBoxInputBox(List<SimpleDataBean> list, string prompt,out bool isOK)
\r
428 DropBoxInputBox inputBox = new DropBoxInputBox(prompt);
\r
429 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
430 inputBox.setDropData(list);
\r
432 inputBox.Owner = this;
\r
434 DialogResult res = inputBox.ShowDialog();
\r
435 if (res == DialogResult.OK)
\r
438 return InputDialogData;
\r
444 /// ドロップダウン式リストを表示します。デフォルト表示を追加しています。
\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
452 DropBoxInputBox inputBox = new DropBoxInputBox(prompt, defaultData);
\r
453 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
454 inputBox.setDropData(list);
\r
456 inputBox.Owner = this;
\r
458 DialogResult res = inputBox.ShowDialog();
\r
459 if (res == DialogResult.OK)
\r
462 return InputDialogData;
\r
468 /// ファイル選択ダイアログつきインプットボックスを表示します。
\r
470 /// <param name="prompt"></param>
\r
471 /// <returns></returns>
\r
472 public string showFileInputBox(string prompt)
\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
480 return InputDialogData;
\r
488 /// マウスでコンソールをドラッグした時に、選択対象をクリップボードにコピーします。
\r
490 /// <param name="sender"></param>
\r
491 /// <param name="e"></param>
\r
492 private void rConsole_MouseUp(object sender, MouseEventArgs e)
\r
495 Clipboard.SetDataObject(rConsole.SelectedText.Trim());
\r
496 //txtInput.Text += rConsole.SelectedText.Trim();
\r
499 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r
502 /// 選択対象をクリップボードにコピーします。サブコンソール版です。
\r
504 /// <param name="sender"></param>
\r
505 /// <param name="e"></param>
\r
506 private void rSubConsole_MouseUp(object sender, MouseEventArgs e)
\r
508 Clipboard.SetDataObject(rEstConsole.SelectedText.Trim());
\r
511 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r
515 /// 背景色設定を呼び出します。コンテンツすべてが対象です。
\r
517 public bool setPnlBackground()
\r
519 DialogResult res = this.BGColorDlg.ShowDialog();
\r
520 if (res == System.Windows.Forms.DialogResult.OK)
\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
529 else { return false; }
\r
535 /// <returns></returns>
\r
536 public bool setPnlForeground()
\r
538 DialogResult res = this.FRColorDlg.ShowDialog();
\r
539 if (res == System.Windows.Forms.DialogResult.OK)
\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
548 else { return false; }
\r
550 private Color frColor = Color.White;
\r
552 /// スプリッターが動いた時に、入力ボックスにフォーカスを移します。
\r
554 /// <param name="sender"></param>
\r
555 /// <param name="e"></param>
\r
556 private void splBase_SplitterMoved(object sender, SplitterEventArgs e)
\r
563 /// タイマーはモードレスダイアログとして表示されます。
\r
565 /// <returns></returns>
\r
566 public void showTimer(int second)
\r
571 form = new ClockForm(second * 60);
\r
575 form = new ClockForm();
\r
581 /// タイマーを呼び出します。タイトルも付けます。
\r
583 /// <param name="second"></param>
\r
584 /// <param name="title"></param>
\r
585 public void showTimer(int second, string title)
\r
590 form = new ClockForm(second * 60, title);
\r
594 form = new ClockForm(title);
\r
600 [DllImport("user32.dll")]
\r
601 static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);
\r
606 [StructLayout(LayoutKind.Sequential)]
\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
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
627 public void showAlert()
\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
636 FlashWindowEx(ref fInfo);
\r
640 /// バッチコマンド用です。ちょっと迂遠ですが、バッチで読み込んだコマンドを
\r
641 /// フォームで受け取り、さらにもう一回ディスパッチをフォームから依頼します。
\r
643 /// <param name="command"></param>
\r
644 public void cmdForBatch(string command)
\r
646 this.addText(wkOnCmdDispatch(command));
\r
650 /// コマンド実行時のハンドラです。
\r
652 /// <param name="sender"></param>
\r
653 /// <param name="e"></param>
\r
654 public delegate void CmdDispatchEventHandler(object sender, CmdDispatchEventArg e);
\r
657 /// コマンドイベントです。コマンド実行時処理をここに設定してください。
\r
659 public event CmdDispatchEventHandler onCmdDispatch;
\r
661 /// コマンドディスパッチを実施し、戻り値(CmdDispatchEventArg.Result)から
\r
662 /// 画面表示用のテキストを受領します。
\r
664 /// <param name="command"></param>
\r
665 /// <returns></returns>
\r
666 string wkOnCmdDispatch(string command)
\r
668 if (onCmdDispatch != null)
\r
670 CmdDispatchEventArg args = new CmdDispatchEventArg();
\r
671 args.Command = command;
\r
673 onCmdDispatch(this, args);
\r
675 return args.Result;
\r
679 throw new KybernetesApplicationException();
\r
683 /// 時間予測コンソールに文字を追加します。
\r
685 /// <param name="estTimeStr"></param>
\r
686 public void showOnEstConsole(List<EstTextSet> estTimeStr)
\r
688 this.rEstConsole.Text = string.Empty;
\r
689 foreach (EstTextSet str in estTimeStr)
\r
691 this.rEstConsole.AppendText(str.Text);
\r
692 int currentSelectionStart = rEstConsole.SelectionStart - str.Text.Length;
\r
694 Color tmpColor = str.TxtColor;
\r
695 if (tmpColor == Color.Transparent)
\r
697 //tmpColor = this.frColor;
\r
698 tmpColor =rEstConsole.ForeColor;
\r
702 rEstConsole.Select(currentSelectionStart, str.Text.Length);
\r
703 rEstConsole.SelectionColor = tmpColor;
\r
704 rEstConsole.Select(rEstConsole.Text.Length, 0);
\r
708 /// 合計時間コンソールに文字を追加します。
\r
710 /// <param name="dataList"></param>
\r
711 public void showOnTotalConsole(List<EstTextSet> dataList)
\r
713 this.rTotalConsole.Text = string.Empty;
\r
714 Font baseFont = rTotalConsole.SelectionFont;
\r
716 foreach (EstTextSet data in dataList)
\r
718 this.rTotalConsole.AppendText(data.Text);
\r
719 int currentSelectionStart = rTotalConsole.SelectionStart - data.Text.Length;
\r
721 Color tmpColor = data.TxtColor;
\r
722 if (tmpColor == Color.Transparent)
\r
724 tmpColor = rTotalConsole.ForeColor;
\r
727 rTotalConsole.Select(currentSelectionStart,data.Text.Length);
\r
728 rTotalConsole.SelectionColor = tmpColor;
\r
729 rTotalConsole.Select(rTotalConsole.Text.Length, 0);
\r
732 baseFont.Dispose();
\r
737 /// 取得したデータを元にタスクパネルにタスクを表示します。
\r
739 /// <param name="taskList"></param>
\r
740 public void showOnPanel(List<TaskData> taskList)
\r
744 string wkAreaForIndex = "";
\r
745 DateComponent wkIndexDate = new DateComponent("19000101");
\r
746 bool wkIsComplete = false;
\r
747 foreach (TaskData data in taskList)
\r
749 //data.Today = todayDate;
\r
750 if (!data.isComplete)
\r
753 if (wkIndexDate.calculateDateDiff(data.DoDate) != 0 || wkIsComplete)
\r
755 string wkBranc = " ";
\r
756 addIndexPanel(wkBranc);
\r
758 if (wkAreaForIndex != data.TimeArea || wkIndexDate.calculateDateDiff(data.DoDate) != 0 || wkIsComplete)
\r
760 string wkIndex = "-- " + data.TimeArea + " -- on " + data.DoDate.getDateString("yyyy/MM/dd");
\r
761 addIndexPanel(wkIndex);
\r
764 wkAreaForIndex = data.TimeArea;
\r
765 wkIndexDate = data.DoDate;
\r
766 wkIsComplete = false;
\r
771 if (wkIndexDate.calculateDateDiff(data.DoDate) > 0)
\r
773 string wkBranc = " ";
\r
774 addIndexPanel(wkBranc);
\r
776 wkAreaForIndex = data.TimeArea;
\r
777 wkIndexDate = data.DoDate;
\r
778 wkIsComplete = true;
\r
785 private void splConsole_SplitterMoved(object sender, SplitterEventArgs e)
\r
790 private void tabInfo_SelectedIndexChanged(object sender, EventArgs e)
\r
795 private void tabInfo_MouseUp(object sender, MouseEventArgs e)
\r
800 private void rForcastConsole_MouseUp(object sender, MouseEventArgs e)
\r
802 Clipboard.SetDataObject(rTotalConsole.SelectedText.Trim());
\r
805 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r
808 public TaskData taskFromTemplate
\r
813 public TaskData showTemplateTaskBox(List<TemplateData> dataList)
\r
815 TemplateBox tempBox = new TemplateBox();
\r
816 tempBox.setTemplateData(dataList);
\r
817 tempBox.Owner = this;
\r
819 DialogResult res = tempBox.ShowDialog();
\r
821 if (res == DialogResult.OK)
\r
823 return taskFromTemplate;
\r
828 private void tabChange()
\r
831 if (tabInfo.SelectedIndex == 0)
\r
833 tabInfo.SelectedIndex = 1;
\r
837 tabInfo.SelectedIndex = 0;
\r
845 /// 見積もり用コンソールの文字列クラス
\r
847 public class EstTextSet
\r
854 public Color TxtColor
\r
859 public EstTextSet(string text, Color prtxtColor)
\r
862 this.TxtColor = prtxtColor;
\r
864 public EstTextSet(string text): this(text, Color.Transparent) { }
\r
866 public EstTextSet(): this(System.Environment.NewLine) { }
\r