private void EditPropertiesMarker(object sender, EventArgs e) { if (dataGridView1.SelectedItems.Count == 1 && GetDataGrid().SelectedItems[0].Tag is Game.Marker) { Marker mk = (Game.Marker)GetDataGrid().SelectedItems[0].Tag; var mke = new Game.Marker(game); mke.Assign(mk); var mef = new MarkerEditForm(); mef.Edit(mke); if (mef.ShowDialog() == System.Windows.Forms.DialogResult.OK) { mk.Assign(mke); mk.FlagUpdate = true; UpdateGridView((Game.Marker)mk); try { game.SaveLocal(); } catch (Exception ex) { } } } }
//Marker 1 private void radioButton13_CheckedChanged(object sender, EventArgs e) { var rb = (RadioButton)sender; var action_type = Convert.ToInt32(rb.Tag); Result1 = new Game.Marker(Marker.game, 9, action_type) { Half = Marker.Half, TimeVideo = Marker.TimeVideo, Player1 = Marker.Player1 }; }
private void button3_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { import_process = true; UpdateUI(); ShowStatus("Send FOUL to instatfootball.com...", 0); if (player_foul_del > 1) { var mk = new Game.Marker(game, 5, player_foul_del, game.Half, -1) { Player1 = player_foul1, TimeActualSrv = game.Time }; Web.SaveMarker(game, mk); game.Insert(mk); } if (player_foul_disc > 5) { var mk = new Game.Marker(game, 5, player_foul_disc, game.Half, -1) { Player1 = player_foul1, TimeActualSrv = game.Time }; Web.SaveMarker(game, mk); game.Insert(mk); } var mk1 = new Game.Marker(game, 9, player_foul_type, game.Half, -1) { Player1 = player_foul1, TimeActualSrv = game.Time }; Web.SaveMarker(game, mk1); game.Insert(mk1); game.SaveLocal(); ShowStatus("Success", 0); } catch (Exception ex) { ShowStatus(ex.Message, 1); } finally { import_process = false; ReloadDataGridView(); UpdateUI(); } }); }
/// <summary> /// Получить список действий для маркера. /// </summary> /// <param name="marker">Список маркеров.</param> /// <returns>Возвращает список действий, если маркер есть. Иначе null.</returns> public static List <StageEnum> GetMarkersStage(Game.Marker marker) { var action_id = marker.ActionId; var action_type = marker.ActionType; var win = marker.Win; var markerModel = markerModels.FirstOrDefault(x => x.Compare(action_id, action_type, win)); if (markerModel != null) { return(GetMyMarkerStage(markerModel)); } return(null); }
public FoulTypeForm(Marker mk) { InitializeComponent(); Marker = (Game.Marker)mk; Result1 = new Game.Marker(Marker.game, 9, 1) { Half = mk.Half, TimeVideo = mk.TimeVideo, Player1 = mk.Player1 }; Result2 = null; groupBox1.Text = PlayerNameFormat(mk.Player1); groupBox2.Text = PlayerNameFormat(mk.Player2); }
public static void SetInviteLabel(ModeEnum newmode, Game.Marker mk, string text, Label inviteLabel) { HockeyGui.SetMode(newmode, mk); if (mk != null) { inviteLabel.Visible = true; inviteLabel.Text = text; } else { inviteLabel.Visible = false; } }
public void UpdateGridView(Game.Marker mk) { sync.Execute(() => { lock (locker) { if (mk.FlagGuiUpdate && mk.row != null) { FillRow(mk); mk.FlagGuiUpdate = false; } locker = new object(); } }); }
private void button2_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { import_process = true; UpdateUI(); ShowStatus("Send ASSISTS to instatfootball.com...", 0); if (player_assist1 != null) { var mk = new Game.Marker(game, 1, 2, game.Half, -1) { Player1 = player_assist1, TimeActualSrv = game.Time }; Web.SaveMarker(game, mk); game.Insert(mk); } if (player_assist2 != null) { var mk = new Game.Marker(game, 1, 2, game.Half, -1) { Player1 = player_assist2, TimeActualSrv = game.Time }; Web.SaveMarker(game, mk); game.Insert(mk); } game.SaveLocal(); ShowStatus("Success", 0); } catch (Exception ex) { ShowStatus(ex.Message, 1); } finally { import_process = false; ReloadDataGridView(); UpdateUI(); } }); }
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e) { if (dataGridView1.SelectedItems.Count > 0) { var mk = (Game.Marker)dataGridView1.SelectedItems[0].Tag; var mke = new Game.Marker(game); mke.Assign(mk); var mef = new MarkerEditForm(); mef.Edit(mke); if (mef.ShowDialog() == System.Windows.Forms.DialogResult.OK) { mk.Assign(mke); mk.FlagUpdate = true; Task.Factory.StartNew(() => { try { import_process = true; UpdateUI(); ShowStatus("UPDATE instatfootball.com...", 0); Web.SaveMarker(game, mk); ShowStatus("Success", 0); } catch (Exception ex) { ShowStatus(ex.Message, 1); } finally { import_process = false; ReloadDataGridView(); UpdateUI(); } }); } } }
//public void SetStages(IEnumerable<StageEnum> stages) //{ // Stages = new List<StageEnum>(stages); //} public List <Game.Marker> GenerateMarkers(Game.Marker copyMarkerInfo) { var res = new List <Game.Marker>(); if (Pair) { Game.Marker mk1 = null; Game.Marker.CopyMarkerData(copyMarkerInfo, out mk1); mk1.ActionId = 9; mk1.ActionType = this.ActionType; mk1.Win = 0; res.Add(mk1); // Другие игроки, поменялись местами! Game.Marker mk2 = null; Game.Marker.CopyMarkerData(copyMarkerInfo, out mk2); mk2.ActionId = 9; mk2.ActionType = this.ActionType; mk2.Win = 0; // меняем игроков. var player = mk2.Player1; mk2.Player1 = mk2.Player2; mk2.Player2 = player; res.Add(mk2); } else { Game.Marker mk = null; Game.Marker.CopyMarkerData(copyMarkerInfo, out mk); mk.ActionId = 9; mk.ActionType = this.ActionType; mk.Win = 0; res.Add(mk); } return(res); }
public FineForm(Game.Marker marker, Player player) { InitializeComponent(); this.marker = marker; radioButton1.Enabled = marker.player2_id > 0; radioButton2.Enabled = marker.player2_id > 0; radioButton3.Enabled = marker.player2_id > 0; radioButton4.Enabled = marker.player2_id > 0; radioButton5.Enabled = marker.player2_id > 0; radioButton6.Enabled = marker.player2_id > 0; radioButton7.Enabled = marker.player2_id == 0; radioButton8.Enabled = marker.player2_id > 0; radioButton9.Enabled = marker.player2_id > 0; radioButton10.Enabled = marker.player2_id == 0; radioButton11.Enabled = marker.player2_id > 0; radioButton12.Enabled = marker.player2_id > 0; radioButton13.Enabled = marker.player2_id > 0; radioButton14.Enabled = marker.player2_id == 0; if (marker.player2_id == 0) { radioButton7.Checked = true; } foulPlayer = player; checkBox1.Enabled = marker.player2_id > 0 && foulPlayer == marker.Player1; if (foulPlayer != null) { label1.Text = foulPlayer.ToString(); LoadPlayers(false); } else { groupBox1.Enabled = false; groupBox2.Enabled = false; groupBox3.Enabled = false; } UpdateUI(); }
public MyPenaltyForm(Game.Marker marker, Player player) { InitializeComponent(); this.marker = marker; foulPlayer = player; if (foulPlayer != null) { label1.Text = foulPlayer.ToString(); LoadPlayers(); } else { groupBox2.Enabled = false; groupBox3.Enabled = false; } UpdateUI(); }
/// <summary> /// Добавить или Убрать в prevMarker дополнительный newMarker. Возможность добавлять СТРОГО один дополнительный маркер. /// </summary> /// <param name="prevMarker">Исходный маркер, в который можно добавить новый.</param> /// <param name="newMarker">Новый маркер.</param> public static void AddSingleNewExtraMarker(Game.Marker prevMarker, Game.Marker newMarker) { if (prevMarker == null || newMarker == null) { return; } var alreadyAddedMarker = prevMarker.flag_adding.FirstOrDefault( o => o.Compare(newMarker.ActionId, newMarker.ActionType, newMarker.Win)); // Если уже есть такой маркер, то выпиливаем его. if (alreadyAddedMarker != null) { prevMarker.flag_adding.Remove(alreadyAddedMarker); } // Иначе очищаем списокдоп.маркеров и запихивает новый маркер. else { prevMarker.flag_adding.Clear(); prevMarker.flag_adding.Add(newMarker); } }
private int CompareMarkersTime(Game.Marker ma, Game.Marker mb) { if (ma.TimeVideo > mb.TimeVideo) { return(1); } if (ma.TimeVideo < mb.TimeVideo) { return(-1); } if (ma.TimeActual > mb.TimeActual) { return(1); } if (ma.TimeActual < mb.TimeActual) { return(-1); } return(0); }
public static void CopyMarkerData(Game.Marker copyFrom, out Game.Marker newMarker) { newMarker = new Marker(copyFrom.game) { user_id = copyFrom.user_id, flag_adding = copyFrom.flag_adding, Half = copyFrom.Half, ActionCode = copyFrom.ActionCode, ActionType = copyFrom.ActionType, Win = copyFrom.Win, TimeVideo = copyFrom.TimeVideo, TimeVideoReal = copyFrom.TimeVideoReal, TimeActual = copyFrom.TimeActual, TimeActualSrv = copyFrom.TimeActualSrv, TimeActualTotal = copyFrom.TimeActualTotal, Player1 = copyFrom.Player1, Player2 = copyFrom.Player2, Point1 = copyFrom.Point1, Point2 = copyFrom.Point2, Num = copyFrom.Num, NumTeam1 = copyFrom.NumTeam1, NumTeam2 = copyFrom.NumTeam2, }; }
/// <summary> /// Добавить новый ИЛИ убрать предыдущее вхождение нового маркера ИЛИ переключить на новый дочерний маркер в prevMarker дополнительный newMarker. Возможность добавлять СТРОГО один дополнительный маркер. /// </summary> /// <param name="marker">Исходный маркер, в который можно добавить новый.</param> /// <param name="extraMarker">Новый дочерний маркер.</param> public static void XorAddSingleNewExtraMarker(Game.Marker marker, Game.Marker extraMarker) { // Если еще не пустой. if (marker.flag_adding.Any()) { // Проверяем, если пытаемся добавить тот же самый, то вырубаем его. if (marker.flag_adding.Any(x => x.Compare(extraMarker.ActionId, extraMarker.ActionType, extraMarker.Win))) { marker.flag_adding.Clear(); } // Иначе в нем был какой-то другой. else { marker.flag_adding.Clear(); marker.flag_adding.Add(extraMarker); } } // Иначе, если пустой. else { marker.flag_adding.Add(extraMarker); } }
/*registrator_ask_f_match_event * * Параметры: * @match_id int - id матча * @dl tinyint - 1 - выдать все маркеры, включая удаленные, 0 - только не удаленные * * Возвращает поля: * id - id записи * half - номер тайма * second - секунда * c_action - id действия * action_name - наименование действия * f_team - id команды * team_name - наименование команды * f_player - id игрока * player_name - имя+фамилия игрока * opponent_f_team - id команды оппонента * opponent_team_name - наименование команды оппонента * opponent_f_player - id игрока-оппонента * opponent_player_name - имя+фамилия игрока-оппонента * pos_x * pos_y * opponent_pos_x * opponent_pos_y * f_user - id последнего изменившего запись пользователя * user_name - имя+фамилия последнего изменившего запись пользователя * dl - флаг удаления записи */ public static List <Marker> GetMarkers(Uniso.InStat.Game.HockeyIce game, int match_id) { var datain = new Dictionary <string, object>(); datain.Add("match_id", match_id); datain.Add("dl", 0); string rqst; var req = Request(HOCK_PRE, "registrator_ask_f_match_event", datain, new Dictionary <string, object>(), out rqst); var objlist = (object[])req["data"]; var res = new List <Marker>(); foreach (Dictionary <string, object> u in objlist) { try { var period = Convert.ToInt32(u["half"]); var half = game.HalfList.FirstOrDefault(o => o.Index == period); if (half == null) { throw new Exception(String.Format("Указанный период игры ({0}) не найден в системе", period)); } var c_action = Convert.ToInt32(u["c_action"]); var sync = 0; if (u.ContainsKey("data2_int")) { sync = Convert.ToInt32(u["data2_int"]); } var mk = new Game.Marker(game) { Id = Convert.ToInt32(u["id"]), ActionCode = c_action, Half = half, Link = u.ContainsKey("link") && u["link"] != null?Convert.ToInt32(u["link"]) : 0, player1_id = u["f_player"] != null?Convert.ToInt32(u["f_player"]) : 0, team1_id = u["f_team"] != null?Convert.ToInt32(u["f_team"]) : 0, player2_id = u["opponent_f_player"] != null?Convert.ToInt32(u["opponent_f_player"]) : 0, team2_id = u["opponent_f_team"] != null?Convert.ToInt32(u["opponent_f_team"]) : 0, Point1 = new System.Drawing.PointF { X = u["pos_x"] != null?Convert.ToSingle(u["pos_x"]) : 0, Y = u["pos_y"] != null?Convert.ToSingle(u["pos_y"]) : 0, }, Point2 = new System.Drawing.PointF { X = u["opponent_pos_x"] != null?Convert.ToSingle(u["opponent_pos_x"]) : 0, Y = u["opponent_pos_y"] != null?Convert.ToSingle(u["opponent_pos_y"]) : 0, }, user_id = u["f_user"] != null?Convert.ToInt32(u["f_user"]) : 0, Sync = sync, }; if (u.ContainsKey("second_clear") && u["second_clear"] != null) { try { var sav = 0.0f; var sa = u["second_clear"].ToString().Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator); if (Single.TryParse(sa, out sav)) { mk.TimeActualSrv = Convert.ToInt32(sav * 1000f); } } catch { } } if (Game.HockeyIce.Role == Game.HockeyIce.RoleEnum.Online) { if (!mk.Compare(1, 1) && !mk.Compare(1, 2) && !mk.Compare(3, 8) && !mk.Compare(8, 1) && !mk.Compare(5) && !mk.Compare(9) && !mk.Compare(3, 1) && !mk.Compare(16) && !mk.Compare(18)) { continue; } if (mk.Compare(18, 9)) { continue; } } var time1 = -1; if (u.ContainsKey("second") && u["second"] != null) { time1 = Convert.ToInt32(Convert.ToSingle(u["second"].ToString().Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator)) * 1000f); } var time2 = -1; if (u.ContainsKey("second_online") && u["second_online"] != null) { time2 = Convert.ToInt32(Convert.ToSingle(u["second_online"].ToString().Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator)) * 1000f); } mk.TimeVideoReal = Game.HockeyIce.Role == Game.HockeyIce.RoleEnum.Online ? time2 : time1; if (u.ContainsKey("players_num_team1")) { mk.NumTeam1 = Convert.ToInt32(u["players_num_team1"]); } if (u.ContainsKey("players_num_team2")) { mk.NumTeam2 = Convert.ToInt32(u["players_num_team2"]); } if (u.ContainsKey("data1_int")) { mk.Num = Convert.ToInt32(u["data1_int"]); } res.Add(mk); } catch (Exception ex) { Log.WriteException(ex); throw new Exception("Ошибка в формате данных registrator_ask_f_match_event"); } } return(res); }
private void dataGridView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && dataGridView1.SelectedItems.Count > 0) { if (MessageBox.Show(String.Format("Удалить маркеры ({0}) ?", dataGridView1.SelectedItems.Count), "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { return; } var del = new List <Marker>(); foreach (ListViewItem row in dataGridView1.SelectedItems) { var mk = (Game.Marker)row.Tag; del.Add(mk); } Task.Factory.StartNew(() => { try { import_process = true; UpdateUI(); ShowStatus("DELETE from instatfootball.com...", 0); var tasks = new List <Task>(); Exception exception = null; foreach (Game.Marker mk in del) { tasks.Add(Task.Factory.StartNew(() => { try { var mk1 = new Game.Marker(game); mk1.Assign(mk); mk1.FlagDel = !mk.FlagDel; Web.SaveMarker(game, mk1); lock (game.Markers) game.Markers.Remove(mk); } catch (Exception ex) { exception = ex; } })); } Task.WaitAll(tasks.ToArray <Task>()); if (exception != null) { throw exception; } ShowStatus("Success", 0); } catch (Exception ex) { ShowStatus(ex.Message, 1); } finally { import_process = false; ReloadDataGridView(); UpdateUI(); } }); } }
/*registrator_save_del_f_match_event * * Параметры: * @action tinyint - 1 - сохранить, 2 - удалить * @id int - id маркера (для сохранения и удаления) * @match_id int - id матча * @half tinyint - номер тайма * @second float - секунда * @c_action int - id действия * @f_team int - id команды * @f_player int - id игрока * @opponent_f_team int - id команды оппонента * @opponent_f_player int - id игрока-оппонента * @pos_x float - позиция точки (X) * @pos_y float - позиция точки (Y) * @opponent_pos_x float - позиция точки назначения (X) * @opponent_pos_y float - позиция точки назначения (Y) * @c_zone tinyint - id зоны * @opponent_c_zone tinyint - id зоны назначения * @f_user int - id пользователя, сохраняющего/удаляющего данные * @ret int OUTPUT - результат операции: вернет id маркера при удаче и отрицательное значение при ошибке * @msg varchar(500) OUTPUT - вернет текст ошибки */ public static void SaveMarker(Game.HockeyIce game, Game.Marker mk) { if (mk.Compare(3, new int[] { 1, 2 }) || mk.Compare(8, 1)) { mk.Win = 0; } var datain = new Dictionary <string, object>(); datain.Add("action", mk.FlagDel ? 2 : 1); if (mk.Id > 0) { datain.Add("id", mk.Id); } datain.Add("match_id", game.Match.Id); datain.Add("half", mk.Half.Index); var time = Math.Round((float)mk.TimeVideoReal / 1000f, 3); if (Uniso.InStat.Game.HockeyIce.Role == Game.HockeyIce.RoleEnum.Online && !mk.Compare(18) && !mk.Compare(16)) { datain.Add("second_online", time); } else { datain.Add("second", time); } datain.Add("second_clear", Math.Round((float)mk.TimeActual / 1000f, 3)); datain.Add("c_action", mk.ActionCode); if (mk.Team1 != null) { datain.Add("f_team", mk.Team1.Id); } if (mk.Player1 != null) { datain.Add("f_player", mk.Player1.Id); } if (mk.Team2 != null) { datain.Add("opponent_f_team", mk.Team2.Id); } if (mk.Player2 != null) { datain.Add("opponent_f_player", mk.Player2.Id); } if (!mk.Point1.IsEmpty) { datain.Add("pos_x", mk.Point1.X); datain.Add("pos_y", mk.Point1.Y); } if (!mk.Point2.IsEmpty) { datain.Add("opponent_pos_x", mk.Point2.X); datain.Add("opponent_pos_y", mk.Point2.Y); } datain.Add("data1_int", mk.Num); datain.Add("data2_int", mk.Sync); datain.Add("f_user", mk.user_id); datain.Add("link", mk.Link); // TODO: Вот тут в datain добавлять свойства маркера. var dataout = new Dictionary <string, object>(); dataout.Add("ret", "int"); dataout.Add("msg", "varchar(500)"); var rqst = String.Empty; var req = Request(HOCK_PRE, "registrator_save_del_f_match_event_2", datain, dataout, out rqst); if (!req.ContainsKey("variables")) { throw new Exception("Error parsing saving"); } var vars = (Dictionary <string, object>)req["variables"]; if (!vars.ContainsKey("@ret")) { throw new Exception("Error parsing saving"); } var ret = Convert.ToInt32(vars["@ret"]); if (ret <= 0) { throw new Exception("Ошибка при сохранении маркера. MESSAGE: " + Convert.ToString(vars["@msg"])); } mk.Id = ret; mk.FlagUpdate = false; }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { var lst = new List <ListViewItem>(); foreach (ListViewItem item in dataGridView1.SelectedItems) { lst.Add(item); } if (lst.Count > 0) { var row = lst[0]; if (row.Tag is Marker) { var mk = (Game.Marker)row.Tag; if (mk.Compare(1, 1) && mk.Player1 == null && mk.Player2 == null) { mainForm.ProcessingMarker(mk); return; } if (mk.Compare(6, 1) && mk.Player1 == null && mk.Player2 == null) { mainForm.ProcessingMarker(mk); return; } if (mk.Compare(8, 1) && mk.Point1.IsEmpty) { mk.Point2 = Point.Empty; mainForm.ProcessingMarker(mk); return; } if (mk.ActionId == 5 && mk.ActionType > 1 && mk.Num == 0 && HockeyIce.Role != HockeyIce.RoleEnum.Ttd) { lock (game.Markers) { if (!game.Markers.Any(o => !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo > mk.TimeVideo - 100 && o.TimeVideo < mk.TimeVideo + 100 && o.ActionId == 14 && o.player2_id == mk.player1_id)) { mk.FlagUpdate = true; var placemk = mk.Player1.Team.Tactics[0].GetPlace(mk.Player1); if (placemk == null) { foreach (var t in mk.Player1.Team.Tactics.Values) { placemk = t.GetPlace(mk.Player1); if (placemk != null) { break; } } } if (placemk != null) { if (MessageBox.Show("Установить маркер выхода с площадки для игрока " + mk.Player1, "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { return; } var mkc = new Game.Marker(game, 14, placemk.GetCode(), mk.Half, mk.TimeVideo) { Player1 = null, Player2 = mk.Player1 }; Log.Write((string)("INSERT FINE " + mkc.Player1)); game.Insert(mkc); ReloadDataGridView(false); return; } } } return; } mainForm.Second = mk.TimeVideo - 1500; } } }
private void FillRow(Game.Marker mk) { if (mk.row == null) { mk.row = new System.Windows.Forms.ListViewItem(mk.Id.ToString()); for (var i = 1; i < 10; i++) { try { mk.row.SubItems.Add(String.Empty); } catch { } } } else { mk.row.SubItems[0].Text = mk.Id.ToString(); } var action = mk.Action; var name = Convert.ToString(HockeyIce.convAction.ConvertTo(action, typeof(string))); if (game.IsRestoreTimeMarker(mk) || game.IsStopTimeMarker(mk)) { mk.row.Font = new System.Drawing.Font(Font, FontStyle.Italic); } else { mk.row.Font = Font; } var time = game.TimeToString(mk.TimeVideo); if (Options.G.Game_ShowActualTime) { time += "/" + game.TimeToString(mk.TimeActual); } mk.row.SubItems[1].Text = name; mk.row.SubItems[2].Text = mk.Half.ToString(); mk.row.SubItems[3].Text = time; mk.row.SubItems[4].Text = mk.Player1 != null?mk.Player1.ToString() : "NULL"; mk.row.SubItems[5].Text = mk.Team1 != null?mk.Team1.ToString() : ""; mk.row.SubItems[6].Text = mk.Player2 != null?mk.Player2.ToString() : "NULL"; mk.row.SubItems[7].Text = mk.Team2 != null?mk.Team2.ToString() : ""; mk.row.SubItems[8].Text = mk.Point1.IsEmpty ? "" : String.Format("{0}, {1}", mk.Point1.X.ToString("0.00"), mk.Point1.Y.ToString("0.00")); mk.row.SubItems[9].Text = mk.Point2.IsEmpty ? "" : String.Format("{0}, {1}", mk.Point2.X.ToString("0.00"), mk.Point2.Y.ToString("0.00")); mk.row.Tag = mk; if (mk.FlagDel) { mk.row.ForeColor = Color.LightGray; mk.row.BackColor = Color.White; } else { mk.row.ForeColor = Color.Black; if (mk.Exception == null) { if (mk.FlagSaved) { if (mk.FlagUpdate) { mk.row.BackColor = Color.Gray; } else { mk.row.BackColor = Color.LightGray; } } else { mk.row.BackColor = Color.White; } } if (mk.Exception is HockeyIce.CheckValidMarkerException) { var ex = (HockeyIce.CheckValidMarkerException)mk.Exception; switch (ex.CheckValidLevel) { case HockeyIce.CheckValidMarkerException.CheckValidLevelEnum.WARNING: mk.row.BackColor = Color.Yellow; break; case HockeyIce.CheckValidMarkerException.CheckValidLevelEnum.CRITICAL: mk.row.BackColor = Color.Red; break; } } } }
private void CorrectMarkerChangedPlayers(object sender, EventArgs e) { if (dataGridView1.SelectedItems.Count == 1 && GetDataGrid().SelectedItems[0].Tag is Game.Marker && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).ActionId == 14 && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Player1 != null && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Player2 != null) { Marker mk = (Game.Marker)GetDataGrid().SelectedItems[0].Tag; Marker mki = new Game.Marker(game); mki.Assign(mk); Marker mk1 = null; if (mk.player2_id > 0 && game.Markers.Any(o => !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo < mk.TimeVideo && o.ActionId == 14 && o.player1_id == mk.player2_id)) { mk1 = game.Markers.Where(o => !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo < mk.TimeVideo && o.ActionId == 14 && o.player1_id == mk.player2_id) .OrderByDescending(o => o.TimeVideo).First(); } Marker mk2 = null; if (mk.player1_id > 0 && game.Markers.Any(o => !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo > mk.TimeVideo && o.ActionId == 14 && o.player2_id == mk.player1_id)) { mk2 = game.Markers.Where(o => !o.FlagDel && o.Half.Index == mk.Half.Index && o.TimeVideo > mk.TimeVideo && o.ActionId == 14 && o.player2_id == mk.player1_id) .OrderBy(o => o.TimeVideo).First(); } var form = new CorrectChangedPlayersMarkerForm(game, mki, mk1, mk2); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Log.Write("MANUAL CORRECT BEFORE " + mk.ToString()); var time_up = mki.TimeVideo != mk.TimeVideo; var team = mk.Player1 != null ? mk.Team1 : mk.Team2;; if (mk1 != null) { if (mk1.Player1 != mki.Player2) { mk1.Player1 = mki.Player2; mk1.FlagUpdate = true; mk1.FlagGuiUpdate = true; UpdateGridView((Game.Marker)mk1); } } if (mk2 != null) { if (mk2.Player2 != mki.Player1) { mk2.Player2 = mki.Player1; mk2.FlagUpdate = true; mk2.FlagGuiUpdate = true; UpdateGridView((Game.Marker)mk2); } } mk.Assign(mki); mk.FlagUpdate = true; mk.FlagGuiUpdate = true; UpdateGridView((Game.Marker)mk); Log.Write("MANUAL CORRECT AFTER " + mk.ToString()); if (time_up) { ReloadDataGridView(true); } lock (game.Markers) MarkerList.SaveToFile(game.Match.Id, game.Markers); } } }
/// <summary> /// Возможно ли добавить к prevMarker дополнительный extraMarker. /// </summary> /// <param name="prevMarker">Исходный маркер, в который можно добавить новый.</param> /// <param name="extraMarker">Новый маркер.</param> /// <returns>Возвращает true - можно, false - нельзя.</returns> public static bool CheckPrevMarkerNeedsExtraMarker(Game.Marker prevMarker, Game.Marker extraMarker) { #region null and empty marker check if (prevMarker == null || extraMarker == null) { return(false); } if (prevMarker.Compare(0, 0, 0)) { return(false); } #endregion #region Перехват 200700 // Перехват. 200700 // возможен с: // Пас по борту 100300 // Пас 100400 // ОП 100500 // Вброс 100800 // Выброс(+) 100601 if (prevMarker.Compare(2, 7, 0)) { var res = extraMarker.Compare(1, 3, 0) || extraMarker.Compare(1, 4, 0) || extraMarker.Compare(1, 5, 0) || extraMarker.Compare(1, 8, 0) || extraMarker.Compare(1, 6, 1); return(res); } #endregion #region Единоборство. 200100 // Единоборство. 200100 // возможен с: // Пас по борту 100300 // Пас 100400 // ОП 100500 // Вброс 100800 // Выброс(+) 100601 if (prevMarker.Compare(2, 1, 0)) { var res = extraMarker.Compare(1, 3, 0) || extraMarker.Compare(1, 4, 0) || extraMarker.Compare(1, 5, 0) || extraMarker.Compare(1, 8, 0) || extraMarker.Compare(1, 6, 1); return(res); } #endregion #region Отбор 200600 // Отбор. 200600 // возможен с: // Пас по борту 100300 // Пас 100400 // ОП 100500 // Вброс 100800 // Выброс(+) 100601 if (prevMarker.Compare(2, 6, 0)) { var res = extraMarker.Compare(1, 3, 0) || extraMarker.Compare(1, 4, 0) || extraMarker.Compare(1, 5, 0) || extraMarker.Compare(1, 8, 0) || extraMarker.Compare(1, 6, 1); return(res); } #endregion #region Отбитый бросок // Отбитый бросок 400200 // возможен с флагами: // Фиксация шайбы вратарем 300600 // Отбивание шайбы вратарем 100900 if (prevMarker.Compare(4, 2, 0)) { var res = extraMarker.Compare(3, 6, 0) || extraMarker.Compare(1, 9, 0); return(res); } #endregion return(false); }
private void dataGridView1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { } if (e.Button == System.Windows.Forms.MouseButtons.Right) { contextMenuStrip1.Items.Clear(); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Свойства...", null, EditPropertiesMarker)); Game.Marker mk = null; if (dataGridView1.SelectedItems.Count == 1 && GetDataGrid().SelectedItems[0].Tag is Game.Marker) { mk = (Game.Marker)GetDataGrid().SelectedItems[0].Tag; } //Вбрасывание /*if (mk != null && mk.Compare(1, 1)) * { * Marker mk1 = null; * lock (game.Markers) * mk1 = game.Markers.Where(o => !o.FlagDel && o.Compare(1, 1) && o.Half.Index == game.Half.Index) * .OrderBy(o => o.TimeVideo).FirstOrDefault(); * * if (mk1 == mk) * { * contextMenuStrip1.Items.Add(new ToolStripSeparator()); * contextMenuStrip1.Items.Add(new ToolStripMenuItem("Установить текущее время для первого вбрасывания", null, SetupCurrentTime) { Tag = mk }); * } * }*/ if (mk != null && mk.ActionId == 14) { contextMenuStrip1.Items.Add(new ToolStripMenuItem("Коррекция маркера замены...", null, CorrectMarkerChangedPlayers)); if (mk.Num == 1) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Завершить эпизод замен", null, FinallySubsEpisode) { Tag = mk }); } } if (mk != null) { //if (mk.ActionId != 16) { if (contextMenuStrip1.Items.Count > 0) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); } contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время +1s", null, ShiftTimeMarker) { Tag = +1000 }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время +0.1s", null, ShiftTimeMarker) { Tag = +100 }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время -1s", null, ShiftTimeMarker) { Tag = -1000 }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время -0.1s", null, ShiftTimeMarker) { Tag = -100 }); contextMenuStrip1.Items.Add(new ToolStripSeparator()); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время +2s", null, ShiftTimeMarker) { Tag = +2000 }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время -2s", null, ShiftTimeMarker) { Tag = -2000 }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время +0.5s", null, ShiftTimeMarker) { Tag = +500 }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Время -0.5s", null, ShiftTimeMarker) { Tag = -500 }); if (mk.ActionId == 14 && mk.player1_id > 0) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Выделить все замены игрока", null, SelectSubsMarker) { Tag = mk }); contextMenuStrip1.Items.Add(new ToolStripMenuItem("Выделить все замены позиции", null, SelectPosMarker) { Tag = mk }); } } } if (dataGridView1.SelectedItems.Count > 0) { if (contextMenuStrip1.Items.Count > 0) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); } contextMenuStrip1.Items.Add(new ToolStripMenuItem("Удалить", null, DeleteSelectedMarkers)); } if (dataGridView1.SelectedItems.Count == 1 && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Exception != null && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Exception.Code == 1) { if (contextMenuStrip1.Items.Count > 0) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); } contextMenuStrip1.Items.Add(new ToolStripMenuItem("Вставить подбор ?", null, InsertPickUp)); } if (dataGridView1.SelectedItems.Count == 1 && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Exception != null && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Exception.Code == 2) { if (contextMenuStrip1.Items.Count > 0) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); } contextMenuStrip1.Items.Add(new ToolStripMenuItem("Заменить на прием ?", null, ChangeToPickUp2)); } if (dataGridView1.SelectedItems.Count == 1 && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Exception != null && ((Game.Marker)GetDataGrid().SelectedItems[0].Tag).Exception.Code == 3) { if (contextMenuStrip1.Items.Count > 0) { contextMenuStrip1.Items.Add(new ToolStripSeparator()); } contextMenuStrip1.Items.Add(new ToolStripMenuItem("Заменить на подбор ?", null, ChangeToPickUp)); } } }
/// <summary> /// Получить правило создания дополнительного маркера childMarker в маркере sourceMarker. /// </summary> /// <param name="sourceMarker">Родительский маркер.</param> /// <param name="childMarker">Дочерний маркер в составе родительского.</param> /// <returns>Правило создания дополнительного маркер.</returns> public static AddChildMarkerRule CheckRuleForeExtraMarker(Game.Marker sourceMarker, Game.Marker childMarker) { #region Перехват 200700 // Перехват. 200700 // добавляется 100 мс. // возможен с: // Пас по борту 100300 // Пас 100400 // ОП 100500 // Вброс 100800 // Выброс(+) 100601 if (sourceMarker.Compare(2, 7, 0)) { var isMyRule = childMarker.Compare(1, 3, 0) || childMarker.Compare(1, 4, 0) || childMarker.Compare(1, 5, 0) || childMarker.Compare(1, 8, 0) || childMarker.Compare(1, 6, 1); return(isMyRule ? AddChildMarkerRule.Add100ms : AddChildMarkerRule.None); } #endregion #region Единоборство 200100 // Единоборство. 200100 // добавляется 100 мс. // возможен с: // Пас по борту 100300 // Пас 100400 // ОП 100500 // Вброс 100800 // Выброс(+) 100601 if (sourceMarker.Compare(2, 1, 0)) { var isMyRule = childMarker.Compare(1, 3, 0) || childMarker.Compare(1, 4, 0) || childMarker.Compare(1, 5, 0) || childMarker.Compare(1, 8, 0) || childMarker.Compare(1, 6, 1); return(isMyRule ? AddChildMarkerRule.Add100ms : AddChildMarkerRule.None); } #endregion #region Единоборство 200600 // Отбор. 200600 // добавляется 100 мс. // возможен с: // Пас по борту 100300 // Пас 100400 // ОП 100500 // Вброс 100800 // Выброс(+) 100601 if (sourceMarker.Compare(2, 6, 0)) { var isMyRule = childMarker.Compare(1, 3, 0) || childMarker.Compare(1, 4, 0) || childMarker.Compare(1, 5, 0) || childMarker.Compare(1, 8, 0) || childMarker.Compare(1, 6, 1); return(isMyRule ? AddChildMarkerRule.Add100ms : AddChildMarkerRule.None); } #endregion return(AddChildMarkerRule.None); }
public MarkerForListView(Game.Marker marker) { this.marker = marker; }