protected void Page_Load(object sender, EventArgs e) { webService = new LeagueOfLegendsWebService(); SetRandomSplashImage(); PopulateRandomBuildPlaceholder(); PopulateTierPlaceholder(); }
protected void Page_Load(object sender, EventArgs e) { LeagueOfLegendsWebService webservice = new LeagueOfLegendsWebService(); HtmlGenericControl characterTextContainer = new HtmlGenericControl("p"); characterTextContainer.InnerText = "Click a portrait below to view builds for that character"; charactersPlaceholder.Controls.Add(characterTextContainer); List<Character> characters = webservice.GetCharacters().ToList<Character>(); for (int i = 0; i < characters.Count(); i++) { HtmlGenericControl imageContainer = new HtmlGenericControl("div"); HtmlGenericControl nameContainer = new HtmlGenericControl("div"); HtmlGenericControl characterContainer = new HtmlGenericControl("div"); imageContainer.ID = "imageContainer"; nameContainer.ID = "nameContainer"; characterContainer.ID = "characterContainer"; string name = characters[i].Name; string link = "ViewBuilds.aspx?ID=" + characters[i].ID; Image charImage = new Image(); charImage.ImageUrl = CharacterUtility.GetImagePath(name, CharacterUtility.ImageType.Square); HyperLink imageLink = new HyperLink(); imageLink.NavigateUrl = link; HyperLink nameLink = new HyperLink(); nameLink.Text = name; imageLink.Controls.Add(charImage); nameLink.NavigateUrl = link; imageContainer.Controls.Add(imageLink); nameContainer.Controls.Add(nameLink); characterContainer.Controls.Add(imageContainer); characterContainer.Controls.Add(nameContainer); charactersPlaceholder.Controls.Add(characterContainer); } }
protected void cmdCreate_Click(object sender, EventArgs e) { if (ValidateBuild()) { int id = Convert.ToInt32(dropCharacter.Items[dropCharacter.SelectedIndex].Value); buildItems = (List<Item>)Session["buildItems"]; List<Ability> buildAbilities = new List<Ability>(); createRadioListArray(); foreach (RadioButtonList list in radioButtonList) { Ability ability = new Ability(); ability.Name = list.SelectedItem.Value; buildAbilities.Add(ability); } webService = new LeagueOfLegendsWebService(); int buildID = webService.CreateBuild(txtBuildName.Text, txtUsername.Text, id, buildAbilities.ToArray(), buildItems.ToArray()); Response.Redirect("BuildDetail.aspx?BuildID=" + buildID); } }
protected void Page_Load(object sender, EventArgs e) { int characterID = 0; NameValueCollection characterData = Request.QueryString; if (characterData["ID"] != null) { try { characterID = Convert.ToInt32(characterData["ID"]); LeagueOfLegendsWebService webservice = new LeagueOfLegendsWebService(); Character selectedCharacter = webservice.GetCharacter(characterID); List<Character> characters = webservice.GetCharacters().ToList<Character>(); if (characterID > characters.Count()) { Response.Redirect("Characters.aspx"); } if (characterID < 0) { Response.Redirect("Characters.aspx"); } string characterName = selectedCharacter.Name; int skinCount = selectedCharacter.SkinCount; //Create HTMLGenericControl and add Character name to it HtmlGenericControl title = new HtmlGenericControl("h1"); title.InnerText = characterName; buildsPlaceholder.Controls.Add(title); //Add random portrait art Random rand = new Random(); Image characterPortrait = new Image(); characterPortrait.ImageUrl = CharacterUtility.GetImagePath(characterName, CharacterUtility.ImageType.Portrait, rand.Next(skinCount)); HtmlGenericControl portraitImage = new HtmlGenericControl("div"); portraitImage.Controls.Add(characterPortrait); portraitImage.ID = "portraitContainer"; buildsPlaceholder.Controls.Add(portraitImage); List<Build> builds = webservice.GetBuildsForCharacter(characterID).ToList<Build>(); if (builds.Count() < 1) { HtmlGenericControl noBuildsContainer = new HtmlGenericControl("div"); noBuildsContainer.InnerText = "There are currently no builds for this champion"; HyperLink characterLink = new HyperLink(); HtmlGenericControl noBuildsRedirectContainer = new HtmlGenericControl("div"); characterLink.NavigateUrl = "Characters.aspx"; characterLink.Text = "Back to Characters page"; noBuildsRedirectContainer.Controls.Add(characterLink); buildsPlaceholder.Controls.Add(noBuildsContainer); buildsPlaceholder.Controls.Add(noBuildsRedirectContainer); noBuildsRedirectContainer.ID = "redirectContainer"; noBuildsContainer.ID = "noBuildsContainer"; } else { for (int i = 0; i < builds.Count(); i++) { HtmlGenericControl buildContainer = new HtmlGenericControl("div"); HtmlGenericControl buildNameContainer = new HtmlGenericControl("div"); HtmlGenericControl buildUserNameContainer = new HtmlGenericControl("div"); HyperLink buildClick2 = new HyperLink(); buildClick2.NavigateUrl = "BuildDetail.aspx?BuildID=" + builds[i].ID; buildContainer.ID = "buildContainer"; buildNameContainer.ID = "buildNameContainer"; buildUserNameContainer.ID = "buildUserNameContainer"; buildNameContainer.InnerText = builds[i].BuildName; buildUserNameContainer.InnerText = builds[i].UserName; buildContainer.Controls.Add(buildNameContainer); buildContainer.Controls.Add(buildUserNameContainer); buildClick2.Controls.Add(buildContainer); buildsPlaceholder.Controls.Add(buildClick2); } } } catch (Exception ex) { Response.Redirect("Characters.aspx"); } } else { Response.Redirect("Characters.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { LeagueOfLegendsWebService webService = new LeagueOfLegendsWebService(); NameValueCollection qs = Request.QueryString; string qsCharacterID = qs.Get("characterID"); string qsVoteType = qs.Get("voteType"); int characterCount = webService.GetCharacters().Count(); try { if (qsCharacterID != null && qsVoteType != null && Convert.ToInt32(qsCharacterID) < characterCount) { if (Session["vote" + qsCharacterID] == null) { switch (qsVoteType) { case "upvote": webService.EnterVote(Convert.ToInt32(qsCharacterID), 1); break; case "downvote": webService.EnterVote(Convert.ToInt32(qsCharacterID), -1); break; default: break; } } else { string previousVote = Session["vote" + qsCharacterID].ToString(); switch (qsVoteType) { case "upvote": if (!previousVote.Equals(qsVoteType)) { webService.EnterVote(Convert.ToInt32(qsCharacterID), 2); } break; case "downvote": if (!previousVote.Equals(qsVoteType)) { webService.EnterVote(Convert.ToInt32(qsCharacterID), -2); } break; default: break; } } Session["vote" + qsCharacterID] = qsVoteType; Response.Redirect("TierList.aspx"); } } catch (Exception ex) { Response.Redirect("TierList.aspx"); } List<Character> characters = webService.GetCharactersOrderedByVote().ToList<Character>(); // This ordered list will hold the tier list. It will be placed into the placeholder at the end. HtmlGenericControl orderedList = new HtmlGenericControl("ol"); orderedList.ID = "orderedListControl"; int previousVoteValue = 0; int rank = 0; int numberOfTiesInARow = 0; for (int i = 0; i < characters.Count; i++) { string characterName = characters[i].Name; int characterID = characters[i].ID; string votes = webService.GetVotesForCharacter(characterID).ToString(); Image characterImage = new Image(); characterImage.ImageUrl = CharacterUtility.GetImagePath(characterName, CharacterUtility.ImageType.Square); Image plusImage = new Image(); plusImage.ImageUrl = "Images/plus.png"; Image minusImage = new Image(); minusImage.ImageUrl = "Images/minus.png"; HtmlGenericControl listItem = new HtmlGenericControl("li"); HtmlGenericControl rankContainer = new HtmlGenericControl("div"); HtmlGenericControl masterContainer = new HtmlGenericControl("div"); HtmlGenericControl characterNameContainer = new HtmlGenericControl("div"); HtmlGenericControl voteNumber = new HtmlGenericControl("div"); HyperLink upvote = new HyperLink(); HyperLink downvote = new HyperLink(); // Assign neccessary Controls an ID so they may be styled through css listItem.ID = "listItem"; rankContainer.ID = "rankContainer"; masterContainer.ID = "masterContainer"; characterNameContainer.ID = "characterNameContainer"; voteNumber.ID = "voteNumber"; upvote.ID = "upvote"; downvote.ID = "downvote"; HighlightSelectedVoteButton(upvote, downvote, characterID); // Populate up/downvote Controls upvote.NavigateUrl = "TierList.aspx?characterID=" + characterID + "&voteType=upvote"; upvote.Controls.Add(plusImage); downvote.NavigateUrl = "TierList.aspx?characterID=" + characterID + "&voteType=downvote"; downvote.Controls.Add(minusImage); // Populate the voteNumber control with the vote number if (Convert.ToInt32(votes) == 1 || Convert.ToInt32(votes) == -1) { voteNumber.InnerText = votes + " point"; } else { voteNumber.InnerText = votes + " points"; } // Populate the rankContainer with the rank number if (i > 0) { if(Convert.ToInt32(votes) == previousVoteValue) { numberOfTiesInARow++; } else { rank += numberOfTiesInARow; rank += 1; numberOfTiesInARow = 0; } } else { rank = 1; // the default rank for the first time through the loop } rankContainer.InnerText = rank.ToString(); // Populate the characterNameContainer with name characterNameContainer.InnerText = characterName; // Add controls, in order, into masterContainer masterContainer.Controls.Add(characterNameContainer); masterContainer.Controls.Add(upvote); masterContainer.Controls.Add(downvote); masterContainer.Controls.Add(voteNumber); // Add controls, in order, into listItem listItem.Controls.Add(rankContainer); listItem.Controls.Add(characterImage); listItem.Controls.Add(masterContainer); // Add the listItem into the orderedList orderedList.Controls.Add(listItem); previousVoteValue = Convert.ToInt32(votes); } tierListPlaceholder.Controls.Add(orderedList); }
protected void Page_Load(object sender, EventArgs e) { int BuildID = 0; NameValueCollection queryString = Request.QueryString; if (queryString["BuildID"] != null) { try { BuildID = Convert.ToInt32(queryString["BuildID"]); LeagueOfLegendsWebService webService = new LeagueOfLegendsWebService(); Build characterBuild = webService.GetBuild(BuildID); if (characterBuild.ID == -1) { Response.Redirect("Default.aspx"); } this.Page.Title = characterBuild.BuildName; //Create the HTML for placeBuildInfo //First create the div to hold the info HtmlGenericControl divBuildInfo = new HtmlGenericControl("div"); divBuildInfo.ID = "BuildInfo"; //divBuildInfo.Attributes.Add("class", "section"); //Get the build name HtmlGenericControl titleBuildName = new HtmlGenericControl("h1"); titleBuildName.InnerHtml = characterBuild.BuildName; divBuildInfo.Controls.Add(titleBuildName); //Create a div to hold the image and title info HtmlGenericControl divCharacter = new HtmlGenericControl("div"); divCharacter.Attributes.Add("class", "description"); //Then Create the image of the character Image characterImage = new Image(); characterImage.ImageUrl = CharacterUtility.GetImagePath(characterBuild.Character.Name, CharacterUtility.ImageType.Square); characterImage.AlternateText = "Icon of " + characterBuild.Character.Name; characterImage.Style.Add("float", "left"); divCharacter.Controls.Add(characterImage); //Create a div to hold the description HtmlGenericControl divDescription = new HtmlGenericControl("div"); //Get the character name HtmlGenericControl titleCharacterName = new HtmlGenericControl("h3"); titleCharacterName.InnerHtml = "<i>A build for " + characterBuild.Character.Name + "</i>"; divDescription.Controls.Add(titleCharacterName); //Get the username HtmlGenericControl titleUsername = new HtmlGenericControl("h4"); titleUsername.InnerHtml = "<i>Created by " + characterBuild.UserName + "</i>"; divDescription.Controls.Add(titleUsername); //Make sure everything is added divCharacter.Controls.Add(divDescription); divBuildInfo.Controls.Add(divCharacter); //Create the actual placeholder placeBuildInfo.Controls.Add(divBuildInfo); //Create the placeAbilities placeholder //First create the div to hold the ability info HtmlGenericControl divAbilities = new HtmlGenericControl("div"); divAbilities.ID = "AbilityInfo"; divAbilities.Attributes.Add("class", "section"); //List the section title HtmlGenericControl titleAbility = new HtmlGenericControl("h2"); titleAbility.InnerText = "Ability Breakdown"; titleAbility.Attributes.Add("class", "sectionTitle"); divAbilities.Controls.Add(titleAbility); //Create the Ability Table Table abilitiesTable = createAbilitiesTable(characterBuild.Character.Abilities.ToList<Ability>(), characterBuild.Abilities.ToList<Ability>()); divAbilities.Controls.Add(abilitiesTable); //Create the actual placeholder placeAbilities.Controls.Add(divAbilities); //Create the placeItems placeholder //Create the div to hold the items info HtmlGenericControl divItems = new HtmlGenericControl("div"); divItems.ID = "ItemsInfo"; divItems.Attributes.Add("class", "section"); //List the section title HtmlGenericControl titleItem = new HtmlGenericControl("h2"); titleItem.InnerHtml = "Items"; titleItem.Attributes.Add("class", "sectionTitle"); divItems.Controls.Add(titleItem); //Create the Item List Table itemList = createItemsTable(characterBuild.Items.ToList<Item>()); divItems.Controls.Add(itemList); //Create the actual placeholder placeItems.Controls.Add(divItems); } catch (Exception ex) { Response.Redirect("Characters.aspx"); } } else { Response.Redirect("Default.aspx"); } }