public static void ShowModal( IConsoleService console, string filename, string actNum) { using (var form = new BroserForm(console, filename, actNum)) { form.ShowDialog(); } }
private void InitialComponentsEvents() { editActButton.Click += (s, e) => { throw new ApplicationException(); Guid index = actGridControl1.GetMarked(); var act = _fileInfos.FirstOrDefault(f => f.Id == index); //ActEditForm.ShowModal(_container, act); int changed = _context.SaveChanges(); _console.AddEvent($"Внесено {changed} изменений"); if (changed != 0) { LoadDataToGrid(); } }; columnsListEditButton.Click += (s, e) => { try { var columns = new List <ColumnInfo>(); actGridControl1.LoadData(columns); using (var form = new ChosingColumnsForm(_console)) { if (form.LoadData(columns) && form.ShowDialog() == DialogResult.OK && actGridControl1.UpdateData(columns)) { } } var json = JsonConvert.SerializeObject(columns, Formatting.Indented); File.WriteAllText(_fileName, json); } catch (Exception ex) { _console?.AddException(ex); } }; openOriginalFileButton.Click += (s, e) => { try { Guid index = actGridControl1.GetMarked(); var pfi = _fileInfos.FirstOrDefault(f => f.Id == index); string directory = _settings[ArgsKeyList.BackUpPath]; var fileName = Directory.GetFiles( _settings[ArgsKeyList.BackUpPath] , $"{pfi.Id}.*") .FirstOrDefault(f => !f.Contains(".json")); if (fileName == null) { return; } BroserForm.ShowModal(_console, fileName, pfi.Id.ToString()); } catch (Exception ex) { _console?.AddException(ex); } }; updateDataButton.Click += (s, e) => Task.Factory.StartNew( () => Invoke((Action)LoadDataToGrid)); excelExportButton.Click += (s, e) => ExportToExcel(); Load += (s, e) => Task.Factory.StartNew( () => Invoke((Action)LoadDataToGrid)); }