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
9 namespace com.andoutomo.kybernetes.view
\r
11 public partial class BaseForm : Form
\r
15 InitializeComponent();
\r
17 List<string> initialText = new List<string>();
\r
18 initialText.Add("#####################################################");
\r
19 initialText.Add("# " + AppInfoContainer.Title + " " + AppInfoContainer.Description);
\r
20 initialText.Add("# Version " + AppInfoContainer.VersionNo);
\r
21 initialText.Add("# " + AppInfoContainer.CopyRight);
\r
22 initialText.Add("# ");
\r
23 initialText.Add("#####################################################");
\r
24 addMultiText(initialText);
\r
27 history = new CmdHistory();
\r
29 this.Text = AppInfoContainer.Title + " " + AppInfoContainer.Description;
\r
34 private CmdHistory history;
\r
37 /// カテゴリ設定ダイアログを表示します。
\r
39 /// <param name="arg"></param>
\r
40 internal void invokeCategSettingDialog(List<CategoryData> arg)
\r
42 CategorySetting categSetting = new CategorySetting();
\r
43 categSetting.StartPosition = FormStartPosition.CenterParent;
\r
44 categSetting.setCategoryList(arg);
\r
45 categSetting.ShowDialog();
\r
51 internal void invokeCreditDialog()
\r
53 Credit creditForm = new Credit();
\r
54 creditForm.StartPosition = FormStartPosition.CenterParent;
\r
56 creditForm.ShowDialog();
\r
59 /// エクスポート用のファイルダイアログを開いて選択したファイルパスを返します。
\r
61 /// <returns></returns>
\r
62 internal string invokeExpDialog()
\r
64 DialogResult result =this.expData.ShowDialog();
\r
65 if (result == DialogResult.OK)
\r
67 return this.expData.FileName;
\r
71 return string.Empty;
\r
75 /// ダンプ用のファイルダイアログを開いて選択したファイルパスを返します。
\r
77 /// <returns></returns>
\r
78 internal string invokeDmpDialog()
\r
80 DialogResult result = this.dmpData.ShowDialog();
\r
81 if (result == DialogResult.OK)
\r
83 return this.dmpData.FileName;
\r
85 return string.Empty;
\r
89 /// タイムエリア設定画面を表示します。
\r
91 /// <param name="arg"></param>
\r
92 internal void invokeTimeareaSettingDialog(List<TimeAreaData> arg)
\r
94 TimeAreaSetting setting = new TimeAreaSetting();
\r
95 setting.StartPosition = FormStartPosition.CenterParent;
\r
96 setting.setTimeareaList(arg);
\r
97 setting.ShowDialog();
\r
101 /// コンソールに文字列を表示します。
\r
103 /// <param name="args">表示したい文字列</param>
\r
104 internal void addText(string args)
\r
106 rConsole.AppendText(args + System.Environment.NewLine);
\r
107 KybernetesLogger.Log.trace(args);
\r
111 /// コンソールに複数文章を追加します。
\r
113 /// <param name="messages">追加したい文章群</param>
\r
114 internal void addMultiText(List<string> messages)
\r
116 foreach (string message in messages)
\r
120 rConsole.AppendText(System.Environment.NewLine);
\r
122 private void addPrompt()
\r
124 rConsole.AppendText("> ");
\r
127 internal int getPanelSize()
\r
129 return this.pnlTask.Width;
\r
134 internal void clearText()
\r
139 private bool exitSwitch = false;
\r
140 internal bool ExitSwitch
\r
142 set { exitSwitch = value; }
\r
145 private int lastRow=17;
\r
149 /// <param name="data"></param>
\r
150 internal void addPanel(TaskData data)
\r
152 Panel targetPanel = new PanelController(this).createRow(lastRow,data);
\r
154 pnlTask.Controls.Add(targetPanel);
\r
155 lastRow += targetPanel.Height-1;
\r
159 /// パネルがダブルクリックされた時に対応します。IDをテキストボックスに転記します。
\r
161 /// <param name="data"></param>
\r
162 internal void AddIDToText(string data)
\r
164 this.txtInput.Text += data + " ";
\r
166 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r
173 internal void clearPanel()
\r
176 int dummy = pnlTask.Controls.Count;
\r
177 for (int h = dummy; h > 0; h--)
\r
179 Control ctrl = pnlTask.Controls[h - 1];
\r
180 for (int i = ctrl.Controls.Count; i > 0; i--)
\r
182 ctrl.Controls[i - 1].Dispose();
\r
188 //pnlTask.Controls.Clear();
\r
191 pnlTask.Controls.Add(new CaptionPanelController().createRow(this.pnlTask.Width));
\r
196 /// コマンド内容を表示するかどうかを決定します。
\r
206 /// <param name="sender"></param>
\r
207 /// <param name="e"></param>
\r
208 private void txtInput_KeyDown(object sender, KeyEventArgs e)
\r
210 int currentYPosition;
\r
211 int currentScrollHeight = this.pnlTask.Height - 20;
\r
215 e.SuppressKeyPress = true;
\r
223 e.SuppressKeyPress = true;
\r
224 if (txtInput.ImeMode == ImeMode.Off)
\r
226 txtInput.ImeMode = ImeMode.On;
\r
230 txtInput.ImeMode = ImeMode.Off;
\r
235 e.SuppressKeyPress = true;
\r
236 history.resetPosition();
\r
240 e.SuppressKeyPress = true;
\r
241 txtInput.Text = history.prevCommand();
\r
242 txtInput.Select(this.txtInput.Text.Length, 0);
\r
245 e.SuppressKeyPress = true;
\r
246 txtInput.Text = history.nextCommand();
\r
247 txtInput.Select(this.txtInput.Text.Length, 0);
\r
250 case Keys.PageDown:
\r
251 currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);
\r
252 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition + currentScrollHeight);
\r
256 currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);
\r
257 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition - currentScrollHeight);
\r
264 private void doCommand()
\r
270 addText(txtInput.Text);
\r
272 KybernetesLogger.Log.trace("[dispatch]" + txtInput.Text);
\r
273 CmdDispatcher dispatcher = CmdDispatcher.getDispatcher(this);
\r
275 string result = dispatcher.dispatch(txtInput.Text.Trim());
\r
276 if (!string.IsNullOrEmpty(result))
\r
282 if (!string.IsNullOrEmpty(txtInput.Text))
\r
284 history.stackCmd(txtInput.Text);
\r
287 txtInput.ImeMode = ImeMode.Off;
\r
289 if (exitSwitch == true)
\r
297 /// 文字入力ボックスを表示します。
\r
299 /// <param name="prompt"></param>
\r
300 /// <returns></returns>
\r
301 internal string showInputBox(string prompt)
\r
303 return this.showInputBox(prompt, string.Empty);
\r
306 /// 文字入力ボックスを表示します。
\r
308 /// <param name="prompt"></param>
\r
309 /// <param name="defaultData"></param>
\r
310 /// <returns></returns>
\r
311 internal string showInputBox(string prompt, string defaultData)
\r
313 return showInputBox(prompt, defaultData, ImeMode.Off);
\r
316 /// 文字入力ボックスを表示します。
\r
318 /// <param name="prompt"></param>
\r
319 /// <param name="defaultData"></param>
\r
320 /// <param name="imeMode"></param>
\r
321 /// <returns></returns>
\r
322 internal string showInputBox(string prompt, string defaultData, ImeMode imeMode)
\r
324 InputBox inputBox = new InputBox(prompt, defaultData);
\r
325 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
326 inputBox.ImeMode = imeMode;
\r
327 inputBox.Owner = this;
\r
330 DialogResult res = inputBox.ShowDialog();
\r
331 if (res == DialogResult.OK)
\r
333 return InputDialogData;
\r
338 /// 文字入力ボックスを表示します。
\r
340 /// <param name="prompt"></param>
\r
341 /// <param name="imeMode"></param>
\r
342 /// <returns></returns>
\r
343 internal string showInputBox(string prompt, ImeMode imeMode)
\r
345 return showInputBox(prompt, string.Empty, imeMode);
\r
349 /// 文字入力ボックスを表示します。プロンプトなし版です。
\r
351 /// <returns></returns>
\r
352 internal string showInputBox()
\r
354 return showInputBox("");
\r
359 /// プロンプトで指定した値を(プロンプトがここに)格納します。
\r
361 internal string InputDialogData
\r
368 /// ドロップダウン式リストを表示します。
\r
370 /// <param name="prompt"></param>
\r
371 /// <returns></returns>
\r
372 internal string showDropBoxInputBox(List<SimpleDataBean> list,string prompt)
\r
374 DropBoxInputBox inputBox = new DropBoxInputBox(prompt);
\r
375 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
376 inputBox.setDropData(list);
\r
378 inputBox.Owner = this;
\r
380 DialogResult res = inputBox.ShowDialog();
\r
381 if (res == DialogResult.OK)
\r
383 return InputDialogData;
\r
388 /// ドロップダウン式リストを表示します。デフォルト表示を追加しています。
\r
390 /// <param name="list"></param>
\r
391 /// <param name="prompt"></param>
\r
392 /// <param name="defaultData"></param>
\r
393 /// <returns></returns>
\r
394 internal string showDropBoxInputBox(List<SimpleDataBean> list, string prompt, string defaultData)
\r
396 DropBoxInputBox inputBox = new DropBoxInputBox(prompt,defaultData);
\r
397 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
398 inputBox.setDropData(list);
\r
400 inputBox.Owner = this;
\r
402 DialogResult res = inputBox.ShowDialog();
\r
403 if (res == DialogResult.OK)
\r
405 return InputDialogData;
\r
411 /// マウスでコンソールをドラッグした時に、選択対象を入力ボックスに追加します。
\r
413 /// <param name="sender"></param>
\r
414 /// <param name="e"></param>
\r
415 private void rConsole_MouseUp(object sender, MouseEventArgs e)
\r
417 txtInput.Text += rConsole.SelectedText.Trim();
\r
420 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r
424 /// ウィンドウ全体のサイズ変更時イベントハンドラです。
\r
426 /// <param name="sender"></param>
\r
427 /// <param name="e"></param>
\r
428 private void BaseForm_ResizeEnd(object sender, EventArgs e)
\r
434 /// タスクパネルの大きさ調整を行います。
\r
435 /// 起動されるのは、ウィンドウ全体のサイズ変更時、及びコマンド実行時です。
\r
437 private void panelResize()
\r
439 pnlTask.Size = new Size(this.Size.Width - 420, this.Size.Height - 50);
\r