private void btReloadFrom_Click(object sender, EventArgs e) { try { DbFolder fld = Common.Db.GetFolder(Common.DbNameSystemFolder); string path = fld.CreateRecordPath((string)cbKnownConditions.SelectedItem); string tmp = path + ".ssc"; FileStream fs = DataBase.OpenFile(ref tmp, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); Cond.Load(br); br.Close(); if (chbShowSourceCode.Checked == false) { scSimpleEditor.Setup(Cond.SourceCode, this); } else { tbSourceCode.Text = Cond.SourceCode; } cbKnownConditions.SelectedIndex = -1; } catch (Exception ex) { Common.Log(ex); } }
private void btDeleteSavedCond_Click(object sender, EventArgs e) { try { DialogResult dr = MessageBox.Show(this, Common.MLS.Get(MLSConst, "Удалить ранее записанную программу измерений:") + (string)cbKnownConditions.SelectedItem, Common.MLS.Get(MLSConst, "Удаление..."), MessageBoxButtons.YesNo, MessageBoxIcon.Hand); if (dr != DialogResult.Yes) { return; } DbFolder fld = Common.Db.GetFolder(Common.DbNameSystemFolder); string path = fld.CreateRecordPath((string)cbKnownConditions.SelectedItem); File.Delete(path + ".ssc"); LoadList(); } catch (Exception ex) { Common.Log(ex); } }
private void btSaveAs_Click(object sender, EventArgs e) { try { string name = util.StringDialog.GetString(this, Common.MLS.Get(MLSConst, "Запиль условий"), Common.MLS.Get(MLSConst, "Введите имя под которым надо сохранить программу измерений"), "", true); if (name == null) { return; } DbFolder fld = Common.Db.GetFolder(Common.DbNameSystemFolder); string path = fld.CreateRecordPath(name); string tmp = path + ".ssc"; FileStream fs = DataBase.OpenFile(ref tmp, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); Cond.Save(bw); bw.Flush(); bw.Close(); LoadList(); } catch (Exception ex) { Common.Log(ex); } }