Develop and Download Open Source Software

Browse Subversion Repository

Contents of /RsiEditor/RsiEditor.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Fri Jun 4 08:26:57 2010 UTC (13 years, 10 months ago) by pex
File size: 41526 byte(s)


1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using System.IO;
9
10 namespace RipSync.RsiEditor
11 {
12 public partial class frmRsiEditor : Form
13 {
14 public const String strVersion = "Version 0.8 2010-06-06";
15 private const int iCheckModeString = 1; // 入力項目チェック文字モード
16 private const int iCheckModeNumeric = 5; // 入力項目チェック数値モード
17 private Boolean flgNotSave; //変更後保存していない:true
18 private RsiManager rsi = new RsiManager();
19 private Lang lang = new Lang();
20
21 public frmRsiEditor()
22 {
23 InitializeComponent();
24 }
25
26 /// <summary>
27 /// ロード処理。
28 /// </summary>
29 private void frmRsiEditor_Load(object sender, EventArgs e)
30 {
31 string[] flist;
32 int i;
33 string fid;
34 flist = lang.GetPofileList;
35 cboLangage.Items.Clear();
36 for (i = 0; i < flist.Length; i++ )
37 {
38 fid = flist[i];
39 fid = Path.GetFileNameWithoutExtension(@fid);
40 cboLangage.Items.Add(fid);
41 }
42 Managers.Configuration config = Managers.ApplicationManager.GetInstance().Configuration;
43 cboLangage.SelectedItem = config.Language;
44
45 InitializeControls();
46
47 //メッセージ表示領域
48 txtMessage.Text = __("「新規作成」または「読み込み」ボタンをクリックしてください。");
49
50 }
51
52 /// <summary>
53 /// コントロールを初期化する。
54 /// </summary>
55 public void InitializeControls()
56 {
57 //初期化時のコントロール使用禁止設定
58 SetControlsEnable(false);
59
60 //画面オブジェクトのTextプロパティセット
61 ApplyLanguage();
62
63 //基本
64 txtRsiFileName.Text = "";
65 txtRsiFileName.BackColor = SystemColors.Control;
66 txtEshi.Text = "";
67 txtEshi.BackColor = SystemColors.Window;
68 txtBase.Text = "";
69 txtBase.BackColor = SystemColors.Control;
70 txtBaseHeight.Text = "";
71 txtBaseHeight.BackColor = SystemColors.Window;
72 txtBaseWidth.Text = "";
73 txtBaseWidth.BackColor = SystemColors.Window;
74
75
76 //目
77 txtEyeClose.Text = "";
78 txtEyeClose.BackColor = SystemColors.Control;
79 txtEyeThin.Text = "";
80 txtEyeThin.BackColor = SystemColors.Control;
81 txtEyeNormal.Text = "";
82 txtEyeNormal.BackColor = SystemColors.Control;
83
84 //口
85 txtMouthA.Text = "";
86 txtMouthA.BackColor = SystemColors.Control;
87 txtMouthI.Text = "";
88 txtMouthI.BackColor = SystemColors.Control;
89 txtMouthU.Text = "";
90 txtMouthU.BackColor = SystemColors.Control;
91 txtMouthE.Text = "";
92 txtMouthE.BackColor = SystemColors.Control;
93 txtMouthO.Text = "";
94 txtMouthO.BackColor = SystemColors.Control;
95 txtMouthN.Text = "";
96 txtMouthN.BackColor = SystemColors.Control;
97 txtMouthXo.Text = "";
98 txtMouthXo.BackColor = SystemColors.Control;
99 txtMouthAa.Text = "";
100 txtMouthAa.BackColor = SystemColors.Control;
101
102 //目追加
103 txtEyeAdd1Name.Text = "";
104 txtEyeAdd1Name.BackColor = SystemColors.Window;
105 txtEyeAdd2Name.Text = "";
106 txtEyeAdd2Name.BackColor = SystemColors.Window;
107 txtEyeAdd3Name.Text = "";
108 txtEyeAdd3Name.BackColor = SystemColors.Window;
109 txtEyeAdd4Name.Text = "";
110 txtEyeAdd4Name.BackColor = SystemColors.Window;
111 txtEyeAdd5Name.Text = "";
112 txtEyeAdd5Name.BackColor = SystemColors.Window;
113 txtEyeAdd6Name.Text = "";
114 txtEyeAdd6Name.BackColor = SystemColors.Window;
115
116 txtEyeAdd1.Text = "";
117 txtEyeAdd1.BackColor = SystemColors.Control;
118 txtEyeAdd2.Text = "";
119 txtEyeAdd2.BackColor = SystemColors.Control;
120 txtEyeAdd3.Text = "";
121 txtEyeAdd3.BackColor = SystemColors.Control;
122 txtEyeAdd4.Text = "";
123 txtEyeAdd4.BackColor = SystemColors.Control;
124 txtEyeAdd5.Text = "";
125 txtEyeAdd5.BackColor = SystemColors.Control;
126 txtEyeAdd6.Text = "";
127 txtEyeAdd6.BackColor = SystemColors.Control;
128
129 //口追加
130 txtMouthAdd1Name.Text = "";
131 txtMouthAdd1Name.BackColor = SystemColors.Window;
132 txtMouthAdd2Name.Text = "";
133 txtMouthAdd2Name.BackColor = SystemColors.Window;
134 txtMouthAdd3Name.Text = "";
135 txtMouthAdd3Name.BackColor = SystemColors.Window;
136 txtMouthAdd4Name.Text = "";
137 txtMouthAdd4Name.BackColor = SystemColors.Window;
138 txtMouthAdd5Name.Text = "";
139 txtMouthAdd5Name.BackColor = SystemColors.Window;
140 txtMouthAdd6Name.Text = "";
141 txtMouthAdd6Name.BackColor = SystemColors.Window;
142
143 txtMouthAdd1.Text = "";
144 txtMouthAdd1.BackColor = SystemColors.Control;
145 txtMouthAdd2.Text = "";
146 txtMouthAdd2.BackColor = SystemColors.Control;
147 txtMouthAdd3.Text = "";
148 txtMouthAdd3.BackColor = SystemColors.Control;
149 txtMouthAdd4.Text = "";
150 txtMouthAdd4.BackColor = SystemColors.Control;
151 txtMouthAdd5.Text = "";
152 txtMouthAdd5.BackColor = SystemColors.Control;
153 txtMouthAdd6.Text = "";
154 txtMouthAdd6.BackColor = SystemColors.Control;
155
156 //基本設定のタブを表示するにゃん
157 tabGroup.SelectTab(0);
158
159 //メッセージ表示領域初期化にゃ
160 txtMessage.Text = "";
161
162 flgNotSave = false;
163 }
164
165 public void ApplyLanguage()
166 {
167 tabEyeAuto.Text = __(" 目自動 ");
168 btnSelectEyeClose.Text = __("選択");
169 label9.Text = __("閉目");
170 btnSelectEyeThin.Text = __("選択");
171 label8.Text = __("薄目");
172 btnSelectEyeNormal.Text = __("選択");
173 label7.Text = __("通常");
174 tabKihon.Text = __(" 基本設定 ");
175 btnSelectBase.Text = __("選択");
176 label6.Text = __("ピクセル");
177 label5.Text = __("ピクセル");
178 label4.Text = __("高さ(Y)");
179 label3.Text = __("幅 (X)");
180 label2.Text = __("ベース画像");
181 label1.Text = __("絵師-キャラ");
182 tabMouthAuto.Text = __(" 口自動 ");
183 btnSelectMouthXo.Text = __("選択");
184 label16.Text = __("ぉ");
185 btnSelectMouthAa.Text = __("選択");
186 label17.Text = __("ああ");
187 btnSelectMouthN.Text = __("選択");
188 label15.Text = __("ん");
189 btnSelectMouthO.Text = __("選択");
190 label13.Text = __("お");
191 btnSelectMouthE.Text = __("選択");
192 label14.Text = __("え");
193 btnSelectMouthU.Text = __("選択");
194 label10.Text = __("う");
195 btnSelectMouthI.Text = __("選択");
196 label11.Text = __("い");
197 btnSelectMouthA.Text = __("選択");
198 label12.Text = __("あ");
199 tabEyeManual.Text = __(" 目手動 ");
200 btnSelectEyeAdd6.Text = __("選択");
201 btnSelectEyeAdd5.Text = __("選択");
202 btnSelectEyeAdd4.Text = __("選択");
203 btnSelectEyeAdd3.Text = __("選択");
204 btnSelectEyeAdd2.Text = __("選択");
205 btnSelectEyeAdd1.Text = __("選択");
206 tabMouthManual.Text = __(" 口手動 ");
207 btnSelectMouthAdd6.Text = __("選択");
208 btnSelectMouthAdd5.Text = __("選択");
209 btnSelectMouthAdd4.Text = __("選択");
210 btnSelectMouthAdd3.Text = __("選択");
211 btnSelectMouthAdd2.Text = __("選択");
212 btnSelectMouthAdd1.Text = __("選択");
213 btnDelEyeAdd1.Text = __("削除");
214 btnDelEyeAdd2.Text = __("削除");
215 btnDelEyeAdd3.Text = __("削除");
216 btnDelEyeAdd4.Text = __("削除");
217 btnDelEyeAdd5.Text = __("削除");
218 btnDelEyeAdd6.Text = __("削除");
219 btnDelMouthAdd1.Text = __("削除");
220 btnDelMouthAdd2.Text = __("削除");
221 btnDelMouthAdd3.Text = __("削除");
222 btnDelMouthAdd4.Text = __("削除");
223 btnDelMouthAdd5.Text = __("削除");
224 btnDelMouthAdd6.Text = __("削除");
225 btnVirsion.Text = __("バージョン情報");
226 btnNewFile.Text = __("新規作成");
227 btnClose.Text = __("終了");
228 btnSaveAs.Text = __("別名保存");
229 btnSave.Text = __("保存");
230 btnRead.Text = __("読み込み");
231 openFileDialogRSI.Filter = __("RipSync定義(推奨)|*.RSI|みそもくそも全部|*.*");
232 saveFileDialog.Filter = __("RipSync定義(推奨)|*.RSI|みそもくそも全部|*.*");
233 openFileDialogGraphic.Filter = __("PNGファイル|*.png|みそもくそも全部|*.*");
234 label18.Text = __("RSIファイル");
235 label19.Text = __("見つかっちゃった。(笑)");
236 Text = __("RSI ファイルエディタ(仮称)");
237
238 if (btnSave.Enabled == false)
239 {
240 //起動直後に言語変更されたときはガイドメッセージも再表示する
241 //使い慣れていないケースだろうから、最初に押すボタンくらいは教えないとね。
242 txtMessage.Text = __("「新規作成」または「読み込み」ボタンをクリックしてください。");
243 }
244 else
245 {
246 //入力途中なら該当タブのガイダンスメッセージ表示
247 tabGroup_Click(null, null);
248 }
249
250 }
251
252 public string __(string s)
253 {
254 return lang.getMessage(s);
255 }
256
257 /// <summary>
258 /// 終了ボタン
259 /// </summary>
260 private void btnClose_Click(object sender, EventArgs e)
261 {
262 //終了にゃ
263 this.Close();
264 }
265
266 /// <summary>
267 /// 画面を閉じるイベント
268 /// </summary>
269 private void frmRsiEditor_FormClosing(object sender, FormClosingEventArgs e)
270 {
271 //保存されてなかったら確認にゃ
272 if (flgNotSave)
273 {
274 DialogResult dr = MessageBox.Show(__("設定が変更されていますよ?\n終了しちゃって良いんですか?"), __("質問"),
275 MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2 );
276 if (dr != DialogResult.OK)
277 {
278 e.Cancel = true;
279 return;
280 }
281 }
282
283 }
284
285 /// <summary>
286 /// 新規作成ボタン
287 /// </summary>
288 private void btnNewFile_Click(object sender, EventArgs e)
289 {
290 //保存されてなかったら確認にゃ
291 if (flgNotSave)
292 {
293 DialogResult dr = MessageBox.Show(__("設定が変更されていますよ?\n消しちゃって良いんですか?"), __("質問"),
294 MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
295 if (dr != DialogResult.OK)
296 {
297 return;
298 }
299 }
300
301 //初期化するにゃ
302 InitializeControls();
303
304 //新規RSIファイルを選択にゃ
305 //RSIファイル選択にゃ
306 if (saveFileDialog.ShowDialog() != DialogResult.OK)
307 {
308 return;
309 }
310 txtRsiFileName.Text = saveFileDialog.FileName;
311 //初期化時のコントロール使用可能設定
312 SetControlsEnable(true);
313
314 //未保存フラグ設定にゃ
315 flgNotSave = true;
316
317 tabGroup.SelectedIndex = 0;
318 tabGroup_Click(sender, e);
319 }
320
321 /// <summary>
322 /// 読み込みボタン
323 /// </summary>
324 private void btnRead_Click(object sender, EventArgs e)
325 {
326 //注意メッセージにゃ
327 DialogResult dr = MessageBox.Show(__("当プログラムで保存したRSIファイル以外を選択すると、\n保存時にデータを破壊する恐れがあります。"), __("☆☆☆ 注 意 ☆☆☆"),
328 MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
329 if (dr != DialogResult.OK)
330 {
331 return;
332 }
333
334 //保存されてなかったら確認にゃ
335 if (flgNotSave)
336 {
337 dr = MessageBox.Show(__("設定が変更されていますよ?\n消しちゃって良いんですか?"), __("質問"),
338 MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
339 if (dr != DialogResult.OK)
340 {
341 return;
342 }
343 }
344
345 //RSIファイル選択にゃ
346 if (openFileDialogRSI.ShowDialog() != DialogResult.OK)
347 {
348 return;
349 }
350
351 //初期化するにゃ
352 InitializeControls();
353
354 //RSIファイル読み込みにゃ
355 rsi = new RsiManager(openFileDialogRSI.FileName);
356
357 //画面に展開にゃ
358 formDataSet(openFileDialogRSI.FileName, rsi);
359
360 //初期化時のコントロール使用可能設定にゃん
361 SetControlsEnable(true);
362
363 //未保存フラグ初期化にゃ
364 flgNotSave = false;
365
366 tabGroup.SelectedIndex = 0;
367 tabGroup_Click(sender, e);
368 }
369
370 /// <summary>
371 /// SingerConfigの内容を画面の各項目にセットする
372 /// </summary>
373 private void formDataSet(String filename, RsiManager rsi)
374 {
375
376 //基本
377 txtRsiFileName.Text = filename;
378 txtEshi.Text = rsi.Eshi;
379 txtBase.Text = rsi.Base;
380 txtBaseHeight.Text = rsi.BaseHeight;
381 txtBaseWidth.Text = rsi.BaseWidth;
382
383 //目
384 txtEyeClose.Text = rsi.EyeClose;
385 txtEyeThin.Text = rsi.EyeThin;
386 txtEyeNormal.Text = rsi.EyeNormal;
387
388 //口
389 txtMouthA.Text = rsi.MouthA;
390 txtMouthI.Text = rsi.MouthI;
391 txtMouthU.Text = rsi.MouthU;
392 txtMouthE.Text = rsi.MouthE;
393 txtMouthO.Text = rsi.MouthO;
394 txtMouthN.Text = rsi.MouthN;
395 txtMouthXo.Text = rsi.MouthXo;
396 txtMouthAa.Text = rsi.MouthAa;
397
398 //目追加
399 // for で繰り返してぇなぁ~
400 txtEyeAdd1Name.Text = rsi.EyeAddName[0];
401 txtEyeAdd1.Text = rsi.EyeAdd[0];
402 txtEyeAdd2Name.Text = rsi.EyeAddName[1];
403 txtEyeAdd2.Text = rsi.EyeAdd[1];
404 txtEyeAdd3Name.Text = rsi.EyeAddName[2];
405 txtEyeAdd3.Text = rsi.EyeAdd[2];
406 txtEyeAdd4Name.Text = rsi.EyeAddName[3];
407 txtEyeAdd4.Text = rsi.EyeAdd[3];
408 txtEyeAdd5Name.Text = rsi.EyeAddName[4];
409 txtEyeAdd5.Text = rsi.EyeAdd[4];
410 txtEyeAdd6Name.Text = rsi.EyeAddName[5];
411 txtEyeAdd6.Text = rsi.EyeAdd[5];
412
413 //口追加
414 // for で繰り返してぇなぁ~
415 txtMouthAdd1Name.Text = rsi.MouthAddName[0];
416 txtMouthAdd1.Text = rsi.MouthAdd[0];
417 txtMouthAdd2Name.Text = rsi.MouthAddName[1];
418 txtMouthAdd2.Text = rsi.MouthAdd[1];
419 txtMouthAdd3Name.Text = rsi.MouthAddName[2];
420 txtMouthAdd3.Text = rsi.MouthAdd[2];
421 txtMouthAdd4Name.Text = rsi.MouthAddName[3];
422 txtMouthAdd4.Text = rsi.MouthAdd[3];
423 txtMouthAdd5Name.Text = rsi.MouthAddName[4];
424 txtMouthAdd5.Text = rsi.MouthAdd[4];
425 txtMouthAdd6Name.Text = rsi.MouthAddName[5];
426 txtMouthAdd6.Text = rsi.MouthAdd[5];
427
428 }
429
430 /// <summary>
431 /// 入力項目チェック処理
432 /// </summary>
433 private bool formDataCheck()
434 {
435 bool bRetFlg = false; //戻り値 true 正常、false エラーありにゃ
436 bool bErrFlg = false; //エラーフラグ true エラーあり、false エラーなしにゃ
437 try
438 {
439 //メッセージ領域初期化
440 txtMessage.Text = "";
441
442 //・名称の空白詰め 半角・全角
443 txtEshi.Text = txtEshi.Text.Trim();
444
445 // ・絵師の必須チェック
446 bErrFlg = formDataCheck_TextBox(txtEshi, __("絵師・キャラ名"), iCheckModeString, true) || bErrFlg;
447 //・絵師-キャラの型式チェック
448 // ⇒半角ハイフンの有無確認
449 if (txtEshi.Text.IndexOf("-") <= 0)
450 {
451 bErrFlg = true;
452 txtEshi.BackColor = Color.Red;
453 if (txtMessage.Text.Length == 0)
454 {
455 txtMessage.Text = __("絵師-キャラ名の入力型式が合ってません");
456 }
457 }
458
459 // ・ベース画像、サイズの必須チェック
460 bErrFlg = formDataCheck_TextBox(txtBase, __("ベース画像"), iCheckModeString, true) || bErrFlg;
461 bErrFlg = formDataCheck_TextBox(txtBaseHeight, __("ベース画像のサイズ"), iCheckModeNumeric, true) || bErrFlg;
462 bErrFlg = formDataCheck_TextBox(txtBaseWidth, __("ベース画像のサイズ"), iCheckModeNumeric, true) || bErrFlg;
463
464 // ・目自動、口自動の必須チェック
465 bErrFlg = formDataCheck_TextBox(txtEyeNormal, String.Concat(__("目自動"),", ",__("目通常")), iCheckModeString, true) || bErrFlg;
466 bErrFlg = formDataCheck_TextBox(txtEyeThin, String.Concat(__("目自動"),", ",__("薄目")), iCheckModeString, true) || bErrFlg;
467 bErrFlg = formDataCheck_TextBox(txtEyeClose, String.Concat(__("目自動"),", ",__("閉目")), iCheckModeString, true) || bErrFlg;
468 bErrFlg = formDataCheck_TextBox(txtMouthA, String.Concat(__("口自動"),", ",__("あ")), iCheckModeString, true) || bErrFlg;
469 bErrFlg = formDataCheck_TextBox(txtMouthI, String.Concat(__("口自動"),", ",__("い")), iCheckModeString, true) || bErrFlg;
470 bErrFlg = formDataCheck_TextBox(txtMouthU, String.Concat(__("口自動"),", ",__("う")), iCheckModeString, true) || bErrFlg;
471 bErrFlg = formDataCheck_TextBox(txtMouthE, String.Concat(__("口自動"),", ",__("え")), iCheckModeString, true) || bErrFlg;
472 bErrFlg = formDataCheck_TextBox(txtMouthO, String.Concat(__("口自動"),", ",__("お")), iCheckModeString, true) || bErrFlg;
473 bErrFlg = formDataCheck_TextBox(txtMouthN, String.Concat(__("口自動"),", ",__("ん")), iCheckModeString, true) || bErrFlg;
474 bErrFlg = formDataCheck_TextBox(txtMouthAa, String.Concat(__("口自動"),", ",__("ああ")), iCheckModeString, true) || bErrFlg;
475 bErrFlg = formDataCheck_TextBox(txtMouthXo, String.Concat(__("口自動"),", ",__("ぉ")), iCheckModeString, true) || bErrFlg;
476
477 // ・目手動、口手動の片葉チェック
478 // ・目手動、口手動の重複チェック
479 // ・自動と重複
480 // ・手動と重複
481
482
483 if (bErrFlg == false)
484 {
485 //エラーが見つからなかったら、戻り値は正常にゃ
486 bRetFlg = true;
487 }
488 //else
489 //{
490 // //エラーがあったらメッセージ表示にゃ
491 // MessageBox.Show(strErrMsg, __("入力エラー"),
492 // MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
493 //}
494 return bRetFlg;
495 }
496 catch (Exception e)
497 {
498 Logger.GetInstance().ErrorWrite("formDataCheck", e);
499 bRetFlg = false;
500 return bRetFlg;
501 }
502 }
503
504 private bool formDataCheck_TextBox(TextBox _TxtBox, String _strChkKmk, int _chkMode, bool _bHissu)
505 {
506 try
507 {
508 bool bErrFlg = false; //エラーフラグ
509
510 //最初のエラーだけ発見するためにwhileとbreakを使うにゃ
511 while (true)
512 {
513 //必須チェック
514 if (_TxtBox.Text == "")
515 {
516 if(txtMessage.Text.Length == 0 )
517 {
518 //txtMessage.Text = _strChkKmk + "を入力してください。";
519 txtMessage.Text = String.Format(__("{0}を入力してください。"), _strChkKmk);
520 }
521 bErrFlg = true;
522 break;
523 }
524
525 //数値項目なら数値チェック
526 if (_chkMode == iCheckModeNumeric)
527 {
528 try
529 {
530 int ii = Int16.Parse(_TxtBox.Text);
531 }
532 catch
533 {
534
535 if(txtMessage.Text.Length == 0 )
536 {
537 //txtMessage.Text = _strChkKmk + "には数値を入力してください。";
538 txtMessage.Text = String.Format(__("{0}には数値を入力してください。"), _strChkKmk);
539 }
540 bErrFlg = true;
541 }
542 }
543
544 //ループしないのにゃ
545 break;
546 }
547
548 //エラー項目の背景色を赤くするにゃ
549 if (bErrFlg == true)
550 {
551 _TxtBox.BackColor = Color.Red;
552 }
553 return bErrFlg;
554 }
555 catch(Exception e)
556 {
557 Logger.GetInstance().ErrorWrite("formDataCheck", e);
558 return true;
559 }
560
561 }
562
563 /// <summary>
564 /// 保存ボタン処理
565 /// </summary>
566 private void btnSave_Click(object sender, EventArgs e)
567 {
568 //入力項目をチェックにゃ
569 if (formDataCheck() == false)
570 {
571 //エラーがあった場合保存処理中止にゃ
572 return;
573 }
574
575 //新規のときは名前をつけて保存に飛ばすにゃ
576 if (txtRsiFileName.Text == "")
577 {
578 btnSaveAs_Click(sender, e);
579 }
580 else
581 {
582
583 //画面の各内容をRsiManagerにセットにゃ
584 form2RsiManager(rsi);
585
586 //保存するにゃ
587 if (rsi.Save(txtRsiFileName.Text) == true)
588 {
589 MessageBox.Show(__("保存しました。"), __("確認"), MessageBoxButtons.OK, MessageBoxIcon.Information);
590 }
591 else
592 {
593 MessageBox.Show(__("保存に失敗しました。"), __("エラー"), MessageBoxButtons.OK, MessageBoxIcon.Error);
594 }
595
596 //未保存フラグ初期化にゃ
597 flgNotSave = false;
598 }
599 }
600
601 /// <summary>
602 /// 名前をつけて保存
603 /// </summary>
604 private void btnSaveAs_Click(object sender, EventArgs e)
605 {
606 //入力項目をチェックにゃ
607 if (formDataCheck() == false)
608 {
609 //エラーがあった場合保存処理中止にゃ
610 return;
611 }
612
613 //RSIファイル選択にゃ
614 if (saveFileDialog.ShowDialog() != DialogResult.OK)
615 {
616 return;
617 }
618 txtRsiFileName.Text = saveFileDialog.FileName;
619
620
621 //画面の各内容をRsiManagerにセットにゃ
622 form2RsiManager(rsi);
623
624 //保存するにゃ
625 if (rsi.Save(txtRsiFileName.Text) == true)
626 {
627 MessageBox.Show(__("保存しました。"), __("確認"), MessageBoxButtons.OK, MessageBoxIcon.Information);
628 }
629 else
630 {
631 MessageBox.Show(__("保存に失敗しました。"), __("エラー"), MessageBoxButtons.OK, MessageBoxIcon.Error);
632 }
633
634 //未保存フラグ初期化にゃ
635 flgNotSave = false;
636 }
637
638 /// <summary>
639 /// 画面の各項目をRsiManagerクラスにセットする。
640 /// </summary>
641 private void form2RsiManager(RsiManager _rsi)
642 {
643 //基本
644 rsi.Eshi = txtEshi.Text;
645 rsi.Base = txtBase.Text;
646 rsi.BaseHeight = txtBaseHeight.Text;
647 rsi.BaseWidth = txtBaseWidth.Text;
648
649 //目
650 rsi.EyeClose = txtEyeClose.Text;
651 rsi.EyeThin = txtEyeThin.Text;
652 rsi.EyeNormal = txtEyeNormal.Text;
653
654 //口
655 rsi.MouthA = txtMouthA.Text;
656 rsi.MouthI = txtMouthI.Text;
657 rsi.MouthU = txtMouthU.Text;
658 rsi.MouthE = txtMouthE.Text;
659 rsi.MouthO = txtMouthO.Text;
660 rsi.MouthN = txtMouthN.Text;
661 rsi.MouthXo = txtMouthXo.Text;
662 rsi.MouthAa = txtMouthAa.Text;
663
664 //目追加
665 rsi.EyeAddName[0] = txtEyeAdd1Name.Text;
666 rsi.EyeAdd[0] = txtEyeAdd1.Text;
667 rsi.EyeAddName[1] = txtEyeAdd2Name.Text;
668 rsi.EyeAdd[1] = txtEyeAdd2.Text;
669 rsi.EyeAddName[2] = txtEyeAdd3Name.Text;
670 rsi.EyeAdd[2] = txtEyeAdd3.Text;
671 rsi.EyeAddName[3] = txtEyeAdd4Name.Text;
672 rsi.EyeAdd[3] = txtEyeAdd4.Text;
673 rsi.EyeAddName[4] = txtEyeAdd5Name.Text;
674 rsi.EyeAdd[4] = txtEyeAdd5.Text;
675 rsi.EyeAddName[5] = txtEyeAdd6Name.Text;
676 rsi.EyeAdd[5] = txtEyeAdd6.Text;
677
678 //口追加
679 rsi.MouthAddName[0] = txtMouthAdd1Name.Text;
680 rsi.MouthAdd[0] = txtMouthAdd1.Text;
681 rsi.MouthAddName[1] = txtMouthAdd2Name.Text;
682 rsi.MouthAdd[1] = txtMouthAdd2.Text;
683 rsi.MouthAddName[2] = txtMouthAdd3Name.Text;
684 rsi.MouthAdd[2] = txtMouthAdd3.Text;
685 rsi.MouthAddName[3] = txtMouthAdd4Name.Text;
686 rsi.MouthAdd[3] = txtMouthAdd4.Text;
687 rsi.MouthAddName[4] = txtMouthAdd5Name.Text;
688 rsi.MouthAdd[4] = txtMouthAdd5.Text;
689 rsi.MouthAddName[5] = txtMouthAdd6Name.Text;
690 rsi.MouthAdd[5] = txtMouthAdd6.Text;
691
692 }
693
694 /// <summary>
695 /// 選択ボタン共通処理
696 /// </summary>
697 private bool btnSelectGraphic(string _title, Button _btn, TextBox _fname)
698 {
699 //RSIファイル選択にゃ
700 if (openFileDialogGraphic.ShowDialog() != DialogResult.OK)
701 {
702 //選択されんかったにゃ (T_T)
703 return false;
704 }
705
706 flgNotSave = true; //変更後保存していない:true
707
708 if (txtRsiFileName.Text.Length == 0)
709 {
710 _fname.Text = openFileDialogGraphic.FileName;
711 }
712 else
713 {
714 //選択された画像から相対パスを取得するにゃ
715 int i;
716 String fname = openFileDialogGraphic.FileName;
717 for (i = 0; i < fname.Length; i++)
718 {
719 if (txtRsiFileName.Text.Length < i) break;
720 if (fname.Substring(i, 1) != txtRsiFileName.Text.Substring(i, 1))
721 {
722 break;
723 }
724 }
725 _fname.Text = fname.Substring(i);
726 }
727
728 return true;
729 }
730
731 /// <summary>
732 /// コントロールの使用可否設定
733 /// </summary>
734 private void SetControlsEnable(bool _enabled)
735 {
736 btnSaveAs.Enabled = _enabled;
737 btnSave.Enabled = _enabled;
738 tabGroup.Enabled = _enabled;
739 }
740
741 /// <summary>
742 /// バージン情報
743 /// </summary>
744 private void btnVirsion_Click(object sender, EventArgs e)
745 {
746 MessageBox.Show(String.Concat(strVersion, " "), __(" バージョン情報"), MessageBoxButtons.OK, MessageBoxIcon.Information);
747 }
748
749 #region "選択ボタンをクリックしたときの処理"
750 /// <summary>
751 /// ベース画像選択ボタン
752 /// </summary>
753 private void btnSelectBase_Click(object sender, EventArgs e)
754 {
755 if (btnSelectGraphic(__("ベース画像"), btnSelectBase, txtBase))
756 {
757 //現在何も処理なし
758 }
759 }
760
761 //-----------------------------------------------------------------
762 /// 目選択ボタン
763 //-----------------------------------------------------------------
764 private void btnSelectEyeNormal_Click(object sender, EventArgs e)
765 {
766 if (btnSelectGraphic(__("目通常"), btnSelectEyeNormal, txtEyeNormal))
767 {
768 //現在何も処理なし
769 }
770 }
771
772 /// <summary>
773 /// 薄目選択ボタン
774 /// </summary>
775 private void btnSelectEyeThin_Click(object sender, EventArgs e)
776 {
777 if (btnSelectGraphic(__("薄目"), btnSelectEyeThin, txtEyeThin))
778 {
779 //現在何も処理なし
780 }
781 }
782
783 /// <summary>
784 /// 閉目選択ボタン
785 /// </summary>
786 private void btnSelectEyeClose_Click(object sender, EventArgs e)
787 {
788 if (btnSelectGraphic(__("閉目"), btnSelectEyeClose, txtEyeClose))
789 {
790 //現在何も処理なし
791 }
792 }
793
794 //-----------------------------------------------------------------
795 /// 口選択ボタン
796 //-----------------------------------------------------------------
797 private void btnSelectMouthA_Click(object sender, EventArgs e)
798 {
799 if (btnSelectGraphic(__("口あ"), btnSelectMouthA, txtMouthA))
800 {
801 //現在何も処理なし
802 }
803 }
804
805 private void btnSelectMouthI_Click(object sender, EventArgs e)
806 {
807 if (btnSelectGraphic(__("口い"), btnSelectMouthI, txtMouthI))
808 {
809 //現在何も処理なし
810 }
811 }
812
813 private void btnSelectMouthU_Click(object sender, EventArgs e)
814 {
815 if (btnSelectGraphic(__("口う"), btnSelectMouthU, txtMouthU))
816 {
817 //現在何も処理なし
818 }
819 }
820
821 private void btnSelectMouthE_Click(object sender, EventArgs e)
822 {
823 if (btnSelectGraphic(__("口え"), btnSelectMouthE, txtMouthE))
824 {
825 //現在何も処理なし
826 }
827 }
828
829 private void btnSelectMouthO_Click(object sender, EventArgs e)
830 {
831 if (btnSelectGraphic(__("口お"), btnSelectMouthO, txtMouthO))
832 {
833 //現在何も処理なし
834 }
835 }
836
837 private void btnSelectMouthN_Click(object sender, EventArgs e)
838 {
839 if (btnSelectGraphic(__("口ん"), btnSelectMouthN, txtMouthN))
840 {
841 //現在何も処理なし
842 }
843 }
844
845 private void btnSelectMouthAa_Click(object sender, EventArgs e)
846 {
847 if (btnSelectGraphic(__("口ああ"), btnSelectMouthAa, txtMouthAa))
848 {
849 //現在何も処理なし
850 }
851 }
852
853 private void btnSelectMouthXo_Click(object sender, EventArgs e)
854 {
855 if (btnSelectGraphic(__("口ぉ"), btnSelectMouthXo, txtMouthXo))
856 {
857 //現在何も処理なし
858 }
859 }
860
861 //-----------------------------------------------------------------
862 /// 目手動選択ボタン
863 //-----------------------------------------------------------------
864 private void btnSelectEyeAdd1_Click(object sender, EventArgs e)
865 {
866 if (btnSelectGraphic(String.Concat(__("目手動"), "1"), btnSelectEyeAdd1, txtEyeAdd1))
867 {
868 //現在何も処理なし
869 }
870 }
871
872 private void btnSelectEyeAdd2_Click(object sender, EventArgs e)
873 {
874 if (btnSelectGraphic(String.Concat(__("目手動"),"2"), btnSelectEyeAdd2, txtEyeAdd2))
875 {
876 //現在何も処理なし
877 }
878 }
879
880 private void btnSelectEyeAdd3_Click(object sender, EventArgs e)
881 {
882 if (btnSelectGraphic(String.Concat(__("目手動"),"3"), btnSelectEyeAdd3, txtEyeAdd3))
883 {
884 //現在何も処理なし
885 }
886 }
887
888 private void btnSelectEyeAdd4_Click(object sender, EventArgs e)
889 {
890 if (btnSelectGraphic(String.Concat(__("目手動"),"4"), btnSelectEyeAdd4, txtEyeAdd4))
891 {
892 //現在何も処理なし
893 }
894 }
895
896 private void btnSelectEyeAdd5_Click(object sender, EventArgs e)
897 {
898 if (btnSelectGraphic(String.Concat(__("目手動"),"5"), btnSelectEyeAdd5, txtEyeAdd5))
899 {
900 //現在何も処理なし
901 }
902 }
903
904 private void btnSelectEyeAdd6_Click(object sender, EventArgs e)
905 {
906 if (btnSelectGraphic(String.Concat(__("目手動"),"6"), btnSelectEyeAdd6, txtEyeAdd6))
907 {
908 //現在何も処理なし
909 }
910 }
911
912 private void btnSelectMouthAdd1_Click(object sender, EventArgs e)
913 {
914 if (btnSelectGraphic(String.Concat(__("口手動"),"1"), btnSelectMouthAdd1, txtMouthAdd1))
915 {
916 //現在何も処理なし
917 }
918 }
919
920 private void btnSelectMouthAdd2_Click(object sender, EventArgs e)
921 {
922 if (btnSelectGraphic(String.Concat(__("口手動"),"2"), btnSelectMouthAdd2, txtMouthAdd2))
923 {
924 //現在何も処理なし
925 }
926 }
927
928 private void btnSelectMouthAdd3_Click(object sender, EventArgs e)
929 {
930 if (btnSelectGraphic(String.Concat(__("口手動"),"3"), btnSelectMouthAdd3, txtMouthAdd3))
931 {
932 //現在何も処理なし
933 }
934 }
935
936 private void btnSelectMouthAdd4_Click(object sender, EventArgs e)
937 {
938 if (btnSelectGraphic(String.Concat(__("口手動"),"4"), btnSelectMouthAdd4, txtMouthAdd4))
939 {
940 //現在何も処理なし
941 }
942 }
943
944 private void btnSelectMouthAdd5_Click(object sender, EventArgs e)
945 {
946 if (btnSelectGraphic(String.Concat(__("口手動"),"5"), btnSelectMouthAdd5, txtMouthAdd5))
947 {
948 //現在何も処理なし
949 }
950 }
951
952 private void btnSelectMouthAdd6_Click(object sender, EventArgs e)
953 {
954 if (btnSelectGraphic(String.Concat(__("口手動"),"6"), btnSelectMouthAdd6, txtMouthAdd6))
955 {
956 //現在何も処理なし
957 }
958 }
959 #endregion
960
961 #region "テキストボックスを変更したときの処理"
962 private void txtBoxCommon_TextChanged(object sender, EventArgs e)
963 {
964 flgNotSave = true; //変更後保存していない:true
965 TextBox txtBox = (TextBox)sender;
966 if (txtBox.ReadOnly == true)
967 {
968 txtBox.BackColor = SystemColors.Control;
969 }
970 else
971 {
972 txtBox.BackColor = SystemColors.Window;
973 }
974 }
975
976 #endregion
977
978 #region "画像削除ボタンをクリックしたときの処理"
979 private void btnDelEyeAdd1_Click(object sender, EventArgs e)
980 {
981 txtEyeAdd1.Text = "";
982 }
983
984 private void btnDelEyeAdd2_Click(object sender, EventArgs e)
985 {
986 txtEyeAdd2.Text = "";
987 }
988
989 private void btnDelEyeAdd3_Click(object sender, EventArgs e)
990 {
991 txtEyeAdd3.Text = "";
992 }
993
994 private void btnDelEyeAdd4_Click(object sender, EventArgs e)
995 {
996 txtEyeAdd4.Text = "";
997 }
998
999 private void btnDelEyeAdd5_Click(object sender, EventArgs e)
1000 {
1001 txtEyeAdd5.Text = "";
1002 }
1003
1004 private void btnDelEyeAdd6_Click(object sender, EventArgs e)
1005 {
1006 txtEyeAdd6.Text = "";
1007 }
1008
1009 private void btnDelMouthAdd1_Click(object sender, EventArgs e)
1010 {
1011 txtMouthAdd1.Text = "";
1012 }
1013
1014 private void btnDelMouthAdd2_Click(object sender, EventArgs e)
1015 {
1016 txtMouthAdd2.Text = "";
1017 }
1018
1019 private void btnDelMouthAdd3_Click(object sender, EventArgs e)
1020 {
1021 txtMouthAdd3.Text = "";
1022 }
1023
1024 private void btnDelMouthAdd4_Click(object sender, EventArgs e)
1025 {
1026 txtMouthAdd4.Text = "";
1027 }
1028
1029 private void btnDelMouthAdd5_Click(object sender, EventArgs e)
1030 {
1031 txtMouthAdd5.Text = "";
1032 }
1033
1034 private void btnDelMouthAdd6_Click(object sender, EventArgs e)
1035 {
1036 txtMouthAdd6.Text = "";
1037 }
1038 #endregion
1039
1040 private void tabGroup_Click(object sender, EventArgs e)
1041 {
1042 switch (tabGroup.SelectedIndex)
1043 {
1044 case 0:
1045 //メッセージ表示領域
1046 txtMessage.Text = __("絵師-キャラクターの名前を入力し、ベース画像を選択後、画像サイズを入力してください。");
1047 break;
1048 case 1:
1049 //メッセージ表示領域
1050 txtMessage.Text = __("目の画像を選択してください。");
1051 break;
1052 case 2:
1053 //メッセージ表示領域
1054 txtMessage.Text = __("口の画像を選択してください。");
1055 break;
1056 case 3:
1057 case 4:
1058 //メッセージ表示領域
1059 txtMessage.Text = __("形状の名称を入力し画像を選択してください。(最大6個)");
1060 break;
1061 }
1062 }
1063
1064 private void cboLangage_SelectedIndexChanged(object sender, EventArgs e)
1065 {
1066 //config内容を変更。終了時にconfigファイルに書き込み
1067 Managers.Configuration config = Managers.ApplicationManager.GetInstance().Configuration;
1068 config.Language = cboLangage.SelectedItem.ToString();
1069
1070 //poファイルを読み込み、画面のラベルを再編集
1071 lang.SelectIndex = cboLangage.SelectedIndex;
1072 lang.Load();
1073 ApplyLanguage();
1074 }
1075 private void loadPofile()
1076 {
1077 }
1078 }
1079 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26