private void AddItemBtn_Click(object sender, EventArgs e) { if (nameTb.Text == null || descTb.Text == null || quantNUD.Value == 0 || typeCb.SelectedIndex == -1 || feeNUD.Value == 0) { timer1.Start(); label6.Text = "Values for item cannot be empty, please fill every box"; } else { string name = nameTb.Text; string desciption = descTb.Text; double fee = Convert.ToDouble(feeNUD.Value); int quantity = Convert.ToInt32(quantNUD.Value); string type = typeCb.Text; client.AddData(newStand.Id, name, desciption, fee, quantity, type); mainApp.UpdateListMethod(); ActiveForm.Refresh(); nameTb.Clear(); descTb.Clear(); typeCb.SelectedIndex = -1; feeNUD.Value = 0; quantNUD.Value = 0; mainApp.ClearGUI(); } }
private void timer1_Tick(object sender, EventArgs e) { foreach (var ball in balls) { //ball.ApplyForce(gravity); ball.Update(); } ActiveForm.Refresh(); }
private void Woid_txtbox_KeyPress(object sender, KeyPressEventArgs e) { // check timing (keystrokes within 100 ms) TimeSpan elapsed = DateTime.Now - _lastKeystroke; if (elapsed.TotalMilliseconds > userinputtime) { _barcode.Clear(); } // record keystroke & timestamp _barcode.Add(e.KeyChar); _lastKeystroke = DateTime.Now; // process barcode if (e.KeyChar == 13 && _barcode.Count > 0) { string msg = new string(_barcode.ToArray()); _barcode.Clear(); if (msg != "\r" || developer) { if (e.KeyChar == 13) { if (connectapi.WOReleased(woid_txtbox.Text.Trim())) { connectapi.Scanworkorder(woid_txtbox.Text.Trim()); Showaddedtodg(); woid_txtbox.Clear(); ActiveForm.Refresh(); } else { MessageBox.Show("Please check the work order number.", "SPM Connet - Work Order Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); woid_txtbox.Clear(); woid_txtbox.Focus(); } e.Handled = true; } } else { MessageBox.Show("System cannot accept keyboard inputs. Scan with barcode reader", "SPM Connect", MessageBoxButtons.OK, MessageBoxIcon.Error); woid_txtbox.Clear(); woid_txtbox.Focus(); } } }
/// <summary> /// refresh /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["MayaMayaConnection"].ConnectionString; SqlConnection dbConnection = new SqlConnection(connString); BestellingDAO bestellingDAO = new BestellingDAO(dbConnection); listView1.Items.Clear(); listView2.Items.Clear(); foreach (Button b in button) { b.Dispose(); } BarScherm_Huidig_load(); BarScherm_Geschiedenis_load(); ActiveForm.Refresh(); }
private void buttonStart_Click(object sender, EventArgs e) { start(); int y = Convert.ToInt32(textBoxRozmiarX.Text); int x = Convert.ToInt32(textBoxRozimarY.Text); int iloscBomb = Convert.ToInt32(textBoxLiczbaBomb.Text); _x = x; _y = y; _iloscBomb = iloscBomb; if (iloscBomb >= 10 && y >= 8 && x >= 8 && iloscBomb <= (x - 1) * (y - 1) && y <= 30 && x <= 24) { tablica = new int[x, y]; tablicaOdblokowane = new bool[x, y]; zerujTablce(x, y); losujBomby(iloscBomb); sprawdzTablce(x, y); dodajPrzyciski(x, y); timer1.Start(); stopwatch.Start(); buttonStart.Enabled = false; if (50 + x * (30) + 10 > 350) { ActiveForm.Height = 50 + x * (30) + 10; } else { ActiveForm.Height = 350; } if (50 + y * (30) + 10 > 370) { ActiveForm.Width = 50 + y * (30) + 10; } else { ActiveForm.Width = 370; } ActiveForm.Refresh(); } else { MessageBox.Show("Błąd \nZmień dane", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void drawarrpoints() { ActiveForm.Refresh(); if (mmmm > arrmaxmemb) { mmmm = arrmaxmemb; } xx2 = myArr[0, 0]; yy2 = myArr[0, 1]; g.DrawEllipse(myPen2, xx2, yy2, 1, 0); for (i = 0; i < mmmm; i++) { xx1 = myArr[i, 0]; yy1 = myArr[i, 1]; g.DrawEllipse(myPen2, xx1, yy1, 1, 0); progressBar1.Value = Convert.ToInt32(Convert.ToDouble(i) / Convert.ToDouble(mmmm) * 100.0); } }
private void buttonStartStop_MouseClick(object sender, MouseEventArgs e) { trigger0 += 1; startx = 0; stopx = MainForm.ActiveForm.Width - 17; starty = 65; stopy = MainForm.ActiveForm.Height - 104; g = this.CreateGraphics(); switch (trigger0) { case 1: ActiveForm.Refresh(); progressBar1.Value = 0; pointnumber = 0; mmmm = 0; buttonStartStop.Text = "Click to Abort"; threadrunit = new Thread(RunIt) { Priority = ThreadPriority.Normal }; threadrunit.Start(); break; case 2: threadrunit.Abort(); label4.Text = Convert.ToString(mmmm); buttonStartStop.Text = "Aborted. Press for drawing from array"; break; case 3: buttonStartStop.Text = "Drawing from array"; drawarrpoints(); buttonStartStop.Text = "Drawed from array"; trigger0 = 0; break; case 4: trigger0 = 0; break; } }
/// <summary> /// Wanneer een button wordt geclickt, wordt de bestelling gemarkeerd en de button verwijderd. Ook refresht het scherm. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void button_Click(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["MayaMayaConnection"].ConnectionString; SqlConnection dbConnection = new SqlConnection(connString); BestellingDAO bestellingDAO = new BestellingDAO(dbConnection); Button btn = (Button)sender; BestelRegel regel = (BestelRegel)btn.Tag; bestellingDAO.MarkeerBestelRegel(regel.Id, regel.Status); listView1.Items.Clear(); listView2.Items.Clear(); foreach (Button b in button) { b.Dispose(); } BarScherm_Huidig_load(); BarScherm_Geschiedenis_load(); ActiveForm.Refresh(); }
private void FinalGame() { skip1.Visible = false; skip2.Visible = false; foreach (CardClass card in firstPlayerGameCards) { card.SetImagePosition(-200, -200); } foreach (CardClass card in secondPlayerGameCards) { card.SetImagePosition(-200, -200); } firstPlayerOutCards.Sort(Compare); secondPlayerOutCards.Sort(Compare); int firstIndex = 11; if (firstPlayerOutCards.Count < 11) { firstIndex = firstPlayerOutCards.Count; } int secondIndex = 11; if (secondPlayerOutCards.Count < 11) { secondIndex = secondPlayerOutCards.Count; } int firstSumma = 0; int secondSumma = 0; for (int i = 0; i < firstIndex; i++) { firstPlayerOutCards[i].SetVisible(true); if (i < 6) { firstPlayerOutCards[i].SetImagePosition(120 + i * 128, 360); } else { firstPlayerOutCards[i].SetImagePosition(182 + (i - 6) * 128, 504); } firstSumma += firstPlayerOutCards[i].Value; firstPlayerOutCards[i].ImageBox.BringToFront(); if (ActiveForm != null) { ActiveForm.Refresh(); } System.Threading.Thread.Sleep(1000); } if (ActiveForm != null) { ActiveForm.Refresh(); } for (int i = 0; i < secondIndex; i++) { secondPlayerOutCards[i].SetVisible(true); if (i < 5) { secondPlayerOutCards[i].SetImagePosition(182 + i * 128, 32); } else { secondPlayerOutCards[i].SetImagePosition(120 + (i - 5) * 128, 180); } secondSumma += secondPlayerOutCards[i].Value; secondPlayerOutCards[i].ImageBox.BringToFront(); if (ActiveForm != null) { ActiveForm.Refresh(); } System.Threading.Thread.Sleep(1000); } if (ActiveForm != null) { ActiveForm.Refresh(); } MessageBox.Show("First " + firstSumma + "\nSecond " + secondSumma); if (firstSumma > secondSumma) { MessageBox.Show("First win game", "Football"); } else if (secondSumma > firstSumma) { MessageBox.Show("Second win game", "Football"); } if (MessageBox.Show("Start a new game?", "Football", MessageBoxButtons.YesNo) == DialogResult.Yes) { newToolStripMenuItem_Click(null, null); } else { if (MessageBox.Show("Exit game?", "Football", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Exit(); } } }
private void RandomCards() { MessageBox.Show("Penalties", "Football"); int firstPlayerSumma = 0; int secondPlayerSumma = 0; foreach (CardClass card in firstPlayerGameCards) { card.ImageBox.Visible = false; } foreach (CardClass card in secondPlayerGameCards) { card.ImageBox.Visible = false; } for (int i = 0; i < 4; i++) { if (cardsOnTable[i] != null) { cardsOnTable[i].ImageBox.Visible = false; } } firstPlayerBlocked = true; secondPlayerBlocked = true; skip1.Visible = false; skip2.Visible = false; for (int i = 0; i < 6; i++) { cards[indexArray[counter]].SetVisible(true); cards[indexArray[counter]].ImageBox.BringToFront(); cards[indexArray[counter]].Status = CardStatus.Table; if (i % 2 == 0) { cards[indexArray[counter]].SetImagePosition(240 + i * 100, 420); randomGameCards.Add(cards[indexArray[counter]]); firstPlayerSumma += cards[indexArray[counter]].Value; } else { cards[indexArray[counter]].SetImagePosition(240 + (i - 1) * 100, 120); randomGameCards.Add(cards[indexArray[counter]]); secondPlayerSumma += cards[indexArray[counter]].Value; } ++counter; if (ActiveForm != null) { ActiveForm.Refresh(); } System.Threading.Thread.Sleep(1000); } MessageBox.Show("First " + firstPlayerSumma.ToString(CultureInfo.InvariantCulture) + "\nSecond " + secondPlayerSumma.ToString(CultureInfo.InvariantCulture), "Football"); if (firstPlayerSumma > secondPlayerSumma) { MessageBox.Show("First win", "Football"); foreach (CardClass card in randomGameCards) { card.SetVisible(false); card.Status = CardStatus.OutOfGame; card.SetImagePosition(855, 424); firstPlayerOutCards.Add(card); } randomGameCards.Clear(); roundWinner = Players.First; } else if (secondPlayerSumma > firstPlayerSumma) { MessageBox.Show("Second win", "Football"); foreach (CardClass card in randomGameCards) { card.SetVisible(false); card.Status = CardStatus.OutOfGame; card.SetImagePosition(855, 112); secondPlayerOutCards.Add(card); } randomGameCards.Clear(); roundWinner = Players.Second; } else { MessageBox.Show("Round draw", "Football"); foreach (CardClass card in randomGameCards) { card.SetVisible(false); card.Status = CardStatus.OutOfGame; card.SetImagePosition(-200, -200); } randomGameCards.Clear(); roundWinner = Players.None; } foreach (CardClass card in firstPlayerGameCards) { card.ImageBox.Visible = true; } foreach (CardClass card in secondPlayerGameCards) { card.ImageBox.Visible = true; } for (int i = 0; i < 4; i++) { if (cardsOnTable[i] != null) { cardsOnTable[i].ImageBox.Visible = true; } } }
// ============= Поиск ====================== private void searchAnaliseButton_Click(object sender, EventArgs e) { if (Data.GeneratedFileName != null && Directory.Exists(Data.GeneratedFileName + "_")) { var dir = new DirectoryInfo(Data.GeneratedFileName + "_"); // папка с файлами Data.Files = dir.GetFiles().Select(file => file.FullName).ToList(); // список для имен файлов Data.CountOfFiles = Data.Files.Count; } else { MessageBox.Show(@"Path not found", @"Error", MessageBoxButtons.OK); return; } Data.GraphMidTime = new Dictionary <long, long>(); Data.GraphNotTime = new Dictionary <long, long>(); var stopwatch = new Stopwatch(); stopwatch.Start(); label1.Text = @"Осталось: " + Data.Files.Count.ToString(CultureInfo.InvariantCulture) + @" из " + Data.CountOfFiles.ToString(CultureInfo.InvariantCulture); if (ActiveForm != null) { ActiveForm.Refresh(); ActiveForm.Enabled = false; } var t = new Thread(new Finder().DoIt); var t2 = new Thread(new Finder().DoIt); t.Start(); t2.Start(); //new Finder().DoIt(); while (t.IsAlive || t2.IsAlive) { Thread.Sleep(5000); label1.Text = @"Осталось: " + Data.Files.Count.ToString(CultureInfo.InvariantCulture) + @" из " + Data.CountOfFiles.ToString(CultureInfo.InvariantCulture); Refresh(); } t.Join(); t2.Join(); stopwatch.Stop(); // выводим графику _g3 = new Graphic(tempBitmapSearch1, graphAnalise1, search1box); _g4 = new Graphic(tempBitmapSearch2, graphAnalise2, search2box); // график первого метода хеширования var maxYSelector = from d in Data.GraphMidTime orderby d.Value select d.Value; long maxY = maxYSelector.Last(); var result = Data.GraphMidTime.OrderBy(pair => pair.Key); int i = 0; foreach (KeyValuePair <long, long> keyValuePair in result) { _g3.DrawNewStat(i++, keyValuePair.Value / (double)maxY * 100); } _g3.DrawYMaxStat(maxY); // график второго метода хеширования maxYSelector = from d in Data.GraphNotTime orderby d.Value select d.Value; maxY = maxYSelector.Last(); result = Data.GraphNotTime.OrderBy(pair => pair.Key); i = 0; foreach (KeyValuePair <long, long> keyValuePair in result) { _g4.DrawNewStat(i++, keyValuePair.Value / (double)maxY * 100); } _g4.DrawYMaxStat(maxY); MessageBox.Show("Поиск выполнен успешно.\nЗатрачено " + stopwatch.Elapsed, @"Success", MessageBoxButtons.OK); label1.Text = @"Осталось: " + Data.Files.Count.ToString(CultureInfo.InvariantCulture) + @" из " + Data.CountOfFiles.ToString(CultureInfo.InvariantCulture); Refresh(); Enabled = true; }
public void trackBarSize_MouseUp(object sender, MouseEventArgs e) { MainForm.ActiveForm.Width = trackBarSize.Value * 160; MainForm.ActiveForm.Height = trackBarSize.Value * 120; ActiveForm.Refresh(); }
private void MainForm_Resize(object sender, EventArgs e) { ActiveForm.Refresh(); }