public void LoadPage() { var i1 = new MGMixAndMatchItems(); var i2 = new MGMixAndMatchItems(); var i3 = new MGMixAndMatchItems(); MGMixAndMatch.Get3RandomItems(int.Parse(MMID.Text), out i1, out i2, out i3); MGMixAndMatchItems correctItem = null; var rnd = new Random(DateTime.Now.Millisecond); var ticks = rnd.Next(1, 3); if (ticks == 1) { correctItem = i1; } if (ticks == 2) { correctItem = i2; } if (ticks == 3) { correctItem = i3; } if (correctItem != null) { MMIID.Text = correctItem.MMIID.ToString(); lblEasy.Text = correctItem.EasyLabel; lblMedium.Text = correctItem.MediumLabel; lblHard.Text = correctItem.HardLabel; } Correct.Text = ticks.ToString(); btn1.ImageUrl = "/Images/Games/MixMatch/" + i1.MMIID.ToString() + ".png"; btn2.ImageUrl = "/Images/Games/MixMatch/" + i2.MMIID.ToString() + ".png"; btn3.ImageUrl = "/Images/Games/MixMatch/" + i3.MMIID.ToString() + ".png"; var difficulty = int.Parse(Difficulty.Text); if (difficulty == 1) { pnlAudioEasy.Visible = System.IO.File.Exists(Server.MapPath(AudioEasy)); } if (difficulty == 2) { pnlAudioMedium.Visible = System.IO.File.Exists(Server.MapPath(AudioMedium)); } if (difficulty == 3) { pnlAudioHard.Visible = System.IO.File.Exists(Server.MapPath(AudioHard)); } }
public void LoadPage() { var i1 = new MGMixAndMatchItems(); var i2 = new MGMixAndMatchItems(); var i3 = new MGMixAndMatchItems(); MGMixAndMatch.Get3RandomItems(int.Parse(MMID.Text), out i1, out i2, out i3); MGMixAndMatchItems correctItem = null; var correctItemNumber = new Random(DateTime.Now.Millisecond).Next(1, 3); switch (correctItemNumber) { case 1: correctItem = i1; break; case 2: correctItem = i2; break; case 3: correctItem = i3; break; } var difficulty = int.Parse(Difficulty.Text); if (correctItem != null) { MMIID.Text = correctItem.MMIID.ToString(); StringBuilder audio = new StringBuilder(MixMatchBasePath); switch (difficulty) { case 2: //medium lblMixMatch.Text = correctItem.MediumLabel; audio.AppendFormat("m_{0}.mp3", MMIID.Text); break; case 3: //hard lblMixMatch.Text = correctItem.HardLabel; audio.AppendFormat("h_{0}.mp3", MMIID.Text); break; default: lblMixMatch.Text = correctItem.EasyLabel; audio.AppendFormat("e_{0}.mp3", MMIID.Text); break; } if (System.IO.File.Exists(Server.MapPath(audio.ToString()))) { lblSound.Text = string.Format( "<audio controls><source src='{0}' type='audio/mpeg'>Your browser does not support this audio format.</audio>", VirtualPathUtility.ToAbsolute(audio.ToString())); pnlAudio.Visible = true; } } Correct.Text = correctItemNumber.ToString(); btn1.ImageUrl = string.Format("{0}{1}.png", MixMatchBasePath, i1.MMIID); btn2.ImageUrl = string.Format("{0}{1}.png", MixMatchBasePath, i2.MMIID); btn3.ImageUrl = string.Format("{0}{1}.png", MixMatchBasePath, i3.MMIID); }