/// <summary> /// カレントフォルダに設定ファイルを保存する。 /// </summary> public static void SaveSetting(SettingData data) { string stCurrentDir = Environment.CurrentDirectory; string stSettingFilePath = Path.Combine(stCurrentDir, FILENAME_SETTING); try { SaveSerializeData(stSettingFilePath, data); } catch { } }
/////////////////////////////////////////////////////////////////////////////////////////////////////// /// その他 /////////////////////////////////////////////////////////////////////////////////////////////////////// //設定 private void cmdSet_Click(object sender, EventArgs e) { //処理順の保存 DELEGATE_ID[] tpIds = new DELEGATE_ID[grdDelegate.RowCount]; for (int i = 0; i < grdDelegate.RowCount; i++) { tpIds[i] = GetDelegateID(grdDelegate[CnColMain, i].Value.ToString()); } Condition[] tpConditions = new Condition[] { }; SettingData data = new SettingData(tpConditions, tpIds); SaveSetting(data); this.Dispose(); }
private void frmSetting_Load(object sender, EventArgs e) { CtpSettingData = LoadSetting(); if (CtpSettingData == null) //設定ファイルが無ければデフォルトを作成 { CreateDefaultSettingFile(); //デフォルト設定を作成 CtpSettingData = LoadSetting(); //設定をロード if (CtpSettingData == null) { this.Dispose(); } //それでも失敗したら終了 } InitComboBoxOfDelegate(); InitGridOfDelegate(); InitGridOfCondition(); }
/// <summary> /// 設定ファイルから処理順を読み込む /// </summary> public static void LoadDelegate() { SettingData setting = LoadSetting(); ConvertStr = NotReplace; if (setting == null) //設定ファイル読み込みに失敗したらデフォルト設定にする { ConvertStr += ReplaceIterator; ConvertStr += ReplaceNumber; ConvertStr += ReplaceSequence; ConvertStr += ReplaceCondition; ConvertStr += EvaluateExpression; return; } foreach (DELEGATE_ID id in setting.DelegateId) { if (id == DELEGATE_ID.ITERATOR) { ConvertStr += ReplaceIterator; } else if (id == DELEGATE_ID.SEQUENCE) { ConvertStr += ReplaceSequence; } else if (id == DELEGATE_ID.CONDITION) { ConvertStr += ReplaceCondition; } else if (id == DELEGATE_ID.NUMBER) { ConvertStr += ReplaceNumber; } else if (id == DELEGATE_ID.EXPRESSION) { ConvertStr += EvaluateExpression; } } }
/// <summary> /// デフォルト設定を作成して保存する /// </summary> public static void CreateDefaultSettingFile() { DELEGATE_ID[] tpIds = new DELEGATE_ID[] { DELEGATE_ID.ITERATOR, DELEGATE_ID.NUMBER, DELEGATE_ID.SEQUENCE, DELEGATE_ID.CONDITION, DELEGATE_ID.EXPRESSION }; Condition[] tpConditions = new Condition[] { new Condition("{3桁}", "{=('00000' + (num + 0)).slice(-3)}"), new Condition("{今日}", "{=var now = new Date();now.getYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate()}"), new Condition("{乱数}", "{=Math.floor(Math.random()*100)}") }; SettingData data = new SettingData(tpConditions, tpIds); SaveSetting(data); }