private void BtnClear_Click(object sender, EventArgs e) { DGVUpload.Rows.Clear(); DGVUpload.Refresh(); DGVUpload.Columns.Clear(); DGVUpload.Controls.Remove(chek); }
private void CaptureScreen() { Graphics myGraphics = DGVUpload.CreateGraphics(); Size s = DGVUpload.Size; memoryImage = new Bitmap(s.Width, s.Height, myGraphics); Graphics memoryGraphics = Graphics.FromImage(memoryImage); memoryGraphics.CopyFromScreen(DGVUpload.Location.X, DGVUpload.Location.Y, 0, 0, s); }
//List<int[]> results = new List<int[]>(); //List<Task<int[]>> T = new List<Task<int[]>>(); #region Main Events private async void btnPaste_Click(object sender, EventArgs e) { DGVUpload.Rows.Clear(); DGVUpload.Refresh(); DGVUpload.Columns.Clear(); // initialize datagridview columns addColumns(); findAccounts(); // List<Task<FindExistingTrades>> findTradeTask = new List<Task<FindExistingTrades>>(); // Check if any similar trades exist //List<FindExistingTrades> JobList = new List<FindExistingTrades>(); //foreach(DataGridViewRow row in DGVUpload.Rows) //{ // JobList.Add(new FindExistingTrades(row.Cells["Symbol"].Value.ToString(), row.Cells["Side"].Value.ToString(), Convert.ToInt32(row.Cells["Quantity"].Value), Convert.ToDecimal(row.Cells["Avg_Price"].Value), row.Cells["ClientAcct"].Value.ToString(), row.Index)); //} //foreach(FindExistingTrades jobs in JobList) //{ // T.Add(new Task<int[]>(jobs.Find)); //} //foreach(Task<int[]> tasks in T) //{ // tasks.Start(); // results.Add(tasks.Result); //} progressBar1.Maximum = DGVUpload.Rows.Count; progressBar1.Value = 0; label2.Text = "Matching..."; foreach (DataGridViewRow row in DGVUpload.Rows) { FindExistingTrades findExisting = new FindExistingTrades(row.Cells["Symbol"].Value.ToString(), row.Cells["Side"].Value.ToString(), Convert.ToInt32(row.Cells["Quantity"].Value), Convert.ToDecimal(row.Cells["Avg_Price"].Value), row.Cells["ClientAcct"].Value.ToString(), row.Index); progressBar1.Increment(1); var searchVal = await findExisting.Find(); if (searchVal == 2) { row.DefaultCellStyle.BackColor = Color.LightBlue; row.Cells["Status"].Value = "Found"; } else if (searchVal == 3) { row.DefaultCellStyle.BackColor = Color.LightGreen; row.Cells["Status"].Value = "Potential trade matched"; } else if (searchVal == 1) { row.DefaultCellStyle.BackColor = Color.Yellow; row.Cells["Status"].Value = "Found similar trade, follow prompts - Price did not match"; } else { row.Cells["Status"].Value = "New trade details"; } //await findExisting.Find().ContinueWith(r => //{ // var searchVal = r.Result; // if (searchVal == 2) // { // row.DefaultCellStyle.BackColor = Color.LightBlue; // row.Cells["Status"].Value = "Found"; // } // else if (searchVal == 3) // { // row.DefaultCellStyle.BackColor = Color.LightGreen; // row.Cells["Status"].Value = "Found incomplete Trade"; // } // else if (searchVal == 1) // { // row.DefaultCellStyle.BackColor = Color.Yellow; // row.Cells["Status"].Value = "Found similar trade, follow prompts"; // } // else // { // row.Cells["Status"].Value = "No Trades found"; // } // //}, TaskScheduler.FromCurrentSynchronizationContext()); } foreach (DataGridViewRow row in DGVUpload.Rows) { FindExistingTrades finder = new FindExistingTrades(row.Cells["Symbol"].Value.ToString(), row.Cells["Side"].Value.ToString(), Convert.ToInt32(row.Cells["Quantity"].Value), Convert.ToDecimal(row.Cells["Avg_Price"].Value), row.Cells["ClientAcct"].Value.ToString(), row.Index); var portfolios = finder.FindPortfolios(); if (portfolios.Count > 1) { row.Cells["ClientAcct"].Value = String.Join(", ", portfolios.ToArray()); } else if (portfolios.Count == 1) { if (portfolios[0] != "") { row.Cells["ClientAcct"].Value = portfolios[0]; } } row.Cells["Commission"].Value = finder.getCommission() * 100; } try { modifyColumns(); if (DGVUpload.Controls.Find("chk", true).Count() == 0) { addCheckBox(); } } catch { return; } label2.Text = "Done"; btnUpload.Enabled = true; btnUpload.ForeColor = Color.White; //DGVUpload.Columns["chkBoxCol"].Width = 20; foreach (DataGridViewRow row in DGVUpload.Rows) { if (row.DefaultCellStyle.BackColor == Color.LightBlue) { btnPrint.Enabled = true; return; } } }