////////////////////////////////////////////////// меню "Поиск" private void ShowSearchForm(SearchFormArgs args) { IFormBuilder builder = new SearchFormBuilder(args, this); Form searchForm = FormDirector.CreateForm(builder); searchForm.Show(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(FormDirector.CreateForm(new MainFormBuilder())); }
private void toolStripButtonEditRooms_Click(object sender, EventArgs e) { MakeSnapshot(this, new EventArgs()); foreach (DataGridViewRow row in dataGridView1.SelectedRows) { IFormBuilder builder = new RoomEditFormBuilder(row.DataBoundItem as IFlat); Form roomEditor = FormDirector.CreateForm(builder); roomEditor.Show(); } }
/// <summary> /// Добавление объекта в список квартир /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonAdd_Click(object sender, EventArgs e) { // try/catch обрабатывает случай, если площадь не введена // ошибка возникает в MyFlatArgs try { // Паттерн Builder FlatBuilder fb; if (checkBoxRundomRooms.Checked) { fb = new RandomRoomsFlatBuilder(MyFlatArgs); } else { fb = new SimpleFlatBuilder(MyFlatArgs); } var flat = FlatDirector.CreateFlat(fb); // для валидации var results = new List <ValidationResult> { }; var context = new ValidationContext(flat); // валидация if (!Validator.TryValidateObject(flat, context, results, true)) { OnInvalidValidation(results); } else { // если валидация успешна // сначала сохраняем состояние MakeSnapshot(this, new EventArgs()); PrimarySource.Add(flat); maskedTextBoxArea.BackColor = maskedTextBoxOwner.BackColor = System.Drawing.SystemColors.Window; // открываем редактор комнат IFormBuilder builder = new RoomEditFormBuilder(flat); Form roomEditor = FormDirector.CreateForm(builder); roomEditor.Show(); } } catch (System.FormatException ex) { // если в поле ввода площади ничего не введено MessageBox.Show(ex.Message); maskedTextBoxArea.BackColor = System.Drawing.Color.Salmon; } }
////////////////////////////////////////////////////////////////////// private void buttonAdressesMenu_Click(object sender, EventArgs e) { Form searchForm = FormDirector.CreateForm(new AdressEditFormBuilder()); searchForm.Show(); }