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
175 pnlTask.Controls.Clear();
\r
177 pnlTask.Controls.Add(new CaptionPanelController().createRow(this.pnlTask.Width));
\r
181 /// コマンド内容を表示するかどうかを決定します。
\r
191 /// <param name="sender"></param>
\r
192 /// <param name="e"></param>
\r
193 private void txtInput_KeyDown(object sender, KeyEventArgs e)
\r
195 int currentYPosition;
\r
199 e.SuppressKeyPress = true;
\r
207 e.SuppressKeyPress = true;
\r
208 if (txtInput.ImeMode == ImeMode.Off)
\r
210 txtInput.ImeMode = ImeMode.On;
\r
214 txtInput.ImeMode = ImeMode.Off;
\r
219 e.SuppressKeyPress = true;
\r
220 history.resetPosition();
\r
224 e.SuppressKeyPress = true;
\r
225 txtInput.Text = history.prevCommand();
\r
228 e.SuppressKeyPress = true;
\r
229 txtInput.Text = history.nextCommand();
\r
232 case Keys.PageDown:
\r
233 currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);
\r
234 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition + 380);
\r
238 currentYPosition = Math.Abs(this.pnlTask.AutoScrollPosition.Y);
\r
239 this.pnlTask.AutoScrollPosition = new Point(0, currentYPosition - 380);
\r
246 private void doCommand()
\r
252 addText(txtInput.Text);
\r
254 KybernetesLogger.Log.trace("[dispatch]" + txtInput.Text);
\r
255 CmdDispatcher dispatcher = CmdDispatcher.getDispatcher(this);
\r
257 string result = dispatcher.dispatch(txtInput.Text.Trim());
\r
258 if (!string.IsNullOrEmpty(result))
\r
264 if (!string.IsNullOrEmpty(txtInput.Text))
\r
266 history.stackCmd(txtInput.Text);
\r
269 txtInput.ImeMode = ImeMode.Off;
\r
271 if (exitSwitch == true)
\r
279 /// 文字入力ボックスを表示します。
\r
281 /// <param name="prompt"></param>
\r
282 /// <returns></returns>
\r
283 internal string showInputBox(string prompt)
\r
285 return this.showInputBox(prompt, string.Empty);
\r
288 /// 文字入力ボックスを表示します。
\r
290 /// <param name="prompt"></param>
\r
291 /// <param name="defaultData"></param>
\r
292 /// <returns></returns>
\r
293 internal string showInputBox(string prompt, string defaultData)
\r
295 return showInputBox(prompt, defaultData, ImeMode.Off);
\r
298 /// 文字入力ボックスを表示します。
\r
300 /// <param name="prompt"></param>
\r
301 /// <param name="defaultData"></param>
\r
302 /// <param name="imeMode"></param>
\r
303 /// <returns></returns>
\r
304 internal string showInputBox(string prompt, string defaultData, ImeMode imeMode)
\r
306 InputBox inputBox = new InputBox(prompt, defaultData);
\r
307 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
308 inputBox.ImeMode = imeMode;
\r
309 inputBox.Owner = this;
\r
312 DialogResult res = inputBox.ShowDialog();
\r
313 if (res == DialogResult.OK)
\r
315 return InputDialogData;
\r
320 /// 文字入力ボックスを表示します。
\r
322 /// <param name="prompt"></param>
\r
323 /// <param name="imeMode"></param>
\r
324 /// <returns></returns>
\r
325 internal string showInputBox(string prompt, ImeMode imeMode)
\r
327 return showInputBox(prompt, string.Empty, imeMode);
\r
331 /// 文字入力ボックスを表示します。プロンプトなし版です。
\r
333 /// <returns></returns>
\r
334 internal string showInputBox()
\r
336 return showInputBox("");
\r
341 /// プロンプトで指定した値を(プロンプトがここに)格納します。
\r
343 internal string InputDialogData
\r
350 /// ドロップダウン式リストを表示します。
\r
352 /// <param name="prompt"></param>
\r
353 /// <returns></returns>
\r
354 internal string showDropBoxInputBox(List<SimpleDataBean> list,string prompt)
\r
356 DropBoxInputBox inputBox = new DropBoxInputBox(prompt);
\r
357 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
358 inputBox.setDropData(list);
\r
360 inputBox.Owner = this;
\r
362 DialogResult res = inputBox.ShowDialog();
\r
363 if (res == DialogResult.OK)
\r
365 return InputDialogData;
\r
370 /// ドロップダウン式リストを表示します。デフォルト表示を追加しています。
\r
372 /// <param name="list"></param>
\r
373 /// <param name="prompt"></param>
\r
374 /// <param name="defaultData"></param>
\r
375 /// <returns></returns>
\r
376 internal string showDropBoxInputBox(List<SimpleDataBean> list, string prompt, string defaultData)
\r
378 DropBoxInputBox inputBox = new DropBoxInputBox(prompt,defaultData);
\r
379 inputBox.StartPosition = FormStartPosition.CenterParent;
\r
380 inputBox.setDropData(list);
\r
382 inputBox.Owner = this;
\r
384 DialogResult res = inputBox.ShowDialog();
\r
385 if (res == DialogResult.OK)
\r
387 return InputDialogData;
\r
393 /// マウスでコンソールをドラッグした時に、選択対象を入力ボックスに追加します。
\r
395 /// <param name="sender"></param>
\r
396 /// <param name="e"></param>
\r
397 private void rConsole_MouseUp(object sender, MouseEventArgs e)
\r
399 txtInput.Text += rConsole.SelectedText.Trim();
\r
402 this.txtInput.Select(this.txtInput.Text.Length, 0);
\r