private async void LoadTabs() { try { var answer_L_Clients = await Client.Remote.Communication.GetClients(); var answer_L_Employees = await Client.Remote.Communication.GetEmployees(); var answer_L_Products = await Client.Remote.Communication.GetProducts(); if (answer_L_Clients != null && answer_L_Clients.Count > 0) { this.Hide(); //Récupérer le contenu des trois GridView aprés authentification var bindingListClient = new BindingList <Mapping.Client>(answer_L_Clients); var sourceClientBinding = new BindingSource(bindingListClient, null); var bindingListEmployee = new BindingList <Mapping.Employee>(answer_L_Employees); var sourceEmployeeBinding = new BindingSource(bindingListEmployee, null); var bindingListProduct = new BindingList <Mapping.Product>(answer_L_Products); var sourceProductBinding = new BindingSource(bindingListProduct, null); var clientForm = new ClientForm(sourceClientBinding, sourceProductBinding, sourceEmployeeBinding); clientForm.Show(); clientForm.GetDataGridViewClient().DataSource = sourceClientBinding; clientForm.GetDataGridViewEmployee().DataSource = sourceEmployeeBinding; clientForm.GetDataGridViewProduct().DataSource = sourceProductBinding; } else { MessageBox.Show("Remote access Error: The API returned an empty list", "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Couldn't communicate with the API: " + ex.Message, "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLaunch_Click(object sender, EventArgs e) { Process[] processess = Process.GetProcessesByName("LEGORacers"); if (processess.Count() > 0) { MessageBox.Show( "It seems that there is already a LEGO Racers process running on your system. In order to make everything work correctly, these processess will be terminated after closing this message.", "Attention"); foreach (Process process in processess) { process.Kill(); } } if (String.IsNullOrWhiteSpace(Properties.Settings.Default.GameClientDirectory)) { MessageBox.Show("Game client directory was not set. Please restart the client.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } if (File.Exists(Path.Combine(Properties.Settings.Default.GameClientDirectory, "LEGORacers.exe"))) { ProcessStartInfo processInfo = new ProcessStartInfo() { WorkingDirectory = Properties.Settings.Default.GameClientDirectory, FileName = "LEGORacers.exe" }; if (Properties.Settings.Default.WindowMode) { processInfo.Arguments = "-window"; } if (Properties.Settings.Default.SkipIntroVideo) { processInfo.Arguments += " -novideo"; } processInfo.Arguments += " " + Properties.Settings.Default.Arguments; try { Process p = Process.Start(processInfo); ClientForm c = new ClientForm(p, this); c.FormClosed += (s, args) => Close(); c.Show(); Hide(); } catch (Exception exc) { ErrorHandler.ShowDialog("Cannot launch the game", "The game could not be closed or launched.", exc); } } else { MessageBox.Show( "The file 'LEGORacers.exe' was not found in the directory '" + Properties.Settings.Default.GameClientDirectory + "'. Please reinstall the game.", "Game file not found", MessageBoxButtons.OK, MessageBoxIcon.Error); } }