private void add() { try { Game wnd = new Game(connect, IS, recom, mode); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_data(); if (gpos >= 0 && dataGridViewCalendarGames.Rows.Count > 0) { dataGridViewCalendarGames.Rows[gpos].Selected = true; dataGridViewCalendarGames.FirstDisplayedScrollingRowIndex = gpos; } recom = flawour; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void buttonSave_Click(object sender, EventArgs e) { CGame clGame = new CGame(connect); try { stC = read_data(); if (fread) { if (newgame == true) { if (clGame.Insert(stC)) { DialogResult = DialogResult.OK; } } else { if (clGame.Update(stC, IS.idseason, gstGame.idgame)) { DialogResult = DialogResult.OK; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void edit() { try { STGame data = GetSelectionData(); if (data.idgame > 0) { Game wnd = new Game(connect, IS, mode, data); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_data(); if (gpos >= 0 && dataGridViewGames.Rows.Count > 0) { dataGridViewGames.Rows[gpos].Selected = true; dataGridViewGames.FirstDisplayedScrollingRowIndex = gpos; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
// Call with StandardTetrisTimeT::GetIntervalDurationSecondsFloat() in main() public static void PerformGameIterations ( STGame game, double deltaTimeSeconds ) { // First, update the game time. game.ConditionalAdvanceGameTimeByDelta(deltaTimeSeconds); int gameSpeed = 0; gameSpeed = game.GetGameSpeedAdjustment( ); if (gameSpeed <= 2) { // Perform any unforced game iteration. game.ConditionalAdvanceGameIteration(false); } else { int totalIncrements = (8 * gameSpeed); int incrementCounter = 0; for ( incrementCounter = 0; incrementCounter < totalIncrements; incrementCounter++ ) { game.ConditionalAdvanceGameIteration(true); } } // Update reported frame rate { float frameDurationSeconds = 0.0f; frameDurationSeconds = (float)deltaTimeSeconds; float framesPerSecond = 0.0f; if (frameDurationSeconds > 0.0001f) { framesPerSecond = (1.0f / frameDurationSeconds); } if (framesPerSecond < 0.0f) { framesPerSecond = 0.0f; } game.SetReportedFrameRate(framesPerSecond); } }
public Stats(SqlConnection cn, STInfoSeason inf, ushort md, STGame gm) { InitializeComponent(); connect = cn; IS = inf; mode = md; gSTGame = gm; clStats = new CStats(connect); clfs = new ListCompareByNumberFormStats(); clep = new ListCompareByNumberFromEntryPlayers(); }
private void set_data() { string text; try { textBoxId.Text = gstTF.id.ToString(); clTeam = new CTeam(connect, gstTF.idteam); comboBoxTeam.Text = clTeam.stTeam.name; if (gstTF.typepart == 0) { radioButtonPlayer.Checked = true; clPlayer = new CPlayer(connect, gstTF.idpart); text = string.Format("{0} {1} ({2})", clPlayer.stPlayer.family, clPlayer.stPlayer.name, clPlayer.stPlayer.personalnum); comboBoxPart.Text = text; } if (gstTF.typepart == 1) { radioButtonCoach.Checked = true; clCoach = new CCoach(connect, gstTF.idpart); text = string.Format("{0} {1} ({2})", clCoach.stCoach.family, clCoach.stCoach.name, clCoach.stCoach.personalnum); comboBoxPart.Text = text; } textBoxNGame.Text = gstTF.idgame.ToString(); game = clGame.GetGame(gstTF.idseason, gstTF.idgame); clTeam = new CTeam(connect, (int)game.idteam1); name1 = clTeam.stTeam.name; clTeam = new CTeam(connect, (int)game.idteam2); name2 = clTeam.stTeam.name; text = string.Format("{0} - {1}", name1, name2); textBoxDescriptGame.Text = text; textBoxDescript.Text = gstTF.descript; if (gstTF.idreferee > 0) { clReferee = new CReferee(connect, (int)gstTF.idreferee); text = string.Format("{0} {1}", clReferee.stRef.family, clReferee.stRef.name); comboBoxReferee.Text = text; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void stats() { try { STGame data = GetSelectionData(); if (data.idgame > 0) { Stats wnd = new Stats(connect, IS, mode, data); wnd.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void init_list_add_capt(STGame item, int i) { string text = null; CScheme clScheme = new CScheme(connect, IS.idseason, (int)item.iddivision, (int)item.idstage); try { /* вставляем дату и тур */ text = string.Format("{0}, {1} тур", clScheme.stScheme.namestage, item.round); dataGridViewGames.Rows[i].Cells[0].Value = text; dataGridViewGames.Rows[i].DefaultCellStyle.BackColor = Color.Azure; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public Game(SqlConnection cn, STInfoSeason st, ushort m, STGame stru) { InitializeComponent(); connect = cn; IS = st; mode = m; gstGame = stru; if (stru.type != null) { gType = (int)stru.type; } if (stru.iddivision != null) { gDiv = (int)stru.iddivision; } else { gDiv = 0; } if (stru.idgroup != null) { gGroup = (int)stru.idgroup; } else { gGroup = 0; } if (stru.idstage != null) { gStage = (int)stru.idstage; } else { gStage = 0; } newgame = false; caption = "–едактировать игру"; }
private void stats() { try { STGame data = GetSelectionData(); if (data.idgame > 0) { if (data.idteamwins == null || data.idteamwins == 0) { MessageBox.Show("Необходимо заполнить протокол", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Stats wnd = new Stats(connect, IS, mode, data); wnd.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private STGame GetSelectionData() { STGame ret = new STGame(); int n; try { foreach (DataGridViewRow item in dataGridViewGames.SelectedRows) { if (item.Cells[1].Value != null) { n = int.Parse(item.Cells[1].Value.ToString()); ret = clGame.GetGame(IS.idseason, n); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private void del() { string text = null; try { STGame data = GetSelectionData(); if (data.idgame > 0) { text = string.Format("Вы действиетльно желаете удалить игру {0}?", data.idgame); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { clGame.Delete(data); init_data(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public static void HandleVideoCaptureGUI ( GR gr, float videoSheetX, float videoSheetY, float videoSheetWidth, float videoSheetHeight, STGame game, int clientWidth, int clientHeight, int clientRelativeCursorX, int clientRelativeCursorY ) { STGameState gameState = game.GetGameState( ); if (false == game.GameIsSpawnFromVideoCapture( )) { return; } gr.glBindTexture ( GR.GL_TEXTURE_2D, STEngine.GetVideoProcessing( ).mTextureOpenGLHandleBGR256x256 ); float x1 = 0.0f; float y1 = 0.0f; float x2 = 0.0f; float y2 = 0.0f; x1 = videoSheetX; y1 = videoSheetY; x2 = x1 + (videoSheetWidth - 1.0f); y2 = y1 + (videoSheetHeight - 1.0f); float u1 = 0.0f; float v1 = 0.0f; float u2 = 0.0f; float v2 = 0.0f; u1 = 0.0f; v1 = 0.0f; u2 = 0.5f; v2 = 1.0f; gr.glEnable(GR.GL_SCISSOR_TEST); gr.glScissor((int)(x1), (int)(y1), (int)((x2 - x1) + 1), (int)((y2 - y1) + 1)); gr.glEnable(GR.GL_TEXTURE_2D); gr.glColor3f(1.0f, 1.0f, 1.0f); gr.glBegin(GR.GL_QUADS); gr.glTexCoord2f(u1, v2); gr.glVertex2f(x1, y2); gr.glTexCoord2f(u1, v1); gr.glVertex2f(x1, y1); gr.glTexCoord2f(u2, v1); gr.glVertex2f(x2, y1); gr.glTexCoord2f(u2, v2); gr.glVertex2f(x2, y2); gr.glEnd( ); gr.glDisable(GR.GL_TEXTURE_2D); gr.glDisable(GR.GL_SCISSOR_TEST); int xTexelMin = 0; int yTexelMin = 0; int xTexelMax = 0; int yTexelMax = 0; int xScreenMin = 0; int yScreenMin = 0; int xScreenMax = 0; int yScreenMax = 0; // Only listen to the mouse in training/calibration mode if (true == gameState.mCalibrationModeFlag) { if (0 != GetAsyncKeyState(Keys.LButton)) { // Left button pressed if (0 == gameState.mSelectionState) { gameState.mSelectionState = 1; gameState.mSelectionX1 = clientRelativeCursorX; gameState.mSelectionY1 = ((clientHeight - 1) - clientRelativeCursorY); gameState.mSelectionX2 = clientRelativeCursorX; gameState.mSelectionY2 = ((clientHeight - 1) - clientRelativeCursorY); } else { gameState.mSelectionX2 = clientRelativeCursorX; gameState.mSelectionY2 = ((clientHeight - 1) - clientRelativeCursorY); } } else { // Left button released if (0 == gameState.mSelectionState) { // Nothing to do... } else { gameState.mSelectionState = 0; } } gr.glEnable(GR.GL_SCISSOR_TEST); gr.glScissor(0, 0, clientWidth, clientHeight); gr.glColor3f(1.0f, 0.0f, 0.0f); gr.glBegin(GR.GL_LINES); gr.glVertex2f((float)clientRelativeCursorX - 8.0f, (float)((clientHeight - 1) - clientRelativeCursorY)); gr.glVertex2f((float)clientRelativeCursorX + 8.0f, (float)((clientHeight - 1) - clientRelativeCursorY)); gr.glVertex2f((float)clientRelativeCursorX, (float)((clientHeight - 1) - clientRelativeCursorY) - 8.0f); gr.glVertex2f((float)clientRelativeCursorX, (float)((clientHeight - 1) - clientRelativeCursorY) + 8.0f); gr.glEnd( ); } if (0 != ((GetAsyncKeyState(Keys.Shift)) & 0x8000)) { if (0 != ((GetAsyncKeyState(Keys.Left)) & 0x8000)) { gameState.mSelectionX2--; } if (0 != ((GetAsyncKeyState(Keys.Right)) & 0x8000)) { gameState.mSelectionX2++; } if (0 != ((GetAsyncKeyState(Keys.Down)) & 0x8000)) { gameState.mSelectionY2--; } if (0 != ((GetAsyncKeyState(Keys.Up)) & 0x8000)) { gameState.mSelectionY2++; } } else { if (0 != ((GetAsyncKeyState(Keys.Left)) & 0x8000)) { gameState.mSelectionX1--; } if (0 != ((GetAsyncKeyState(Keys.Right)) & 0x8000)) { gameState.mSelectionX1++; } if (0 != ((GetAsyncKeyState(Keys.Down)) & 0x8000)) { gameState.mSelectionY1--; } if (0 != ((GetAsyncKeyState(Keys.Up)) & 0x8000)) { gameState.mSelectionY1++; } } xScreenMin = gameState.mSelectionX1; yScreenMin = gameState.mSelectionY1; xScreenMax = gameState.mSelectionX2; yScreenMax = gameState.mSelectionY2; xTexelMin = (int)(256.0f * (((float)xScreenMin - videoSheetX) / videoSheetHeight)); yTexelMin = (int)(256.0f * (((float)yScreenMin - videoSheetY) / videoSheetHeight)); xTexelMax = (int)(256.0f * (((float)xScreenMax - videoSheetX) / videoSheetHeight)); yTexelMax = (int)(256.0f * (((float)yScreenMax - videoSheetY) / videoSheetHeight)); int disregard = 0; if (xTexelMin < 0) { disregard = 1; xTexelMin = 0; } if (yTexelMin < 0) { disregard = 1; yTexelMin = 0; } if (xTexelMax < 0) { disregard = 1; xTexelMax = 0; } if (yTexelMax < 0) { disregard = 1; yTexelMax = 0; } if (xTexelMin > 255) { disregard = 1; xTexelMin = 255; } if (yTexelMin > 255) { disregard = 1; yTexelMin = 255; } if (xTexelMax > 255) { disregard = 1; xTexelMax = 255; } if (yTexelMax > 255) { disregard = 1; yTexelMax = 255; } if (xTexelMin > xTexelMax) { int swap = xTexelMin; xTexelMin = xTexelMax; xTexelMax = swap; } if (yTexelMin > yTexelMax) { int swap = yTexelMin; yTexelMin = yTexelMax; yTexelMax = swap; } // Only set region if in training mode! if ((true == gameState.mCalibrationModeFlag) && (0 == disregard)) { STEngine.GetVideoProcessing( ).SetRegion(xTexelMin, yTexelMin, xTexelMax, yTexelMax); } STEngine.GetVideoProcessing( ).GetRegion(ref xTexelMin, ref yTexelMin, ref xTexelMax, ref yTexelMax); xScreenMin = (int)(videoSheetX + (videoSheetHeight * (float)xTexelMin / 256.0f)); yScreenMin = (int)(videoSheetY + (videoSheetHeight * (float)yTexelMin / 256.0f)); xScreenMax = (int)(videoSheetX + (videoSheetHeight * (float)xTexelMax / 256.0f)); yScreenMax = (int)(videoSheetY + (videoSheetHeight * (float)yTexelMax / 256.0f)); x1 = videoSheetX; y1 = videoSheetY; x2 = x1 + (videoSheetWidth - 1.0f); y2 = y1 + (videoSheetHeight - 1.0f); int currentClassification = STEngine.GetVideoProcessing( ).GetRegionClassification( ); if (0 == currentClassification) { // If the previous classification was a PIECE, and the current classification // is something different, then submit the piece (which must have fallen // by a row by now). if ((gameState.mPreviousClassification >= 1) && (gameState.mPreviousClassification <= 7)) { game.SpawnSpecifiedPieceShape(STPiece.GetShapeCorrespondingToByteCode((byte)gameState.mPreviousClassification)); } } gameState.mPreviousClassification = currentClassification; Color color; color = STGameDrawing.GetCellValueColorARGB // Returns WHITE for unknown ( (byte)currentClassification, // 0..6 false // monochrome mode ); float red = 0.0f; float green = 0.0f; float blue = 0.0f; red = (float)(color.R) / 255.0f; green = (float)(color.G) / 255.0f; blue = (float)(color.B) / 255.0f; gr.glColor3f(red, green, blue); gr.glBegin(GR.GL_LINES); gr.glVertex2f((float)xScreenMin, (float)yScreenMin); gr.glVertex2f((float)xScreenMin, (float)yScreenMax); gr.glVertex2f((float)xScreenMax, (float)yScreenMin); gr.glVertex2f((float)xScreenMax, (float)yScreenMax); gr.glVertex2f((float)xScreenMin, (float)yScreenMin); gr.glVertex2f((float)xScreenMax, (float)yScreenMin); gr.glVertex2f((float)xScreenMin, (float)yScreenMax); gr.glVertex2f((float)xScreenMax, (float)yScreenMax); // Horizontal divider gr.glVertex2f((float)xScreenMin, (float)((yScreenMin + yScreenMax) / 2)); gr.glVertex2f((float)xScreenMax, (float)((yScreenMin + yScreenMax) / 2)); // Vertical dividers gr.glVertex2f((float)(xScreenMin + ((xScreenMax - xScreenMin) / 4)), (float)yScreenMin); gr.glVertex2f((float)(xScreenMin + ((xScreenMax - xScreenMin) / 4)), (float)yScreenMax); gr.glVertex2f((float)(xScreenMin + 2 * ((xScreenMax - xScreenMin) / 4)), (float)yScreenMin); gr.glVertex2f((float)(xScreenMin + 2 * ((xScreenMax - xScreenMin) / 4)), (float)yScreenMax); gr.glVertex2f((float)(xScreenMin + 3 * ((xScreenMax - xScreenMin) / 4)), (float)yScreenMin); gr.glVertex2f((float)(xScreenMin + 3 * ((xScreenMax - xScreenMin) / 4)), (float)yScreenMax); gr.glEnd( ); gr.glDisable(GR.GL_SCISSOR_TEST); }
private STGame read_data() { STGame ret = new STGame(); try { /* сезон */ ret.idseason = IS.idseason; /* тип игры */ ret.type = gType; /* номер игры */ if (textBoxNum.Text.Length > 0) { ret.idgame = int.Parse(textBoxNum.Text.Trim()); } /* дата\врем¤ игры */ ret.datetime = new DateTime(dateTimePickerDate.Value.Year, dateTimePickerDate.Value.Month, dateTimePickerDate.Value.Day, dateTimePickerTime.Value.Hour, dateTimePickerTime.Value.Minute, 0, 0); /* дивизион */ if (comboBoxDivision.Text.Length > 0) { clDivision = new CDivision(connect, IS.idseason, comboBoxDivision.Text); ret.iddivision = clDivision.stDiv.id; } else { ret.iddivision = 0; } /* стади¤ */ if (comboBoxStage.Text.Length > 0) { clScheme = new CScheme(connect, IS.idseason, (int)ret.iddivision, comboBoxStage.Text.Trim()); ret.idstage = clScheme.stScheme.idstage; } else { ret.idstage = null; } /* группа */ if (comboBoxGroup.Text.Length > 0) { clGroup = new CGroup(connect, IS.idseason, (int)ret.iddivision, comboBoxGroup.Text.Trim()); ret.idgroup = clGroup.stGroup.idgroup; } else { ret.idgroup = null; } /* номер тура */ if (comboBoxRound.Text.Length > 0) { ret.round = int.Parse(comboBoxRound.Text.Trim()); } else { ret.round = null; } /* площадка */ if (comboBoxPlace.Text.Length > 0) { clPlace = new CPlace(connect, comboBoxPlace.Text.Trim()); ret.idplace = clPlace.stPlace.id; } else { ret.idplace = null; } /* команда 1 */ if (comboBoxTeam1.Text.Length > 0) { clTeam = new CTeam(connect, comboBoxTeam1.Text.Trim()); ret.idteam1 = clTeam.stTeam.id; } else { ret.idteam1 = null; } /* команда 2 */ if (comboBoxTeam2.Text.Length > 0) { clTeam = new CTeam(connect, comboBoxTeam2.Text.Trim()); ret.idteam2 = clTeam.stTeam.id; } else { ret.idteam2 = null; } /* данный команд */ if (textBoxAPer1.Text.Length > 0) { ret.aper1 = int.Parse(textBoxAPer1.Text.Trim()); } else { ret.aper1 = null; } if (textBoxAPer2.Text.Length > 0) { ret.aper2 = int.Parse(textBoxAPer2.Text.Trim()); } else { ret.aper2 = null; } if (textBoxADopPer.Text.Length > 0) { ret.adopper = int.Parse(textBoxADopPer.Text.Trim()); } else { ret.adopper = null; } if (textBoxAF1.Text.Length > 0) { ret.ateamfouls1 = int.Parse(textBoxAF1.Text.Trim()); } else { ret.ateamfouls1 = null; } if (textBoxAF2.Text.Length > 0) { ret.ateamfouls2 = int.Parse(textBoxAF2.Text.Trim()); } else { ret.ateamfouls2 = null; } if (textBoxAF3.Text.Length > 0) { ret.ateamfouls3 = int.Parse(textBoxAF3.Text.Trim()); } else { ret.ateamfouls3 = null; } if (textBoxAF4.Text.Length > 0) { ret.ateamfouls4 = int.Parse(textBoxAF4.Text.Trim()); } else { ret.ateamfouls4 = null; } if (textBoxBPer1.Text.Length > 0) { ret.bper1 = int.Parse(textBoxBPer1.Text.Trim()); } else { ret.bper1 = null; } if (textBoxBPer2.Text.Length > 0) { ret.bper2 = int.Parse(textBoxBPer2.Text.Trim()); } else { ret.bper2 = null; } if (textBoxBDopPer.Text.Length > 0) { ret.bdopper = int.Parse(textBoxBDopPer.Text.Trim()); } else { ret.bdopper = null; } if (textBoxBF1.Text.Length > 0) { ret.bteamfouls1 = int.Parse(textBoxBF1.Text.Trim()); } else { ret.bteamfouls1 = null; } if (textBoxBF2.Text.Length > 0) { ret.bteamfouls2 = int.Parse(textBoxBF2.Text.Trim()); } else { ret.bteamfouls2 = null; } if (textBoxBF3.Text.Length > 0) { ret.bteamfouls3 = int.Parse(textBoxBF3.Text.Trim()); } else { ret.bteamfouls3 = null; } if (textBoxBF4.Text.Length > 0) { ret.bteamfouls4 = int.Parse(textBoxBF4.Text.Trim()); } else { ret.bteamfouls4 = null; } if (textBoxAPoints1.Text.Length > 0) { ret.apointsper1 = int.Parse(textBoxAPoints1.Text.Trim()); } else { ret.apointsper1 = null; } if (textBoxAPoints2.Text.Length > 0) { ret.apointsper2 = int.Parse(textBoxAPoints2.Text.Trim()); } else { ret.apointsper2 = null; } if (textBoxAPoints3.Text.Length > 0) { ret.apointsper3 = int.Parse(textBoxAPoints3.Text.Trim()); } else { ret.apointsper3 = null; } if (textBoxAPoints4.Text.Length > 0) { ret.apointsper4 = int.Parse(textBoxAPoints4.Text.Trim()); } else { ret.apointsper4 = null; } if (textBoxADopPoints.Text.Length > 0) { ret.apointsdopper = int.Parse(textBoxADopPoints.Text.Trim()); } else { ret.apointsdopper = null; } if (textBoxAPoints.Text.Length > 0) { ret.apoints = int.Parse(textBoxAPoints.Text.Trim()); } else { ret.apoints = null; } if (textBoxBPoints1.Text.Length > 0) { ret.bpointsper1 = int.Parse(textBoxBPoints1.Text.Trim()); } else { ret.bpointsper1 = null; } if (textBoxBPoints2.Text.Length > 0) { ret.bpointsper2 = int.Parse(textBoxBPoints2.Text.Trim()); } else { ret.bpointsper2 = null; } if (textBoxBPoints3.Text.Length > 0) { ret.bpointsper3 = int.Parse(textBoxBPoints3.Text.Trim()); } else { ret.bpointsper3 = null; } if (textBoxBPoints4.Text.Length > 0) { ret.bpointsper4 = int.Parse(textBoxBPoints4.Text.Trim()); } else { ret.bpointsper4 = null; } if (textBoxBDopPoints.Text.Length > 0) { ret.bpointsdopper = int.Parse(textBoxBDopPoints.Text.Trim()); } else { ret.bpointsdopper = null; } if (textBoxBPoints.Text.Length > 0) { ret.bpoints = int.Parse(textBoxBPoints.Text.Trim()); } else { ret.bpoints = null; } /* флаг технического результата */ if (checkBoxTeh.Checked == true) { ret.flagteh = 1; } else { ret.flagteh = 0; } /* команда - победитель */ if (ret.apoints > ret.bpoints) { ret.idteamwins = ret.idteam1; } else if (ret.apoints < ret.bpoints) { ret.idteamwins = ret.idteam2; } else { ret.idteamwins = null; } /* судьи */ if (comboBoxStReferee.Text.Length > 0) { ret.idstreferee = get_referee(comboBoxStReferee.Text.Trim()); } else { ret.idstreferee = null; } if (comboBoxReferee1.Text.Length > 0) { ret.idreferee1 = get_referee(comboBoxReferee1.Text.Trim()); } else { ret.idreferee1 = null; } if (comboBoxReferee2.Text.Length > 0) { ret.idreferee2 = get_referee(comboBoxReferee2.Text.Trim()); } else { ret.idreferee2 = null; } /* оценки судь¤м */ if (textBoxPointsStrefree.Text.Length > 0) { ret.srrefereepoints = double.Parse(textBoxPointsStrefree.Text.Trim()); } else { ret.srrefereepoints = null; } if (textBoxPointsReferee1.Text.Length > 0) { ret.referee1points = double.Parse(textBoxPointsReferee1.Text.Trim()); } else { ret.referee1points = null; } if (textBoxPointsReferee2.Text.Length > 0) { ret.referee2points = double.Parse(textBoxPointsReferee2.Text.Trim()); } else { ret.referee2points = null; } /* секретарь */ if (comboBoxSecretar.Text.Length > 0) { ret.idwriting = get_participant(comboBoxSecretar.Text.Trim()); } else { ret.idwriting = null; } /* секретарь */ if (comboBoxOperPanel.Text.Length > 0) { ret.idoperpanel = get_participant(comboBoxOperPanel.Text.Trim()); } else { ret.idoperpanel = null; } /* видеооператор */ if (comboBoxOperVideo.Text.Length > 0) { ret.idopervideo = get_participant(comboBoxOperVideo.Text.Trim()); } else { ret.idopervideo = null; } /* врач */ if (comboBoxMedic.Text.Length > 0) { ret.idmedical = get_participant(comboBoxMedic.Text.Trim()); } else { ret.idmedical = null; } /* диктор */ if (comboBoxDiktor.Text.Length > 0) { ret.iddiktor = get_participant(comboBoxDiktor.Text.Trim()); } else { ret.iddiktor = null; } /* подсчЄт статистики */ if (comboBoxStatist.Text.Length > 0) { ret.idstatister = get_participant(comboBoxStatist.Text.Trim()); } else { ret.idstatister = null; } /* остальна¤ статистика */ if (textBoxCntLook.Text.Length > 0) { ret.cntlook = int.Parse(textBoxCntLook.Text.Trim()); } else { ret.cntlook = null; } if (textBoxChangeLider.Text.Length > 0) { ret.changelider = int.Parse(textBoxChangeLider.Text.Trim()); } else { ret.changelider = null; } if (textBoxMaxPointsA.Text.Length > 0) { ret.maxpointsteam1 = int.Parse(textBoxMaxPointsA.Text.Trim()); } else { ret.maxpointsteam1 = null; } if (textBoxMaxPointsB.Text.Length > 0) { ret.maxpointsteam2 = int.Parse(textBoxMaxPointsB.Text.Trim()); } else { ret.maxpointsteam2 = null; } if (textBoxEqualsResult.Text.Length > 0) { ret.equalsresult = int.Parse(textBoxEqualsResult.Text.Trim()); } else { ret.equalsresult = null; } if (textBoxMaxDiff.Text.Length > 0) { ret.maxdiff = int.Parse(textBoxMaxDiff.Text.Trim()); } else { ret.maxdiff = null; } fread = true; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); fread = false; } return(ret); }
public static void HandleKeyPress ( GR gr, IntPtr hwnd, int wParam, int lParam, STGame game, Keys keyCode, bool shiftKeyState, bool controlKeyState ) { STGameState gameState = game.GetGameState( ); // Priority of key press handling: // (1) Instructions; ESCAPE exits instructions; // (2) File Menu; ESCAPE exits file menu; // (3) Calibrate; ESCAPE cancels calibrate mode; // (4) Video Capture; ESCAPE quits application; // (5) Normal; ESCAPE quits application; // INSTRUCTIONS if (0 != game.InstructionGetState( )) { switch (keyCode) { case Keys.Down: case Keys.Next: // Page-Down case Keys.Right: { // Next page game.InstructionsNextPage( ); } break; case Keys.Up: case Keys.Prior: // Page-Up case Keys.Left: { // Previous page game.InstructionsPreviousPage( ); } break; default: { // User hit a key, but it wasn't relevant, so exit menu. game.InstructionsHide( ); // NOTE: Don't resume! : game.InputEventResume(); } break; } return; } else if (keyCode == Keys.I) { game.InstructionsShow( ); game.InputEventPause( ); return; } // FILE LIST if (true == gameState.mShowFileList) { switch (keyCode) { case Keys.Next: // Page-Down { // Next page gameState.mFirstItem += 20; } break; case Keys.Prior: // Page-Up { // Previous page gameState.mFirstItem -= 20; } break; case Keys.Down: { // Next Item gameState.mRelativeItem++; if (gameState.mRelativeItem > 19) { gameState.mFirstItem++; gameState.mRelativeItem = 19; } } break; case Keys.Up: { // Previous Item gameState.mRelativeItem--; if (gameState.mRelativeItem < 0) { gameState.mFirstItem--; gameState.mRelativeItem = 0; } } break; case Keys.Return: { // Load item gameState.mLoadFlag = true; } break; default: { // User hit a key, but it wasn't relevant, so exit menu. gameState.mShowFileList = false; // NOTE: Don't resume. : game.InputEvent_Resume(); } break; } return; } else if ((keyCode == Keys.L) && (true == shiftKeyState)) { // SHIFT-L will read a text file in to the game state. game.InputEventPause( ); gameState.mShowFileList = true; gameState.mFirstItem = 0; gameState.mRelativeItem = 0; gameState.mLoadFlag = false; STEngine.GetFileList().ScanDirectory(STEngine.GetApplicationPath( )); return; } // Calibrate Mode // (NOTE: See how normal mode enters calibrate mode by pressing 'C'.) if (true == game.GetCalibrationModeFlagValue( )) { if ((Keys.Escape == keyCode) || (Keys.C == keyCode)) { game.SetCalibrationModeFlagValue(false); game.InputEventResume( ); return; } if (keyCode == Keys.V) { if (false == game.GameIsSpawnFromVideoCapture( )) { // Set up sane conditions game.InputEventReset( ); game.InputEventShowNextPieceOff( ); game.InputEventAutoRestartOff( ); // Initialize Video Capture STEngine.GetVideoProcessing( ).Initialize(gr, hwnd); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.InputEventVideoStart( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); } else { STEngine.GetVideoProcessing( ).Terminate( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.InputEventVideoStop( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); } return; } switch (keyCode) { // training mode piece selection case Keys.D0: game.SetCalibrationModeShapeCode(0); break; case Keys.D1: game.SetCalibrationModeShapeCode(1); break; case Keys.D2: game.SetCalibrationModeShapeCode(2); break; case Keys.D3: game.SetCalibrationModeShapeCode(3); break; case Keys.D4: game.SetCalibrationModeShapeCode(4); break; case Keys.D5: game.SetCalibrationModeShapeCode(5); break; case Keys.D6: game.SetCalibrationModeShapeCode(6); break; case Keys.D7: game.SetCalibrationModeShapeCode(7); break; case Keys.D8: game.SetCalibrationModeShapeCode(0); break; case Keys.D9: game.SetCalibrationModeShapeCode(0); break; } return; } // Video Capture // The following is not mutually-exclusive with normal game play. if (true == game.GameIsSpawnFromVideoCapture( )) { if (keyCode == Keys.Return) { STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.ClearPreviousClassification( ); game.InputEventReset( ); System.Threading.Thread.Sleep(200); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.ClearPreviousClassification( ); game.InputEventReset( ); System.Threading.Thread.Sleep(200); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.ClearPreviousClassification( ); game.InputEventReset( ); System.Threading.Thread.Sleep(200); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.ClearPreviousClassification( ); game.InputEventReset( ); System.Threading.Thread.Sleep(200); } if (keyCode == Keys.V) { if (false == game.GameIsSpawnFromVideoCapture( )) { // Set up sane conditions game.InputEventReset( ); game.InputEventShowNextPieceOff( ); game.InputEventAutoRestartOff( ); // Initialize Video Capture STEngine.GetVideoProcessing( ).Initialize(gr, hwnd); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.InputEventVideoStart( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); } else { STEngine.GetVideoProcessing( ).Terminate( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.InputEventVideoStop( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); } return; } } // Console Mode if (true == gameState.mShowConsole) { if (keyCode == Keys.Delete) { STEngine.GetConsole( ).ClearAllLines( ); } else { // Any key other than delete or P (pause) exits console mode. if (keyCode != Keys.P) { gameState.mShowConsole = false; } } } else { if ((keyCode == Keys.Q) && (true == shiftKeyState)) { // SHIFT-Q : Console gameState.mShowConsole = true; } } // Normal Game Play // QUIT KEY: ESCAPE if (keyCode == Keys.Escape) { Form form = (Form)STEngine.GetMainForm( ); form.Close( ); return; } // Enter Calibrate Mode if (keyCode == Keys.C) { game.SetCalibrationModeFlagValue(true); game.SetCalibrationModeShapeCode(1); game.InputEventPause( ); } // Enable Video Capture if (keyCode == Keys.V) { if (false == game.GameIsSpawnFromVideoCapture( )) { // Set up sane conditions game.InputEventReset( ); game.InputEventShowNextPieceOff( ); game.InputEventAutoRestartOff( ); // Initialize Video Capture STEngine.GetVideoProcessing( ).Initialize(gr, hwnd); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); game.InputEventVideoStart( ); STEngine.GetVideoProcessing( ).ClearRegionStatus( ); } } // Reset Game if (keyCode == Keys.Return) { if (true == shiftKeyState) { game.InputEventHardReset( ); } else { game.InputEventReset( ); } } if (keyCode == Keys.P) { if (true == game.GameIsPaused( )) { game.InputEventResume( ); } else { game.InputEventPause( ); } } if (keyCode == Keys.A) { if (true == shiftKeyState) { STStrategyManager.SelectNextStrategy( ); } else { if (true == game.GameIsAI( )) { game.InputEventAIStop( ); } else { game.InputEventAIStart( ); } } } if (keyCode == Keys.T) { if (game.GameIsOutputToRS232( )) { game.InputEventRS232Stop( ); STRS232.TerminatePort( ); } else { STRS232.InitializePort( ); game.InputEventRS232Start( ); } } if ((keyCode == Keys.Subtract) || (keyCode == Keys.OemMinus)) // 0xbd { if (false == shiftKeyState) { game.InputEventGameSpeedDecrease( ); } } if ((keyCode == Keys.Add) || (keyCode == Keys.Oemplus)) // 0xbb { if (false == shiftKeyState) { game.InputEventGameSpeedIncrease( ); } } if ((keyCode == Keys.W) && (true == shiftKeyState)) { // SHIFT-W will write out a text file (c:\tetris_state.txt) game.InputEventGameStateWriteToFile( ); } if (keyCode == Keys.Next) // Page-Down { // Page-Down: Decrease Board Size game.InputEventGameBoardDecrease( ); } if (keyCode == Keys.Prior) // Page-Up { // Page-Up: Increase Board Size game.InputEventGameBoardIncrease( ); } if (true == controlKeyState) { if (keyCode == Keys.Up) { game.InputEventGameBoardIncreaseHeight( ); } if (keyCode == Keys.Left) { game.InputEventGameBoardDecreaseWidth( ); } if (keyCode == Keys.Right) { game.InputEventGameBoardIncreaseWidth( ); } if (keyCode == Keys.Down) { game.InputEventGameBoardDecreaseHeight( ); } } // COLOR SCHEME if ((keyCode == Keys.K) && (true == shiftKeyState)) { if (false == game.GetGameState( ).mMonochromeColorMode) { game.GetGameState( ).mMonochromeColorMode = true; } else { game.GetGameState( ).mMonochromeColorMode = false; } } // Non Video-Capture Options if (false == game.GameIsSpawnFromVideoCapture( )) { // Only respond to user piece-control input if AI is not active. if (false == game.GameIsAI( )) { if (false == controlKeyState) { if (keyCode == Keys.Up) { game.InputEventRotate( ); } if (keyCode == Keys.Left) { game.InputEventLeft( ); } if (keyCode == Keys.Right) { game.InputEventRight( ); } if (keyCode == Keys.Down) { game.InputEventDrop( ); } if (keyCode == Keys.Space) { game.InputEventDrop( ); } } } if (keyCode == Keys.Z) { if ((STPieceSequence.STPieceSelectionSource.AlternatingSAndZ) == game.GetPieceSequenceSourceType( )) { // Since we're in S/Z mode, stop. game.InputEventSZPieceModeStop( ); } else { // Start S/Z mode. game.InputEventSZPieceModeStart( ); } } if (keyCode == Keys.S) { // S will cycle the shadow mode. game.InputEventShadowModeCycle( ); } if ((keyCode == Keys.J) && (true == shiftKeyState)) { // SHIFT-J : Add line of random junk to bottom of the pile. game.InputEventAddRowOfJunk( ); } if ((keyCode == Keys.H) && (true == shiftKeyState)) { // SHIFT-H : Hint Mode if (true == game.GameIsHintMode( )) { game.InputEventHintModeStop( ); } else { game.InputEventHintModeStart( ); } } if (keyCode == Keys.N) { if (true == game.GameIsShowNextPiece( )) { game.InputEventShowNextPieceOff( ); } else { game.InputEventShowNextPieceOn( ); } } if (keyCode == Keys.X) { game.InputEventToggleMoveAnimation( ); } if (keyCode == Keys.U) { if (true == game.GameIsAutoRestart( )) { game.InputEventAutoRestartOff( ); } else { game.InputEventAutoRestartOn( ); } } if (keyCode == Keys.F) { game.InputEventToggleAutoWriteFile( ); } if ((keyCode == Keys.R) && (true == shiftKeyState)) { // SHIFT-R : Soft reset (game goes back to same random seed) game.InputEventSoftReset( ); } } }
private STTehnicFouls read_data() { STTehnicFouls ret = new STTehnicFouls(); string text; try { ret.idseason = idseason; if (textBoxId.Text.Length > 0) { ret.id = int.Parse(textBoxId.Text.Trim()); } else { ret.id = 0; } if (radioButtonPlayer.Checked == true) { ret.typepart = 0; char[] del = { ' ', '(', ')' }; string s = comboBoxPart.Text.Trim(); string[] words = s.Split(del); clPlayer = new CPlayer(connect, words[0].Trim(), words[1].Trim(), words[3].Trim()); ret.idpart = clPlayer.stPlayer.idplayer; } if (radioButtonCoach.Checked == true) { ret.typepart = 1; char[] del = { ' ', '(', ')' }; string s = comboBoxPart.Text.Trim(); string[] words = s.Split(del); clCoach = new CCoach(connect, words[0].Trim(), words[1].Trim(), words[3].Trim()); ret.idpart = clCoach.stCoach.idcoach; } if (comboBoxTeam.Text.Length > 0) { clTeam = new CTeam(connect, comboBoxTeam.Text.Trim()); ret.idteam = clTeam.stTeam.id; } if (textBoxNGame.Text.Length > 0) { ret.idgame = int.Parse(textBoxNGame.Text.Trim()); } else { ret.idgame = 0; } if (ret.idgame > 0) { STGame st = clGame.GetGame(idseason, ret.idgame); ret.date = new DateTime(st.datetime.Value.Year, st.datetime.Value.Month, st.datetime.Value.Day, 0, 0, 0, 0); } else { ret.date = DateTime.Now; } ret.descript = textBoxDescript.Text.Trim(); if (comboBoxReferee.Text.Length > 0) { ret.idreferee = get_referee(comboBoxReferee.Text.Trim()); } else { ret.idreferee = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
/* вспомогательные функции виз. отображения календаря */ private void init_list_add_row(STGame item, int i) { CTeam clTeam = new CTeam(connect); CPlace clPlace = new CPlace(connect); CDivision clDivision = new CDivision(connect); CGroup clGroup = new CGroup(connect); CCity clCity; string text = null; string team1 = null; string team2 = null; Color color = Color.Black; try { if (item.apoints > 0 && item.bpoints > 0) { color = Color.Black; } else { color = Color.Red; } dataGridViewGames.Rows[i].DefaultCellStyle.ForeColor = color; /* вставляем номер игры */ dataGridViewGames.Rows[i].Cells[1].Value = item.idgame; /* игра и результат */ if (item.idteam1 != null) { clTeam = new CTeam(connect, (int)item.idteam1); team1 = clTeam.stTeam.name; } if (item.idteam2 != null) { clTeam = new CTeam(connect, (int)item.idteam2); team2 = clTeam.stTeam.name; } text = string.Format("{0} {1} - {2} {3}", team1, item.apoints, item.bpoints, team2); /* выводим команды которые играют */ dataGridViewGames.Rows[i].Cells[2].Value = text; /* дата и время игры */ if (item.datetime != null) { DateTime dt = (DateTime)item.datetime; text = string.Format("{0} {1}:{2:00}", dt.ToLongDateString(), dt.Hour, dt.Minute); dataGridViewGames.Rows[i].Cells[3].Value = text; } /* место игры */ if (item.idplace != null) { clPlace = new CPlace(connect, (int)item.idplace); clCity = new CCity(connect, clPlace.stPlace.idcity); text = clPlace.stPlace.name; if (clCity.stFullCity.name != null) { text += string.Format(" ({0},{1})", clCity.stFullCity.name, clCity.stFullCity.shortnamecountry); } dataGridViewGames.Rows[i].Cells[4].Value = text; } /* группа */ if (item.idgroup != null) { clGroup = new CGroup(connect, (int)IS.idseason, (int)item.iddivision, (int)item.idgroup); text = string.Format("{0}", clGroup.stGroup.namegroup); dataGridViewGames.Rows[i].Cells[5].Value = text; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
public static bool WriteGameStateToFile ( String filePath, // e.g., C:\ or C:\foo String fileName, // e.g., tetris_state_YYYYMMDD_HHMMSSMMM.txt STGameState gameState ) { if (true == filePath.EndsWith("\\")) { filePath = filePath.Substring(0, (filePath.Length - 1)); } String filePathAndName = ""; filePathAndName = filePath + "\\" + fileName; STFileWriter file = new STFileWriter( ); bool successfullyOpenedFile = false; successfullyOpenedFile = file.Open(filePathAndName); if (false == successfullyOpenedFile) { return(false); } // Simply print out game state information to the text file. // The order of fields doesn't matter. Fields can be added // or removed. It is the consumer's responsibility to // acquire any fields and compensate for "missing" fields. // NOTE: Not all of these fields are intended to be restored // on loading. Many are DERIVED values, or are session-dependent, // or should be cleared upon loading to give the user the // chance to alter settings. For example, don't restore the // pause/unpaused state, or the video capture state. file.WriteText("fileName \"" + fileName + "\"\r\n"); file.WriteText("localDateAndTime \"" + GetDateStringYYYY_MMM_DD_HH_MM_SS_MMM( ) + "\"\r\n"); file.WriteText("standardTetrisVersion \"" + STGame.GetApplicationName( ) + "\"\r\n"); file.WriteText("\r\n"); file.WriteText("boardWidth " + gameState.mSTBoardCurrent.GetWidth( ) + "\r\n"); file.WriteText("boardHeight " + gameState.mSTBoardCurrent.GetHeight( ) + "\r\n"); file.WriteText("boardCurrent\r\n"); int width = 0; int height = 0; width = gameState.mSTBoardCurrent.GetWidth( ); height = gameState.mSTBoardCurrent.GetHeight( ); int x = 0; int y = 0; for (y = height; y >= 1; y--) // top-down { for (x = 1; x <= width; x++) { int cellShapeCode = 0; cellShapeCode = (int)gameState.mSTBoardCurrent.GetCell(x, y); file.WriteText(" " + String.Format("{0:d}", cellShapeCode)); } file.WriteText("\r\n"); } file.WriteText("\r\n"); file.WriteText("pieceCurrent\r\n"); file.WriteText("shape " + (int)gameState.mSTPieceCurrent.GetByteCodeValue( ) + "\r\n"); file.WriteText("x " + gameState.mSTPieceCurrent.GetX( ) + "\r\n"); file.WriteText("y " + gameState.mSTPieceCurrent.GetY( ) + "\r\n"); file.WriteText("orientation " + gameState.mSTPieceCurrent.GetOrientation( ) + "\r\n"); file.WriteText("\r\n"); int intValue = 0; if (true == gameState.mGameOver) { intValue = 1; } file.WriteText("gameOver " + intValue + "\r\n"); file.WriteText("iterationCountdownSeconds " + gameState.mIterationCountdownSeconds + "\r\n"); file.WriteText("currentPiecePointValue " + gameState.mCurrentPiecePointValue + "\r\n"); file.WriteText("completedRows " + gameState.mCompletedRows + "\r\n"); file.WriteText("\r\n"); file.WriteText("pieceSelectionSource " + (int)gameState.mSTPieceSequence.DirectGetPieceSelectionSource( ) + "\r\n"); file.WriteText("pieceSelectionShapeCurrent " + (int)gameState.mSTPieceSequence.DirectGetCurrentPieceShape( ) + "\r\n"); file.WriteText("pieceSelectionShapeNext " + (int)gameState.mSTPieceSequence.DirectGetNextPieceShape( ) + "\r\n"); file.WriteText("cachedRandomSeedUsedMostRecentlyToInitializeRandomGenerator " + gameState.mSTPieceSequence.DirectGetSeedUsedMostRecentlyToInitializeRandomNumberGenerator( ) + "\r\n"); file.WriteText("currentInternalRandomNumberGeneratorStateForPieceSequence " + gameState.mSTPieceSequence.DirectGetCurrentRandomNumberGeneratorInternalStateValue( ) + "\r\n"); int alternateSZState = 0; if (true == gameState.mSTPieceSequence.DirectGetAlternateSZState( )) { alternateSZState = 1; } file.WriteText("alternatingSZState " + alternateSZState + "\r\n"); file.WriteText("pieceSequenceTotalQueueElements " + gameState.mSTPieceSequence.DirectGetTotalQueueElements( ) + "\r\n"); file.WriteText("pieceSequenceQueueElements " + "\r\n"); int totalQueueElements = 0; totalQueueElements = gameState.mSTPieceSequence.DirectGetTotalQueueElements( ); int indexQueueElement = 0; for (indexQueueElement = 0; indexQueueElement < totalQueueElements; indexQueueElement++) { int queueElementValue = 0; queueElementValue = gameState.mSTPieceSequence.DirectGetQueueElementByIndex(indexQueueElement); file.WriteText(" " + String.Format("{0:d}", queueElementValue)); if (31 == (indexQueueElement % 32)) { file.WriteText("\r\n"); } } file.WriteText("\r\n"); file.WriteText("\r\n"); // User options intValue = 0; if (true == gameState.mPaused) { intValue = 1; } file.WriteText("paused " + intValue + "\r\n"); intValue = 0; if (true == gameState.mShowNextPiece) { intValue = 1; } file.WriteText("showNextPiece " + intValue + "\r\n"); intValue = 0; if (true == gameState.mAI) { intValue = 1; } file.WriteText("aiActive " + intValue + "\r\n"); intValue = 0; if (true == gameState.mSpawnFromVideoCapture) { intValue = 1; } file.WriteText("spawnFromVideoCapture " + intValue + "\r\n"); intValue = 0; if (true == gameState.mOutputToRS232) { intValue = 1; } file.WriteText("outputToRS232 " + intValue + "\r\n"); intValue = 0; if (true == gameState.mAutoRestart) { intValue = 1; } file.WriteText("autoRestart " + intValue + "\r\n"); intValue = 0; if (true == gameState.mAutoWriteFile) { intValue = 1; } file.WriteText("autoWriteFile " + intValue + "\r\n"); file.WriteText("gameSpeedAdjustment " + gameState.mGameSpeedAdjustment + "\r\n"); intValue = 0; if (true == gameState.mShadowMode) { intValue = 1; } file.WriteText("shadowMode " + intValue + "\r\n"); intValue = 0; if (true == gameState.mHintMode) { intValue = 1; } file.WriteText("hintMode " + intValue + "\r\n"); intValue = 0; if (true == gameState.mMonochromeColorMode) { intValue = 1; } file.WriteText("monochromeColorMode " + intValue + "\r\n"); // Currently-selected AI // (be sure to eliminate the double-quotes around the name when reading back in) file.WriteText("currentStrategyName " + "\"" + STStrategyManager.GetCurrentStrategyName( ) + "\"" + "\r\n"); // Statistics for User Consideration Only file.WriteText("\r\n"); file.WriteText("pieceHistogramLength " + (int)gameState.mPieceHistogram.Length + "\r\n"); file.WriteText("pieceHistogram " + "\r\n"); int i = 0; int n = 0; n = gameState.mPieceHistogram.Length; for (i = 0; i < n; i++) { file.WriteText(gameState.mPieceHistogram[i] + "\r\n"); } file.WriteText("\r\n"); file.WriteText("\r\n"); // Height histogram // (find highest index with a non-zero count, and only show indices // up to that index on their own lines, with all subsequent zero // values condensed with 32 such values on a single line) file.WriteText("heightHistogramLength " + (int)gameState.mHeightHistogram.Length + "\r\n"); file.WriteText("heightHistogram " + "\r\n"); int maxIndexWithNonZeroCount = (-1); n = gameState.mHeightHistogram.Length; for (i = 0; i < n; i++) { if (gameState.mHeightHistogram[i] > 0) { maxIndexWithNonZeroCount = i; } } for (i = 0; i <= maxIndexWithNonZeroCount; i++) { file.WriteText(gameState.mHeightHistogram[i] + "\r\n"); } int k = 0; for (i = (maxIndexWithNonZeroCount + 1); i < n; i++) { file.WriteText(gameState.mHeightHistogram[i] + " "); k++; if (0 == (k % 32)) { file.WriteText("\r\n"); } } file.WriteText("\r\n"); file.WriteText("\r\n"); file.WriteText("totalElapsedTimeSeconds " + gameState.mTotalElapsedTimeSeconds + "\r\n"); file.WriteText("score " + gameState.mScore + "\r\n"); file.WriteText("historicHighScore " + gameState.mHistoricHighScore + "\r\n"); file.WriteText("historicHighRows " + gameState.mHistoricHighRows + "\r\n"); file.WriteText("historicHighPieces " + gameState.mHistoricHighPieces + "\r\n"); file.WriteText("historicCumulativeRows " + gameState.mHistoricCumulativeRows + "\r\n"); file.WriteText("historicTotalGames " + gameState.mHistoricTotalGames + "\r\n"); file.WriteText("\r\n"); file.WriteText("historicRowsLength " + (int)gameState.mHistoricRows.Length + "\r\n"); file.WriteText("historicRows " + "\r\n"); n = gameState.mHistoricRows.Length; for (i = 0; i < n; i++) { file.WriteText(gameState.mHistoricRows[i] + "\r\n"); } file.WriteText("\r\n"); file.WriteText("\r\n"); // Derived or copied values file.WriteText("pieceNext\r\n"); file.WriteText("shape " + (int)gameState.mSTPieceNext.GetByteCodeValue( ) + "\r\n"); file.WriteText("x " + gameState.mSTPieceNext.GetX( ) + "\r\n"); file.WriteText("y " + gameState.mSTPieceNext.GetY( ) + "\r\n"); file.WriteText("orientation " + gameState.mSTPieceNext.GetOrientation( ) + "\r\n"); file.WriteText("\r\n"); file.WriteText("pieceBestMove\r\n"); file.WriteText("shape " + (int)gameState.mSTPieceBestMove.GetByteCodeValue( ) + "\r\n"); file.WriteText("x " + gameState.mSTPieceBestMove.GetX( ) + "\r\n"); file.WriteText("y " + gameState.mSTPieceBestMove.GetY( ) + "\r\n"); file.WriteText("orientation " + gameState.mSTPieceBestMove.GetOrientation( ) + "\r\n"); file.WriteText("\r\n"); // state of animation of a an AI-executed move intValue = 0; if (true == gameState.mAnimateAIMovesEnable) { intValue = 1; } file.WriteText("animateAIMovesEnable " + intValue + "\r\n"); file.WriteText("animateAIMovesStartingY " + gameState.mAnimateAIMovesStartingY + "\r\n"); file.WriteText("animateAIMovesFinalSafeY " + gameState.mAnimateAIMovesFinalSafeY + "\r\n"); file.WriteText("animateAITotalInitialCommands " + gameState.mAnimateAITotalInitialCommands + "\r\n"); file.WriteText("animateAICommandsExecuted " + gameState.mAnimateAICommandsExecuted + "\r\n"); file.WriteText("animateAICommandsPerRow " + gameState.mAnimateAICommandsPerRow + "\r\n"); file.WriteText("animateAIMovesPendingRotation " + gameState.mAnimateAIMovesPendingRotation + "\r\n"); file.WriteText("animateAIMovesPendingTranslation " + gameState.mAnimateAIMovesPendingTranslation + "\r\n"); // Derived values // Scaled height histogram file.WriteText("\r\n"); file.WriteText("\r\n"); long sumOfCounts = 0; n = gameState.mHeightHistogram.Length; for (i = 0; i < n; i++) { sumOfCounts += gameState.mHeightHistogram[i]; } if (sumOfCounts > 0) { file.WriteText("scaledHistogramOfPileHeights " + "\r\n"); double fraction = 0.0; for (i = 0; i <= maxIndexWithNonZeroCount; i++) { fraction = ((double)gameState.mHeightHistogram[i] / (double)sumOfCounts); file.WriteText("" + fraction + "\r\n"); } } file.WriteText("\r\n"); file.WriteText("\r\n"); file.Close( ); return(true); }
private STLoadFileInfo write_file(string filename) { STStats stStats; STLoadFileInfo ret = new STLoadFileInfo(); try { ret.iErrorCode = 0; CSmartStats clSS = new CSmartStats(filename); STGame stGame = clSS.stGame; // вычисляем дивизион CGame clGame = new CGame(connect); STGame rgame = clGame.GetGame(IS.idseason, stGame.idgame); int iddiv = (int)rgame.iddivision; lst_records = clRecords.GetRecords(iddiv); // Записываем игру clGame.UpdateSGM(stGame, stGame.idseason, stGame.idgame); // Записываем статистику CStats clStats = new CStats(connect); List <STStats> lst = clSS.stStatsTeam1; foreach (STStats item in lst) { if (item.ptime > 0) { stStats = verify_player(item); verify_records(stStats); clStats.Insert(stStats); } } lst = clSS.stStatsTeam2; foreach (STStats item in lst) { if (item.ptime > 0) { stStats = verify_player(item); verify_records(stStats); clStats.Insert(stStats); } } // Записываем карту бросков CCardTrow clCardTrow = new CCardTrow(connect); STCardTrow card = clSS.stCardTrow1; clCardTrow.Insert(card); card = clSS.stCardTrow2; clCardTrow.Insert(card); // Записываем статистику тренеров CStatsCoach clStatCoach = new CStatsCoach(connect); STStatsCoach coach = clSS.stCoach1; clStatCoach.Insert(coach); coach = clSS.stCoach2; clStatCoach.Insert(coach); // Записываем статистику судей CStatsReferee clStatReferee = new CStatsReferee(connect); STStatsReferee referee = clSS.stReferee1_t1; clStatReferee.Insert(referee); referee = clSS.stReferee1_t2; clStatReferee.Insert(referee); referee = clSS.stReferee2_t1; clStatReferee.Insert(referee); referee = clSS.stReferee2_t2; clStatReferee.Insert(referee); referee = clSS.stStReferee_t1; clStatReferee.Insert(referee); referee = clSS.stStReferee_t2; clStatReferee.Insert(referee); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private void PrepareEditGame(STGame data) { string text; try { /* номер игры */ textBoxNum.Text = data.idgame.ToString(); /* дата\врем¤ игры */ if (data.datetime != null) { dateTimePickerDate.Value = new DateTime(data.datetime.Value.Year, data.datetime.Value.Month, data.datetime.Value.Day, 0, 0, 0, 0); dateTimePickerTime.Value = new DateTime(data.datetime.Value.Year, data.datetime.Value.Month, data.datetime.Value.Day, data.datetime.Value.Hour, data.datetime.Value.Minute, 0, 0); } /* дивизион */ if (data.iddivision != null) { clDivision = new CDivision(connect, IS.idseason, (int)data.iddivision); comboBoxDivision.Text = clDivision.stDiv.name; } /* стади¤ */ if (data.idstage != null) { clScheme = new CScheme(connect, IS.idseason, (int)data.iddivision, (int)data.idstage); comboBoxStage.Text = clScheme.stScheme.namestage; } /* группа */ if (data.idgroup != null) { clGroup = new CGroup(connect, IS.idseason, (int)data.iddivision, (int)data.idgroup); comboBoxGroup.Text = clGroup.stGroup.namegroup; } /* номер тура */ if (data.round != null) { comboBoxRound.Text = data.round.ToString(); } /* площадка */ if (data.idplace != null) { clPlace = new CPlace(connect, (int)data.idplace); comboBoxPlace.Text = clPlace.stPlace.name; } /* команда 1 */ if (data.idteam1 != null) { clTeam = new CTeam(connect, (int)data.idteam1); comboBoxTeam1.Text = clTeam.stTeam.name; } /* команда 2 */ if (data.idteam2 != null) { clTeam = new CTeam(connect, (int)data.idteam2); comboBoxTeam2.Text = clTeam.stTeam.name; } /* данный команд */ if (data.aper1 != null) { textBoxAPer1.Text = data.aper1.ToString(); } if (data.aper2 != null) { textBoxAPer2.Text = data.aper2.ToString(); } if (data.adopper != null) { textBoxADopPer.Text = data.adopper.ToString(); } if (data.ateamfouls1 != null) { textBoxAF1.Text = data.ateamfouls1.ToString(); } if (data.ateamfouls2 != null) { textBoxAF2.Text = data.ateamfouls2.ToString(); } if (data.ateamfouls3 != null) { textBoxAF3.Text = data.ateamfouls3.ToString(); } if (data.ateamfouls4 != null) { textBoxAF4.Text = data.ateamfouls4.ToString(); } if (data.bper1 != null) { textBoxBPer1.Text = data.bper1.ToString(); } if (data.bper2 != null) { textBoxBPer2.Text = data.bper2.ToString(); } if (data.bdopper != null) { textBoxBDopPer.Text = data.bdopper.ToString(); } if (data.bteamfouls1 != null) { textBoxBF1.Text = data.bteamfouls1.ToString(); } if (data.bteamfouls2 != null) { textBoxBF2.Text = data.bteamfouls2.ToString(); } if (data.bteamfouls3 != null) { textBoxBF3.Text = data.bteamfouls3.ToString(); } if (data.bteamfouls4 != null) { textBoxBF4.Text = data.bteamfouls4.ToString(); } if (data.apointsper1 != null) { textBoxAPoints1.Text = data.apointsper1.ToString(); } if (data.apointsper2 != null) { textBoxAPoints2.Text = data.apointsper2.ToString(); } if (data.apointsper3 != null) { textBoxAPoints3.Text = data.apointsper3.ToString(); } if (data.apointsper4 != null) { textBoxAPoints4.Text = data.apointsper4.ToString(); } if (data.apointsdopper != null) { textBoxADopPoints.Text = data.apointsdopper.ToString(); } if (data.apoints != null) { textBoxAPoints.Text = data.apoints.ToString(); } if (data.bpointsper1 != null) { textBoxBPoints1.Text = data.bpointsper1.ToString(); } if (data.bpointsper2 != null) { textBoxBPoints2.Text = data.bpointsper2.ToString(); } if (data.bpointsper3 != null) { textBoxBPoints3.Text = data.bpointsper3.ToString(); } if (data.bpointsper4 != null) { textBoxBPoints4.Text = data.bpointsper4.ToString(); } if (data.bpointsdopper != null) { textBoxBDopPoints.Text = data.bpointsdopper.ToString(); } if (data.bpoints != null) { textBoxBPoints.Text = data.bpoints.ToString(); } /* флаг технического результата */ if (data.flagteh != null) { if (data.flagteh == 1) { checkBoxTeh.Checked = true; } } /* команда - победитель */ if (data.idteamwins != null) { clTeam = new CTeam(connect, (int)data.idteamwins); labelTeamWins.Text = clTeam.stTeam.name; } /* судьи */ if (data.idstreferee != null) { clReferee = new CReferee(connect, (int)data.idstreferee); text = string.Format("{0} {1}", clReferee.stRef.family, clReferee.stRef.name); comboBoxStReferee.Text = text; } if (data.idreferee1 != null) { clReferee = new CReferee(connect, (int)data.idreferee1); text = string.Format("{0} {1}", clReferee.stRef.family, clReferee.stRef.name); comboBoxReferee1.Text = text; } if (data.idreferee2 != null) { clReferee = new CReferee(connect, (int)data.idreferee2); text = string.Format("{0} {1}", clReferee.stRef.family, clReferee.stRef.name); comboBoxReferee2.Text = text; } /* оценки судь¤м */ if (data.srrefereepoints != null) { textBoxPointsStrefree.Text = data.srrefereepoints.ToString(); } if (data.referee1points != null) { textBoxPointsReferee1.Text = data.referee1points.ToString(); } if (data.referee2points != null) { textBoxPointsReferee2.Text = data.referee2points.ToString(); } /* секретарь */ if (data.idwriting != null) { clParticipant = new CParticipant(connect, (int)data.idwriting); text = string.Format("{0} {1}", clParticipant.stPart.family, clParticipant.stPart.name); comboBoxSecretar.Text = text; } /* секретарь */ if (data.idoperpanel != null) { clParticipant = new CParticipant(connect, (int)data.idoperpanel); text = string.Format("{0} {1}", clParticipant.stPart.family, clParticipant.stPart.name); comboBoxOperPanel.Text = text; } /* видеооператор */ if (data.idopervideo != null) { clParticipant = new CParticipant(connect, (int)data.idopervideo); text = string.Format("{0} {1}", clParticipant.stPart.family, clParticipant.stPart.name); comboBoxOperVideo.Text = text; } /* врач */ if (data.idmedical != null) { clParticipant = new CParticipant(connect, (int)data.idmedical); text = string.Format("{0} {1}", clParticipant.stPart.family, clParticipant.stPart.name); comboBoxMedic.Text = text; } /* диктор */ if (data.iddiktor != null) { clParticipant = new CParticipant(connect, (int)data.iddiktor); text = string.Format("{0} {1}", clParticipant.stPart.family, clParticipant.stPart.name); comboBoxDiktor.Text = text; } /* подсчЄт статистики */ if (data.idstatister != null) { clParticipant = new CParticipant(connect, (int)data.idstatister); text = string.Format("{0} {1}", clParticipant.stPart.family, clParticipant.stPart.name); comboBoxStatist.Text = text; } /* остальна¤ статистика */ if (data.cntlook != null) { textBoxCntLook.Text = data.cntlook.ToString(); } if (data.changelider != null) { textBoxChangeLider.Text = data.changelider.ToString(); } if (data.maxpointsteam1 != null) { textBoxMaxPointsA.Text = data.maxpointsteam1.ToString(); } if (data.maxpointsteam2 != null) { textBoxMaxPointsB.Text = data.maxpointsteam2.ToString(); } if (data.equalsresult != null) { textBoxEqualsResult.Text = data.equalsresult.ToString(); } if (data.maxdiff != null) { textBoxMaxDiff.Text = data.maxdiff.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }