// NUMBERS -------------------------------------------------->> private void ButtonClick(object sender, EventArgs e) { // Clears '0' if there is any on the Text Screen if (TextBoxResult.Text == "0" || isOperationPerformed) { TextBoxResult.Clear(); } isOperationPerformed = false; // Gets the value of each button on to the text Screen Button button = (Button)sender; // Take care to only have ONE decimal (".") in the Text Screen if (button.Text == ".") { if (!TextBoxResult.Text.Contains(".")) { TextBoxResult.Text = TextBoxResult.Text + button.Text; } } else { TextBoxResult.Text = TextBoxResult.Text + button.Text; } }
private async void ButtonAsync_Click(object sender, EventArgs e) { Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>(); progress.ProgressChanged += ReportProgress; var watch = System.Diagnostics.Stopwatch.StartNew(); if (cts != null) { cts.Dispose(); } cts = new CancellationTokenSource(); try { var results = await RunDownloadAsync(progress, cts.Token); PrintResults(results); } catch (OperationCanceledException) { TextBoxResult.AppendLine($"The async download was canceled."); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Application.DoEvents(); TextBoxResult.AppendLine($"Total execution time: {elapsedMs}"); }
private async void ButtonStart_Click(object sender, System.EventArgs e) { var progressReport = new Progress <int>(ReportCardProgress); TextBoxResult.Clear(); ProgressBarCards.Value = 0; PictureBoxLoding.Visible = true; // await Wait(); // var name = TextBoxInput.Text; var stopwatch = new Stopwatch(); try { // var greeting = await GetGreetings(name); // MessageBox.Show(greeting); var cards = await GetCards(1000); stopwatch.Start(); await ProcessCards(cards, progressReport); } catch (HttpRequestException ex) { MessageBox.Show(ex.Message); } MessageBox.Show($"Operation done in {stopwatch.ElapsedMilliseconds / 1000.0} seconds"); PictureBoxLoding.Visible = false; }
private void ButtonPoint_Click(object sender, EventArgs e) { if (TextBoxResult.Text.Contains(".") || CheckIfTextBoxResultIsString()) { return; } TextBoxResult.AppendText("."); }
private void PrintResults(List <WebSiteDataModel> results) { TextBoxResult.Text = ""; foreach (var item in results) { TextBoxResult.AppendLine($"{item.WebsiteUrl} downloaded: {item.WebsiteData.Length} characters long."); } }
private void ButtonCE_Click(object sender, EventArgs e) { if (!(TextBoxResult.Text.Contains(".")) && CheckIfTextBoxResultIsString()) { TextBoxResult.Text = "0"; return; } TextBoxResult.Clear(); TextBoxResult.Text = "0"; }
private void ButtonNormal_Click(object sender, System.EventArgs e) { var watch = System.Diagnostics.Stopwatch.StartNew(); RunDownloadSync(); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; TextBoxResult.AppendLine($"Total execution time: {elapsedMs}"); }
private async void ButtonParallel_Click(object sender, EventArgs e) { var watch = System.Diagnostics.Stopwatch.StartNew(); await RunDownloadParallelAsync(); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; TextBoxResult.AppendLine($"Total execution time: {elapsedMs}"); }
private void ButtonTask_Click(object sender, EventArgs e) { TextBoxResult.Clear(); var words = TextBoxSource.Text.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); var result = FormUtils.RunAlgorithm(words); foreach (var index in result) { TextBoxResult.AppendText(words[index] + '\n'); } }
//Events for delete button (C , CE , DEL) private void ButtonC_Click(object sender, EventArgs e) {//Clear the Text box if (!(TextBoxResult.Text.Contains(".")) && CheckIfTextBoxResultIsString()) { TextBoxResult.Text = "0"; return; } TextBoxResult.Clear(); LabelHistory.Text = ""; TextBoxResult.Text = "0"; }
private void HelperNumberButtonsToSetValue(string ValueToSet) { if (TextBoxResult.Text == "0") { TextBoxResult.Clear(); TextBoxResult.Text = ValueToSet; return; } if (!(TextBoxResult.Text.Contains(".")) && CheckIfTextBoxResultIsString()) { TextBoxResult.Text = "0"; return; } TextBoxResult.AppendText(ValueToSet); }
private async void ButtonParallel2_Click(object sender, EventArgs e) { Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>(); progress.ProgressChanged += ReportProgress; var watch = System.Diagnostics.Stopwatch.StartNew(); var results = await RunDownloadParallelAsync2(progress); PrintResults(results); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; TextBoxResult.AppendLine($"Total execution time: {elapsedMs}"); }
private void Button_Click(object sender, EventArgs e) { if ((TextBoxResult.Text == "0") || (IsOperationPerformed)) { TextBoxResult.Clear(); } IsOperationPerformed = false; Button button = (Button)sender; if (button.Text == ",") { if (!TextBoxResult.Text.Contains(",")) { TextBoxResult.Text = TextBoxResult.Text + button.Text; } } else { TextBoxResult.Text = TextBoxResult.Text + button.Text; } }
private void HelperActionsButtonsToSetValue(String ValueToSet) { if (LabelHistory.Text.Contains(ValueToSet)) { return; } if (TextBoxResult.Text.Remove(0, TextBoxResult.Text.Length - 1) == ".") { LabelHistory.Text = TextBoxResult.Text.Remove(TextBoxResult.Text.Length - 1) + ValueToSet; return; } if (!(TextBoxResult.Text.Contains(".")) && CheckIfTextBoxResultIsString()) { TextBoxResult.Clear(); TextBoxResult.Text = "0"; LabelHistory.Text = ""; return; } LabelHistory.Text = TextBoxResult.Text + ValueToSet; TextBoxResult.Text = "0"; }
private void ButtonGetDataTable_OnClick(object sender, RoutedEventArgs e) { var result = _connectionManager.GetDataTable(TextBoxCommand.Text); TextBoxResult.Clear(); foreach (var x in result.Columns) { TextBoxResult.Text += x + "\t\t"; } TextBoxResult.Text += "\n"; foreach (DataRow x in result.Rows) { foreach (var cell in x.ItemArray) { TextBoxResult.Text += cell + "\t"; } TextBoxResult.Text += "\n"; } }
private void button_1_Click(object sender, EventArgs e) { if ((TextBoxResult.Text == "0") || (isOperation)) { TextBoxResult.Clear(); } isOperation = false; Button button = (Button)sender; if (button.Text == ".") { if (!TextBoxResult.Text.Contains(".")) { TextBoxResult.Text = TextBoxResult.Text + button.Text; } } else { TextBoxResult.Text = TextBoxResult.Text + button.Text; } }
/// <summary> /// Очистка текстовых полей. /// </summary> private void ClearTextBoxes() { TextBoxSource.Clear(); TextBoxResult.Clear(); }
private void clearAllToolStripMenuItem_Click(object sender, EventArgs e) { InputTextBox.Clear(); TextBoxResult.Clear(); }
private void btnClear_Click(object sender, RoutedEventArgs e) { TextBoxResult.Clear(); }
private async Task ProcessCards(List <string> cards, IProgress <int> progress = null) { //int i = 1; using var semaphore = new SemaphoreSlim(500); var tasks = new List <Task <HttpResponseMessage> >(); var tasksResolved = 0; tasks = cards.Select(async card => { var json = JsonConvert.SerializeObject(card); var content = new StringContent(json, Encoding.UTF8, "application/json"); await semaphore.WaitAsync(); try { //TextBoxResult.Invoke(new Action(delegate //{ // if (i % 100 == 0) // TextBoxResult.AppendLine($"SemaphoreSlim : {i}"); // i++; //})); var internalTask = await httpClient.PostAsync($"{apiURL}/cards", content); if (progress != null) { tasksResolved++; var percentage = (double)tasksResolved / cards.Count; percentage *= 100; var percentageInt = (int)Math.Round(percentage, 0); progress.Report(percentageInt); } return(internalTask); } finally { semaphore.Release(); } }).ToList(); var responses = await Task.WhenAll(tasks); var rejectedCards = new List <string>(); foreach (var response in responses) { var content = await response.Content.ReadAsStringAsync(); var responseCard = JsonConvert.DeserializeObject <CardResponse>(content); if (!responseCard.Approved) { rejectedCards.Add(responseCard.Card); } } //int i = 1; //ProgressBarCards.Maximum = rejectedCards.Count; foreach (var card in rejectedCards) { TextBoxResult.AppendLine($"Card {card} was rejected"); Thread.Sleep(1); //Application.DoEvents(); //ProgressBarCards.Value = i; //i++; } //var tasks = new List<Task<HttpResponseMessage>>(); //await Task.Run(() => //{ // foreach (var card in cards) // { // var json = JsonConvert.SerializeObject(card); // var content = new StringContent(json, Encoding.UTF8, "application/json"); // var responseTask = httpClient.PostAsync($"{apiURL}/cards", content); // tasks.Add(responseTask); // } //}); //await Task.WhenAll(tasks); }
/// <summary> /// Очищает поля формы /// </summary> public void ClearForm() { //TextBoxArg1.Clear(); //TextBoxArg2.Clear(); TextBoxResult.Clear(); }
private void ReportWebsiteInfo(WebSiteDataModel data) { TextBoxResult.AppendLine($"{data.WebsiteUrl} downloaded: {data.WebsiteData.Length} characters long."); }