public void noSuchButtonStringTest() { form = new MessageDialog(); form.Show(); ButtonTester b = new ButtonTester("openBtn"); b.Click(); }
private void errorMessage(string text) { MessageDialog form = new MessageDialog(); form.errorTxt.Text = text; form.StartPosition = FormStartPosition.Manual; form.Location = new Point(this.Location.X + (this.Width - form.Width) / 2, this.Location.Y + (this.Height - form.Height) / 2); form.Show(this); }
public void nullTypeTest() { form = new MessageDialog(); Assert.AreEqual(form.Text, "Сохранение шаблона"); }
void simpleMessage(string text, string filename) { MessageDialog form = new MessageDialog(filename); form.errorTxt.Text = text; form.Text = "Успех"; form.StartPosition = FormStartPosition.Manual; form.Location = new Point(this.Location.X + (this.Width - form.Width) / 2, this.Location.Y + (this.Height - form.Height) / 2); form.Show(this); }
// End Drag and Drop functions private void button1_Click(object sender, EventArgs e) { //сохранение шаблона //StreamWriter sr = new StreamWriter(@"test.txt"); if (nodes.Count == 0) { Message mess = new Message(this, "Ошибка", "Добавьте хотя бы одно поле", MessageBoxIcon.Warning); mess.switchMessage(); return; } MessageDialog md = new MessageDialog(0); md.StartPosition = FormStartPosition.Manual; md.Location = new Point(this.Location.X + (this.Width - md.Width) / 2, this.Location.Y + (this.Height - md.Height) / 2); md.ShowDialog(); string nameT = md.NameT; string result_str = ""; if(md.btn_continuy & !md.cancel & md.closing ){ if (nameT.Trim() == "")// исправлен баг с некорректным именем { Message mess = new Message(this, "Oшибка", "Введите корректное имя шаблона!", MessageBoxIcon.Warning); mess.switchMessage(); button1_Click(sender, e); } foreach (FieldNode a in nodes) { result_str += a.type.ToString() + ";"; if (a.type == 0) { result_str += a.name + ";"; if (a.pathToFile != "") { result_str += a.pathToFile.ToString() + ";"; } else { result_str += standartList.SelectedItem.ToString() + ";"; } } if (a.type == 1) { result_str += a.name + ";"; result_str += a.from.ToString() + ";"; result_str += a.to.ToString() + ";"; } if(a.type == 2) { result_str += a.name + ";"; result_str += a.dateFormat.ToString() + ";"; result_str += a.dfrom.ToString() + ";"; result_str += a.dto.ToString() + ";"; } if(a.type == 3) { result_str += a.name.ToString() + ";"; result_str += long.Parse(this.seqFromTxt.Text.Trim()) + ";"; result_str += long.Parse(this.seqStepTxt.Text.Trim()) + ";"; } if (a.type == 4) { result_str += a.name + ";"; if (a.pathToFile != "") result_str += a.pathToFile.ToString() + ";"; else result_str += standartList.SelectedValue.ToString() + ";"; } result_str += "_"; } using (var db = new MyDBContext()) { var find = db.Templates.FirstOrDefault(x => x.Name == nameT); if (find != null) { Message mess = new Message(this, "Oшибка!", "Такое имя шаблона уже существует!", MessageBoxIcon.Warning); mess.switchMessage(); button1_Click(sender, e); return; } db.Templates.Add(new Template { Name = nameT, Tmp = result_str }); db.SaveChanges(); } Message mes1 = new Message(this, "Успех", "Шаблон сохранен", MessageBoxIcon.Warning); mes1.switchMessage(); } }