/// <summary> /// Get Data question from file /// </summary> /// <param name="pathFile"></param> /// <param name="listGameShow"></param> public static void getScheduleFromFile(string pathFile, ref List <GameShow> listGameShow) { StreamReader sr = new StreamReader(pathFile); string line = null; GameShow game = null; while ((line = sr.ReadLine()) != null) { if (line.StartsWith("!")) { game = new GameShow(); game.ID = line.Substring(1); } else if (line.StartsWith("@")) { game.Name = line.Substring(1); } else if (line.StartsWith("#")) { game.StartTime = DateTime.Parse(line.Substring(1)); } else if (line.StartsWith("$")) { game.EndTime = DateTime.Parse(line.Substring(1)); } else if (line.StartsWith("%")) { game.NumberPlayer = int.Parse(line.Substring(1)); listGameShow.Add(game); } } sr.Close(); sortSchedule(listGameShow, 2); }
public IsBroadcasting() { InitializeComponent(); GameShow gameIsBroadcasting = Utils.findGameIsBroadcasting(Host.listGameShow); setInforNearestGame(gameIsBroadcasting); }
public Nearest_Game() { InitializeComponent(); GameShow nearestGame = Utils.findNearestGame(Host.listGameShow); nearestGame = Utils.findNearestGame(Host.listGameShow); setInforNearestGame(nearestGame); }
/// <summary> /// Set up schedule a gameshow into the form /// </summary> /// <param name="game"></param> public void setDataIntoForm(GameShow game) { txtID.Text = game.ID; txtName.Text = game.Name; dtmStart.Value = game.StartTime; dtmEnd.Value = game.EndTime; nudNumberPlayer.Value = game.NumberPlayer; }
// Use this for initialization void Awake() { _gameShow = GameObject.Find("GameShow").GetComponent <GameShow>(); userInput = GameObject.Find("Canvas/UserInput"); if (unanswered == null) { unanswered = _questions.ToList <OOQuestions>(); } }
public async Task <IActionResult> Open(string name) { var entity = new GameShow(); entity.IsOpen = true; entity.IsOnline = true; entity.Name = name; var idGameShow = await _gameShowRepos.AddAndGetIdAsyn(entity); return(Ok(idGameShow)); }
/// <summary> /// Save quetion to file /// </summary> /// <param name="fileSchedulePath">Path to file save</param> /// <param name="game"></param> /// <returns></returns> private bool SaveGameShow(string fileSchedulePath, GameShow game) { StreamWriter sw = new StreamWriter(fileSchedulePath, true); sw.WriteLine("!" + game.ID); sw.WriteLine("@" + game.Name); sw.WriteLine("#" + game.StartTime); sw.WriteLine("$" + game.EndTime); sw.WriteLine("%" + game.NumberPlayer); sw.Close(); return(true); }
/// <summary> /// Get information gameshow from form input /// </summary> /// <returns></returns> public GameShow getGameShowFromForm() { if (checkInputSchedule()) { GameShow game = new GameShow(); game.ID = txtID.Text; game.Name = txtName.Text; game.StartTime = dtmStart.Value; game.EndTime = dtmEnd.Value; game.NumberPlayer = (int)nudNumberPlayer.Value; return(game); } return(null); }
private void btnAdd_Click(object sender, EventArgs e) { GameShow game = getGameShowFromForm(); if (game != null) { bool saveFinish = SaveGameShow(fileSchedulePath, game); if (saveFinish) { refreshForm(); getScheduleFromFile(fileSchedulePath, numColumSort); } } }
public void setInforNearestGame() { GameShow nearestGame = Utils.findNearestGame(listGameShow); if (nearestGame == null) { lblGameID.Text = "Hiện không có game nào phát sóng trong thời gian tới"; lblStartTime.Text = ""; lblCountDown.Text = ""; lblGameName.Text = ""; } else { lblGameID.Text = nearestGame.ID; lblStartTime.Text = nearestGame.StartTime.ToString(); lblGameName.Text = nearestGame.Name; countDownTime = Utils.calcWaitingTime(nearestGame) + 1;// get countdown time tmrCountDown.Enabled = true; } }
public void setInforNearestGame(GameShow game) { if (game == null) { lblGameID.Text = "There are no future games"; lblGameID.ForeColor = Color.Red; lblStartTime.Text = ""; lblCountDown.Text = ""; lblGameName.Text = ""; } else { //Set countdown time when game show != null OrigTime = calcWaitingTime(game); //Turn on Timer Countdown tmrCountDown.Enabled = true; lblGameID.Text = game.ID; lblGameName.Text = game.Name; lblStartTime.Text = game.StartTime.ToString(); } }
/// <summary> /// Find the game is broadcasting in Broadcast Schedule /// </summary> /// <param name="listGameShow"></param> /// <returns></returns> public static GameShow findGameIsBroadcasting(List <GameShow> listGameShow) { DateTime timeNow = DateTime.Now; GameShow gameIsBroadcasting = null; listGameShow.ForEach(game => { //Check whether the game has a valid broadcast time and is less than the min time if (timeNow > game.StartTime && timeNow < game.EndTime) { if (gameIsBroadcasting == null) { gameIsBroadcasting = game; } if (game.StartTime.Subtract(timeNow).TotalMilliseconds > gameIsBroadcasting.StartTime.Subtract(timeNow).TotalMilliseconds) { gameIsBroadcasting = game; } } }); return(gameIsBroadcasting); }
private void btnSave_Click(object sender, EventArgs e) { var result = MessageBox.Show("Edit broadcast schedule", "Do you want edit broadcast schedule??", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { btnAdd.Show(); btnSave.Hide(); GameShow game = new GameShow() //Tạo game show mới từ form { ID = txtID.Text, Name = txtName.Text, StartTime = dtmStart.Value, EndTime = dtmEnd.Value, NumberPlayer = (int)nudNumberPlayer.Value }; Host.listGameShow[rowEdit] = game; //Change data gameshow selected in list saveListGameShow(fileSchedulePath); //Backup list game show grvSchedule.DataSource = Host.listGameShow; } txtID.Enabled = true; }
/// <summary> /// Find nearest game in Broadcast Schedule /// </summary> /// <param name="listGameShow"></param> /// <returns></returns> public static GameShow findNearestGame(List <GameShow> listGameShow) { DateTime timeNow = DateTime.Now; GameShow nearestGame = null; listGameShow.ForEach(game => { //Check whether the game has a valid broadcast time and is less than the min time if (timeNow < game.StartTime) { if (nearestGame == null) { nearestGame = game; } if (game.StartTime.Subtract(timeNow).TotalMilliseconds < nearestGame.StartTime.Subtract(timeNow).TotalMilliseconds) { nearestGame = game; } } }); return(nearestGame); }
public List <GameShow> getScheduleFromFile(string pathFile, int numColumSort) { StreamReader sr = new StreamReader(pathFile); List <GameShow> listGameShow = new List <GameShow>(); string line = null; GameShow game = null; while ((line = sr.ReadLine()) != null) { if (line.StartsWith("!")) { game = new GameShow(); game.ID = line.Substring(1); } else if (line.StartsWith("@")) { game.Name = line.Substring(1); } else if (line.StartsWith("#")) { game.StartTime = DateTime.Parse(line.Substring(1)); } else if (line.StartsWith("$")) { game.EndTime = DateTime.Parse(line.Substring(1)); } else if (line.StartsWith("%")) { game.NumberPlayer = int.Parse(line.Substring(1)); listGameShow.Add(game); } } Utils.sortSchedule(listGameShow, numColumSort); grvListGame.DataSource = listGameShow; sr.Close(); return(listGameShow); }
/// <summary> /// Calculate the time distance with the nearest game /// </summary> /// <param name="game">The game is broadcasting</param> /// <returns></returns> public int calcEndTime(GameShow game) { return((int)(game.EndTime.Subtract(DateTime.Now).TotalSeconds)); }
/// <summary> /// Calculate the time distance with the nearest game /// </summary> /// <param name="nearestGame"></param> /// <returns></returns> public int calcWaitingTime(GameShow nearestGame) { return((int)(nearestGame.StartTime.Subtract(DateTime.Now).TotalSeconds)); }
/// <summary> /// Reset information for the nearest game when the previous game has started /// </summary> public void resetInforNearestGame() { GameShow nearestGame = Utils.findNearestGame(Host.listGameShow); setInforNearestGame(nearestGame); }