private void generateGeneralControls() { string itemType = ItemTypes.GetItemType(itemBase); if (itemType == "No type found") { createErrorControl(); return; } generalParams = new Dictionary <string, string>() { { "type", itemType }, { "league", settings.league } }; //create controls if (itemBase == "Gem") { #region Gem controls string quality = itemParams.Where(p => p.Contains("Quality:")).FirstOrDefault(); if (!String.IsNullOrEmpty(quality)) { heightAdjust++; quality = quality.Split(' ')[1].Replace("+", "").Replace("%", "").Replace("(augmented)", "").Trim(); } else { heightAdjust += 2; quality = "0"; } string level = itemParams.Where(p => p.Contains("Level:")).FirstOrDefault(); if (!string.IsNullOrEmpty(level)) { level = level.Split(' ')[1].Trim(); } else { level = "1"; } addControl("Quality: " + quality); addControl("Level: " + level); #endregion } else #region Rare general and pseudo mods if (!itemParams[0].Contains("Unique")) { if (ItemTypes.IsWeapon(itemBase)) { heightAdjust += 4; } if (ItemTypes.IsArmor(itemBase)) { heightAdjust += 4; } if (ItemTypes.IsWeapon(itemBase) || ItemTypes.IsArmor(itemBase)) { heightAdjust += 4; } if (ItemTypes.IsBelt(itemBase) || ItemTypes.IsJewelery(itemBase)) { heightAdjust += 2; } if (ItemTypes.IsQuiver(itemBase)) { heightAdjust++; } if (ItemTypes.IsWeapon(itemBase)) { #region Weapon rare and pseudo mods string[] physDmg = itemParams.Where(p => p.Contains("Physical Damage:")).FirstOrDefault().Split(':')[1].Replace("(augmented)", "").Trim().Split('-'); string aps = itemParams.Where(p => p.Contains("Attacks per Second:")).FirstOrDefault().Split(':')[1].Replace("(augmented)", "").Trim(); string crit = itemParams.Where(p => p.Contains("Critical Strike Chance:")).FirstOrDefault().Split(':')[1].Replace("%", "").Trim(); string elemDmgStr = itemParams.Where(p => p.Contains("Elemental Damage:")).FirstOrDefault(); List <string> elemDmg = new List <string>(); if (elemDmgStr != null) { elemDmg = elemDmgStr.Split(':').ToList()[1].Replace("(augmented)", "").Replace(",", "").Replace(" ", " ").Trim().Split(' ').ToList(); } //extract dmg, calc pdps edps double pdps = Math.Round((Double.Parse(physDmg[0], CultureInfo.InvariantCulture) + Double.Parse(physDmg[1], CultureInfo.InvariantCulture)) / Double.Parse(aps, CultureInfo.InvariantCulture), 2); double edps = 0; for (int i = 0; i < elemDmg.Count(); i++) { var tempEdps = elemDmg[i].Split('-'); double currEdps = Math.Round((Double.Parse(tempEdps[0].Trim(), CultureInfo.InvariantCulture) + Double.Parse(tempEdps[1].Trim(), CultureInfo.InvariantCulture)) / Double.Parse(aps, CultureInfo.InvariantCulture), 2); edps += currEdps; } addControl("pDPS: " + pdps.ToString()); addControl("eDPS: " + edps.ToString()); addControl("APS: " + aps); addControl("Crit. Strike: " + crit); insertSeparatorLine("Total values:"); #endregion } else if (ItemTypes.IsArmor(itemBase)) { #region Armor rare and pseudo mods //extract arm es eva string evaTotal = itemParams.Where(p => p.Contains("Evasion Rating:")).FirstOrDefault(); if (!String.IsNullOrEmpty(evaTotal)) { evaTotal = Mods.ExtractModValue(evaTotal); } else { evaTotal = "0"; } string shieldTotal = itemParams.Where(p => p.Contains("Energy Shield:")).FirstOrDefault(); if (!String.IsNullOrEmpty(shieldTotal)) { shieldTotal = Mods.ExtractModValue(shieldTotal); } else { shieldTotal = "0"; } string armourTotal = itemParams.Where(p => p.Contains("Armour:")).FirstOrDefault(); if (!String.IsNullOrEmpty(armourTotal)) { armourTotal = Mods.ExtractModValue(armourTotal); } else { armourTotal = "0"; } createTotalLifeControl(); createTotalResControl(); addControl("Armour: " + armourTotal); addControl("Evasion: " + evaTotal); addControl("Energy Shield: " + shieldTotal); insertSeparatorLine("Total values:"); #endregion } } #endregion if (itemParams[0].Contains("Unique") || itemBase == "Gem") { if (itemBase != "Gem") { generalParams["rarity"] = "Unique"; } generalParams["name"] = itemParams[1]; } #region Sockets and Links var socketsAndLinks = Mods.GetSocketsAndLinks(itemParams.Where(p => p.Contains("Sockets")).FirstOrDefault()); if (socketsAndLinks != null) { if (itemParams[0].Contains("Unique")) { heightAdjust++; heightAdjust += 2; } addControl("Links: " + socketsAndLinks[1]); addControl("Sockets: " + socketsAndLinks[0]); insertSeparatorLine("Sockets and links:"); } #endregion if (ItemTypes.IsBelt(itemBase) || ItemTypes.IsJewelery(itemBase) || ItemTypes.IsQuiver(itemBase)) { createTotalLifeControl(); createTotalResControl(); insertSeparatorLine("Total values:"); } if (itemBase != "Gem") { itemParams = Mods.FilterItemParams(itemParams); addModControls(); } else { itemParams.Clear(); addSearchButton(); } }
private void addControl(string param) { int totalWidth = 0; string modValue; modValue = Mods.ExtractModValue(param); //add item mod names TextBox modName = new TextBox(); modName.Text = param; modName.ReadOnly = true; modName.Dock = DockStyle.Top; modName.MaximumSize = new Size((int)(form.Width / 1.1), modName.Height); this.form.Controls.Add(modName); totalWidth += modName.Width; if (param.Contains("(not adjustable)")) { heightAdjust--; return; } //adjust mod value if adjustable Button minMinus = new Button(); minMinus.Location = new Point(totalWidth, modName.Height * heightAdjust); minMinus.Width = 20; minMinus.Text = "-"; minMinus.TextAlign = ContentAlignment.MiddleCenter; totalWidth += minMinus.Width; minMinus.Click += new EventHandler(minMinus_Click); minMinus.Name = "minMinus " + param; TextBox minValue = new TextBox(); minValue.Location = new Point(totalWidth, modName.Height * heightAdjust); minValue.Width = 45; totalWidth += minValue.Width; try { if (Double.Parse(modValue) < 1) { minValue.Text = Math.Round((Double.Parse(modValue, CultureInfo.InvariantCulture) * Double.Parse(settings.InitialMinValuesMultiplied, CultureInfo.InvariantCulture)), 2).ToString(); } else { minValue.Text = ((int)(Double.Parse(modValue, CultureInfo.InvariantCulture) * Double.Parse(settings.InitialMinValuesMultiplied, CultureInfo.InvariantCulture))).ToString(); } } catch { minValue.Text = modValue; } minValue.Name = "minVal " + param; Button minPlus = new Button(); minPlus.Location = new Point(totalWidth, modName.Height * heightAdjust); minPlus.Width = 20; minPlus.Text = "+"; minPlus.TextAlign = ContentAlignment.MiddleCenter; totalWidth += minPlus.Width; minPlus.Click += new EventHandler(minPlus_Click); minPlus.Parent = minValue; minPlus.Name = "minPlus " + param; Button maxMinus = new Button(); maxMinus.Location = new Point(totalWidth, modName.Height * heightAdjust); maxMinus.Width = 20; maxMinus.Text = "-"; maxMinus.TextAlign = ContentAlignment.MiddleCenter; totalWidth += maxMinus.Width; maxMinus.Click += new EventHandler(maxMinus_Click); maxMinus.Name = "maxMinus " + param; TextBox maxValue = new TextBox(); maxValue.Location = new Point(totalWidth, modName.Height * heightAdjust); maxValue.Width = 45; totalWidth += maxValue.Width; try { if (Double.Parse(modValue) < 1) { maxValue.Text = Math.Round((Double.Parse(modValue, CultureInfo.InvariantCulture) * Double.Parse(settings.InitialMaxValuesMultiplied, CultureInfo.InvariantCulture)), 2).ToString(); } else { maxValue.Text = ((int)(Double.Parse(modValue, CultureInfo.InvariantCulture) * Double.Parse(settings.InitialMaxValuesMultiplied, CultureInfo.InvariantCulture))).ToString(); } if (maxValue.Text == "0") { maxValue.Text = ""; } } catch { maxValue.Text = modValue; } maxValue.Name = "maxVal " + param;; Button maxPlus = new Button(); maxPlus.Location = new Point(totalWidth, modName.Height * heightAdjust); maxPlus.Width = 20; maxPlus.Text = "+"; maxPlus.TextAlign = ContentAlignment.MiddleCenter; totalWidth += maxPlus.Width; maxPlus.Click += new EventHandler(this.maxPlus_Click); maxPlus.Name = "maxPlus " + param; this.form.Controls.Add(minMinus); this.form.Controls.Add(minValue); this.form.Controls.Add(minPlus); this.form.Controls.Add(maxMinus); this.form.Controls.Add(maxValue); this.form.Controls.Add(maxPlus); //select mod to compare by CheckBox checkbox = new CheckBox(); checkbox.Location = new Point(totalWidth + 2, modName.Height * heightAdjust); checkbox.Width = 20; totalWidth += checkbox.Width; checkbox.Name = "cBox " + param; this.form.Controls.Add(checkbox); if (settings.InitiallyAllSelected != "0") { checkbox.Checked = true; } heightAdjust--; }