public MainForm() { InitializeComponent(); setVersion(); SetDATList(); //SetCharNames(); // SetDatList → DAT リスト変更イベントで勝手に呼ばれる TranslateInitialUI(true); //SetDATList(); //dgvChars.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; string[] cmds = Environment.GetCommandLineArgs(); if (cmds.Length > 1 && System.Text.RegularExpressions.Regex.IsMatch(cmds[1], @"\.[lr]st$", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { OpenStateFile(cmds[1]); } else { string curList = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"current.lst"); #if !DEBUG try #endif { if (File.Exists(curList)) { var tbListPathText = LoadIniString("Text", "tbListPath"); OpenStateFile(curList, tbListPathText + ".lst"); tbListPath.Text = tbListPathText; tbListPath.Select(tbListPath.Text.Length, 0); tbListPath.ScrollToCaret(); string bcmName = LoadIniString("Text", "BCMName"); if (bcmName != "") { OpenFile(Path.Combine(tbSavePath.Text, bcmName)); } setEgvCharsSlotColor(); setEgvCharsNameColor(); setEgvCharsTextsColor(); } } #if !DEBUG catch { try { File.Delete(curList); } catch { } } #endif } undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); // 終了時のイベントハンドラを登録 //ApplicationExitイベントハンドラを追加 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); // 異常終了時は単にタイマーを止める Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // タイマー開始 TimerForSave = new FormsTimerTest(); TimerForSave.Run(); }
private void btnOpenBCM_Click(object sender, EventArgs e) { var pt = GetOwnOFolderrExistingParent(LoadIniString("InitialDirectory", "BCM")); if (pt != "") openFileDialogBCM.InitialDirectory = pt; openFileDialogBCM.FileName = Path.GetFileName(saveFileDialogBCM.FileName); if (ConformScrap() && openFileDialogBCM.ShowDialog() == DialogResult.OK) { OpenFile(openFileDialogBCM.FileName); btnSaveState.Enabled = true; //btnCmpSave.Enabled = false; //btnCmpSave.Enabled = true; //btnCmpSave.Text = Program.dicLanguage["ExtractFiles"]; SaveIniString("InitialDirectory", "BCM", Path.GetDirectoryName(openFileDialogBCM.FileName)); undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); } }
private void btnOpenState_Click(object sender, EventArgs e) { try { var pt = GetOwnOFolderrExistingParent(LoadIniString("InitialDirectory", "LST")); if (pt != "") openFileDialogState.InitialDirectory = pt; openFileDialogState.FileName = Path.GetFileName(saveFileDialogState.FileName); if (ConformScrap() && openFileDialogState.ShowDialog() == DialogResult.OK) { SaveIniString("InitialDirectory", "LST", Path.GetDirectoryName(openFileDialogState.FileName)); //dgvChars.Columns[0].HeaderCell.SortGlyphDirection = SortOrder.None; //dgvChars.Columns[1].HeaderCell.SortGlyphDirection = SortOrder.None; for (int i = 0; i < dgvChars.Columns.Count; i++) { dgvChars.Columns[i].HeaderCell.SortGlyphDirection = SortOrder.None; } if (openFileDialogState.FilterIndex == 1) { string orgpath = openFileDialogState.FileName; string ext = Path.GetExtension(orgpath).ToLower(); //newDlc = true; // OpenStateFile で行われるけど tbListPath.Text 編集イベントの前にかえておかないといけない OpenStateFile(openFileDialogState.FileName); } else { var bf = new BinaryFormatter(); using (var fs = new FileStream(openFileDialogState.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { dlcData = (DLCData)bf.Deserialize(fs); } newDlc = true; tbListPath.Text = "";// newDLC より後で。 ClearMainUI(); MakeColumnsFromDLCData(dlcData); tbSavePath.Text = dlcData.SavePath; btnSave.Text = Program.dicLanguage["SaveDLC"]; ; btnCmpSave.Enabled = btnSave.Enabled = true; btnSaveState.Enabled = true; btnCharsAdd.Enabled = true; //clmCos.ReadOnly = false; clmInner.ReadOnly = false; tbBCMVer.Text = dlcData.BcmVer.ToString(); for (int i = 0; i < dlcData.Chars.Count; i++) { dgvChars.Rows.Add(); dgvChars.Rows[i].Cells[0].Value = GetCharNamesJpn(dlcData.Chars[i].ID);// Program.CharNamesJpn[dlcData.Chars[i].ID]; dgvChars.Rows[i].Cells[1].Value = dlcData.Chars[i].CostumeSlot.ToString(); dgvChars.Rows[i].Cells[2].Value = dlcData.Chars[i].AddTexsCount.ToString(); dlcData.Chars[i].Comment = "";// GetComment()"; //dgvChars.Rows[i].Cells[3].Value = dlcData.Chars[i].Comment; showComment(i); } if (dlcData.Chars.Count > 0) { dgvChars.Rows[0].Selected = true; } } saveFileDialogState.FileName = openFileDialogState.FileName; setEgvCharsSlotColor(); setEgvCharsNameColor(); setEgvCharsTextsColor(); if (dgvChars.Rows.Count <= 0) { btnCharsDelete.Enabled = false; } undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnNewDLC_Click(object sender, EventArgs e) { var pt = LoadIniString("InitialDirectory", "BCM"); if (pt != "") saveFileDialog.InitialDirectory = GetOwnOFolderrExistingParent(Path.GetDirectoryName(pt)); saveFileDialog.FileName = Path.GetFileName(openFileDialog.FileName); if (ConformScrap() && saveFileDialog.ShowDialog() == DialogResult.OK) { //MessageBox.Show("a"); System.Text.RegularExpressions.Regex regex_doa = new System.Text.RegularExpressions.Regex(@"^(.*\\([^\\]+))\\\2\.bcm$", System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (regex_doa.IsMatch(saveFileDialog.FileName)) { tbSavePath.Text = regex_doa.Replace(saveFileDialog.FileName, "$1"); SaveIniString("InitialDirectory", "BCM", Path.GetDirectoryName(saveFileDialog.FileName)); } else { tbSavePath.Text = saveFileDialog.FileName; SaveIniString("InitialDirectory", "BCM", saveFileDialog.FileName); } newDlc = true; ClearMainUI(); //tbSavePath.Text = saveFileDialog.FileName; dlcData = new DLCData(); //btnSave.Text = Program.dicLanguage["SaveDLC"]; setBtnSave(); btnCmpSave.Enabled = btnSave.Enabled = true; btnSaveState.Enabled = true; btnCharsAdd.Enabled = true; //clmCos.ReadOnly = false; clmInner.ReadOnly = false; dlcData.BcmVer = 9; tbBCMVer.Text = "9"; //dlcData.SavePath = saveFileDialog.FileName; cbSaveListInDLC.Enabled = true; cbSaveListInDLC.Checked = true; undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); } }