private void addBtn_Click(object sender, EventArgs e) { using (OpenFileDialog ofDlg = new OpenFileDialog() { Title = "Please select your structure file", DefaultExt = "lua" }) { ofDlg.ShowDialog(this); if (ofDlg.FileName.Length > 0) { string name = Path.GetFileNameWithoutExtension(ofDlg.FileName); StructureInfo newInfo = new StructureInfo() { Path = ofDlg.FileName, FileName = GuessName.Result(name, NameType.File), TableName = GuessName.Result(name, NameType.Table) }; structureBL.Add(newInfo); } } }
private async void saveFileBtn_Click(object sender, EventArgs e) { DataCore.Core dCore = new DataCore.Core(); if (RDBControls.GridRows > 0) { string savePath = OPT.GetString("save.directory"); if (string.IsNullOrEmpty(savePath)) { string structFileName = structFileName = string.Format(@"{0}.{1}", StructureManager.FileName(RDBControls.StructureListValue), rCore.Extension); string fileName = OPT.GetBool("save.hashed") ? dCore.EncodeName(structFileName) : structFileName; using (SaveFileDialog sfDlg = new SaveFileDialog() { Filter = "All files (*.*)|*.*|RDB files (*.rdb)|*.rdb|REF files (*.ref)|*.ref", Title = "Define the name of your rdb", FileName = fileName }) { if (sfDlg.ShowDialog(this) == DialogResult.OK) { if (!string.IsNullOrEmpty(sfDlg.FileName)) { savePath = sfDlg.FileName; } } } } else { savePath += GuessName.Result(RDBControls.StructureListValue, NameType.File); } if (!string.IsNullOrEmpty(savePath)) { await Task.Run(() => { rdbCores[tabIdx].WriteRDB(savePath); }); } } }