public FileReadPlaceholder(string FilePath) { InitializeComponent(); TopMost = true; Loader = new Thread(new ThreadStart(() => { using (var F = File.OpenRead(FilePath)) { using (ExcelFile = new ExcelPackage(F)) { UpdateTeams(); } } })); Loader.IsBackground = true; Loader.Start(); onTeamsLoaded += () => { if (Teams.Count != 0) { //TimerSettings.ResetCompetition(); TimerSettings.Competition = new Competition(Teams); ShowHideForm(this, false); Invoke((MethodInvoker) delegate() { SetSettings MF = new SetSettings(); MF.Closed += (s, a) => Close(); MF.Show(); }); } }; { }; onTeamsFailed += () => { LoadingStatusLabel.SetPropertyThreadSafe(() => LoadingStatusLabel.Text, "Ошибка загрузки!"); Invoke((MethodInvoker) delegate() { Close(); }); }; }
private async Task SaveListAsync() { //REWRITE if (ListOfTeams.Items.Count == 0) { MessageBox.Show("Нет данных для сохранения"); return; } Stream Stream; SaveFileDialog SaveFile = new SaveFileDialog { Title = "Сохранить список команд", InitialDirectory = @"C:\", Filter = "Таблица Excel (*.xlsx)|*.xlsx", FilterIndex = 0, RestoreDirectory = true }; if (SaveFile.ShowDialog() == DialogResult.OK) { if ((Stream = SaveFile.OpenFile()) != null) { List <Team> TeamsList = new List <Team>(); foreach (Team t in ListOfTeams.Items) { TeamsList.Add(t); } ListOfTeams TeamsR = new ListOfTeams(); byte[] b = TeamsR.Generate(TeamsList); await Stream.WriteAsync(b); Stream.Close(); if (TeamsR != null) { Hide(); new Competition(TeamsList); SetSettings Settings = new SetSettings(); Settings.Closed += (s, a) => Close(); Settings.Show(); } return; } } return; }
private void JustUse_Click(object sender, EventArgs e) { List <Team> TeamsList = new List <Team>(); foreach (Team t in ListOfTeams.Items) { TeamsList.Add(t); } if (TeamsList.Count == 0) { MessageBox.Show("Лист команд пустой!"); } Hide(); new Competition(TeamsList); SetSettings Settings = new SetSettings(); Settings.Closed += (s, a) => Close(); Settings.Show(); }