private void button3_Click(object sender, EventArgs e) { List <string[]> path = bd.selectPathToPicturesByComplexityOrder(comboBox2.SelectedItem.ToString()); List <string> id_piece = new List <string>(); if (listView1.SelectedIndices.Count != 0) { int t = listView1.SelectedIndices[0]; string id_picture = bd.selectIdByPathPicture(path[t][0]); string id_puzzle = bd.selectPuzzleByIdPuzzleByIdPicture(id_picture); id_piece = bd.selectIdPiece(id_puzzle); //удалить сначала сейвы с этой картинкой bd.deleteSaveByIdPuzzle(id_puzzle); bd.deleteGameByIdPuzzle(id_puzzle); //bd.deletePuzzle(id_puzzle); for (int i = 0; i < id_piece.Count; i++) { bd.deletePiecePuzzleByIdPuzzleAndOrIdPuzzle(id_puzzle, id_piece[i]); } // bd.deletePiecePuzzleByIdPuzzleAndOrIdPicture("", bd.selectIdByPathPicture(path[t][0])); //удалить геймы с этой картинкой bd.deletePictures(path[t][0]); updateListView(); } }
private void button1_Click(object sender, EventArgs e) { ConnDatabase bd = new ConnDatabase(); string id_piece = ""; List <string> game = new List <string>(); try { game = bd.selectAllAboutGameByLoginAndIdPuzzle(login, id_puzzle); if (game.Count != 0) { bd.deleteGameByIdPuzzleAndLogin(id_puzzle, login); for (int i = 0; i < serial_number.Count; i++) { id_piece = bd.selectIDPiece(serial_number[i].ToString(), id_puzzle); bd.deletePiecePuzzleByIdPuzzleAndOrIdPuzzle(id_puzzle, id_piece); } bd.deleteSaveByIdPuzzleAndLogin(id_puzzle, login); saveGame(record); } else { saveGame(record); } } catch { } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { Point xy = dataGridView1.CurrentCellAddress; int x = xy.X; int y = xy.Y; if (x == 4) { List <string[]> res = bd.selectPuzzlesByComplexity(""); List <string> id_piece = new List <string>(); if (y < res.Count) { string id = res[y][0]; id_piece = bd.selectIdPiece(id); bd.deleteSaveByIdPuzzle(id); for (int i = 0; i < id_piece.Count; i++) { bd.deletePiecePuzzleByIdPuzzleAndOrIdPuzzle(id, id_piece[i]); } bd.deleteGameByIdPuzzle(id); bd.deletePuzzle(id); dataGridView1.Rows.RemoveAt(y); } } }
public void setPieceIfOnRightLocation(object pic) { if (first_move) { timer1.Enabled = true; stopWatch.Start(); first_move = false; } currentmoves++; PicBox picture = (PicBox)pic; bool is_moved_top_piece = true; bool is_this_top_piece = true; char place = (char)((object[])picture.Tag)[1]; Point rightxy = (Point)((object[])picture.Tag)[0]; bool need_to_update_strip = false; ConnDatabase bd = new ConnDatabase(); string id_piece = ""; List <string> game = new List <string>(); picture.Invalidate(); if (triangle) { Color iii = ((Bitmap)picture.Image).GetPixel(5, 5); is_moved_top_piece = !(iii.ToArgb() == Color.Transparent.ToArgb()); } if ((picture.Location.X < (rightxy.X + (btm1[0].Width / 2))) && (picture.Location.X > (rightxy.X - (btm1[0].Width / 2))) && (picture.Location.Y < (rightxy.Y + (btm1[0].Height / 2))) && (picture.Location.Y > (rightxy.Y - (btm1[0].Height / 2)))) { picture.Location = rightxy; picture.Invalidate(); picture.Enabled = false; picture.BorderStyle = BorderStyle.Fixed3D; if (game_mode.Equals("На ленте")) { object[] o = new object[2]; o[0] = rightxy; o[1] = 'f'; picture.Tag = o; if (place == 's') { need_to_update_strip = true; } } } if (game_mode.Equals("На поле")) { //найти ячейку на которую стал пазл int r = 0; int old_num = 0; bool www = false; int l = verticalCountOfPieces * horisontalCountOfPieces; if (triangle) { l *= 2; } //как-то не проверить себя самого while ((old_num < l) && !((char)(((object[])pb[old_num].Tag)[1]) == 'o')) { old_num++; } while ((r < l) && (!www)) { Color iii = ((Bitmap)pb[r].Image).GetPixel(5, 5); is_this_top_piece = !(iii.ToArgb() == Color.Transparent.ToArgb()); if (r != old_num) { if ((picture.Location.X > (pb[r].Location.X - (btm1[0].Width / 2))) && (picture.Location.X < (pb[r].Location.X + (btm1[0].Width / 2))) && (picture.Location.Y < pb[r].Location.Y + (btm1[0].Height / 2)) && (picture.Location.Y > (pb[r].Location.Y - (btm1[0].Height / 2)))) { if (pb[r].Enabled) { if (is_this_top_piece == is_moved_top_piece) { www = true; //устанавливаю туда, куда он стал picture.Location = pb[r].Location; picture.BringToFront(); picture.Invalidate(); pb[r].Location = oldLocation; pb[r].BringToFront(); pb[r].Invalidate(); if (pb[r].Location.X == ((Point)((object[])pb[r].Tag)[0]).X) { if (pb[r].Location.Y == ((Point)((object[])pb[r].Tag)[0]).Y) { pb[r].Enabled = false; pb[r].BorderStyle = BorderStyle.Fixed3D; } } } } } } r++; } if (!www) { picture.Location = oldLocation; picture.Invalidate(); } object[] o = new object[2]; o[0] = (Point)(((object[])picture.Tag)[0]); o[1] = ' '; picture.Tag = o; } //лента if (game_mode.Equals("На ленте")) { if ((currentLocationOfStripZoneTopLeft.X < picture.Location.X) && (picture.Location.X < currentLocationOfStripZoneBottomRight.X)) { if ((currentLocationOfStripZoneTopLeft.Y < picture.Location.Y) && (picture.Location.Y < currentLocationOfStripZoneBottomRight.Y)) { //значит в зоне ленты if (!(place == 's')) { need_to_update_strip = true; object[] o = new object[2]; o[0] = rightxy; o[1] = 'n'; picture.Tag = o; } } } if (place == 's') { need_to_update_strip = true; object[] o = new object[2]; o[0] = rightxy; o[1] = 'f'; picture.Tag = o; } } if (need_to_update_strip) { updateStrip(); } int i = 0; while ((i < pb.Count) && (pb[i].Enabled == false)) { i++; } if (i == pb.Count) { string res = ""; double points = 0; int l = verticalCountOfPieces * horisontalCountOfPieces; if (triangle) { l *= 2; } TimeSpan ts = stopWatch.Elapsed; ts.Add(fromSave); int sec = ts.Hours * 60 * 60 + ts.Minutes * 60 + ts.Seconds; if (record.Equals("На очки")) { points = currentmoves / (l); } else { points = sec / (l); } if (points < betweenGreatAndNormal) { points = GREAT / points; } else if (points > betweenNormalAndBad) { points = BAD / points; } else { points = NORMAL / points; } points *= complexityKoeff; res = ((int)points).ToString(); //проверка сохраненной игры game = bd.selectAllAboutGameByLoginAndIdPuzzle(login, id_puzzle); if (game.Count != 0) { bd.deleteGameByIdPuzzleAndLogin(id_puzzle, login); for (int k = 0; k < l; k++) { id_piece = bd.selectIDPiece(k.ToString(), id_puzzle); bd.deletePiecePuzzleByIdPuzzleAndOrIdPuzzle(id_puzzle, id_piece); } bd.deleteSaveByIdPuzzleAndLogin(id_puzzle, login); } string result = bd.selectResults(login); try { points += Int32.Parse(result); } catch { points += 0; } bd.setResults(login, ((int)points).ToString()); if (MessageBox.Show("Победа!Ваш результат: " + res) == DialogResult.OK) { stopWatch.Stop(); timer1.Enabled = false; close_without_ask = true; hhh.Close(); this.Close(); } } }