void DisplayTradeList() { dataGridViewTrades.Rows.Clear(); if (tradelist.Count > 0) { // last_mcl can be null List <MaterialCommodityMicroResource> mcl = last_mcl == null ? null : discoveryform.history.MaterialCommoditiesMicroResources.Get(last_mcl.Value); var totals = mcl == null ? null : MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present, null if we don't have an mcl foreach (var trade in tradelist) { var rw = dataGridViewTrades.RowTemplate.Clone() as DataGridViewRow; if (mcl != null) { if (!totals.ContainsKey(trade.fromelement.FDName)) // make sure they are both there, so we don't crash. the from should always be here { totals[trade.fromelement.FDName] = 0; } if (!totals.ContainsKey(trade.element.FDName)) // the to, if 0, will not { totals[trade.element.FDName] = 0; } totals[trade.fromelement.FDName] -= trade.offer; if (totals[trade.fromelement.FDName] >= 0) { totals[trade.element.FDName] += trade.receive; rw.CreateCells(dataGridViewTrades, trade.fromelement.Name, trade.offer.ToString(), totals[trade.fromelement.FDName].ToString(), trade.element.Name, trade.receive.ToString(), totals[trade.element.FDName].ToString()); } else { rw.CreateCells(dataGridViewTrades, trade.fromelement.Name, trade.offer.ToString(), "- !!!", trade.element.Name, trade.receive.ToString(), "-"); } } else { rw.CreateCells(dataGridViewTrades, trade.fromelement.Name, trade.offer.ToString(), "-", trade.element.Name, trade.receive.ToString(), "-"); } dataGridViewTrades.Rows.Add(rw); } } }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewSynthesis.FirstDisplayedScrollingRowIndex; // remember where we were displaying var totals = MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present wantedList = new List <Tuple <Recipes.Recipe, int> >(); string recep = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbRecipeFilterSave, "All"); string[] recipeArray = recep.Split(';'); string levels = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string materials = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) { int rno = (int)dataGridViewSynthesis.Rows[i].Tag; dataGridViewSynthesis.Rows[i].Cells[2].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, Recipes.SynthesisRecipes[rno]).Item1.ToString(); bool visible = true; if (recep != "All" || levels != "All" || materials != "All") { if (recep != "All") { visible &= recipeArray.Contains(Recipes.SynthesisRecipes[rno].Name); } if (levels != "All") { visible &= lvlArray.Contains(Recipes.SynthesisRecipes[rno].level); } if (materials != "All") { var inglongname = Recipes.SynthesisRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewSynthesis.Rows[i].Visible = visible; } for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) { int rno = (int)dataGridViewSynthesis.Rows[i].Tag; if (dataGridViewSynthesis.Rows[i].Visible) { Recipes.Recipe r = Recipes.SynthesisRecipes[rno]; Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, r, Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); using (DataGridViewRow row = dataGridViewSynthesis.Rows[i]) { row.Cells[3].Value = Wanted[rno].ToString(); row.Cells[4].Value = res.Item2.ToString(); row.Cells[5].Value = res.Item3; row.Cells[5].ToolTipText = res.Item4; row.Cells[6].Value = r.IngredientsStringvsCurrent(last_he.MaterialCommodity); row.Cells[6].ToolTipText = r.IngredientsStringLong; } } if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded)) { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.SynthesisRecipes[rno], Wanted[rno])); } } dataGridViewSynthesis.RowCount = Recipes.SynthesisRecipes.Count; // truncate previous shopping list.. if (!isEmbedded) { var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); foreach (var c in shoppinglist) // and add new.. { var cur = last_he.MaterialCommodity.Find(c.Item1.Details); // may be null Object[] values = { c.Item1.Details.Name, c.Item1.Details.TranslatedCategory, (cur?.Count ?? 0).ToString(), c.Item2.ToString(), "", "", c.Item1.Details.Shortname }; int rn = dataGridViewSynthesis.Rows.Add(values); dataGridViewSynthesis.Rows[rn].ReadOnly = true; // disable editing wanted.. } } if (fdrow >= 0 && dataGridViewSynthesis.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewSynthesis.SafeFirstDisplayedScrollingRowIndex(fdrow); } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this, true) + " EN " + displaynumber + " Begin Display"); if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewEngineering.FirstDisplayedScrollingRowIndex; // remember where we were displaying MaterialCommoditiesRecipe.ResetUsed(mcl); wantedList = new List <Tuple <Recipes.Recipe, int> >(); string engineers = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbEngFilterSave, "All"); List <string> engList = engineers.Split(';').ToList <string>(); string modules = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbModFilterSave, "All"); List <string> modList = modules.Split(';').ToList <string>(); string levels = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string upgrades = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbUpgradeFilterSave, "All"); string[] upgArray = upgrades.Split(';'); string materials = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { int rno = (int)dataGridViewEngineering.Rows[i].Tag; dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, Recipes.EngineeringRecipes[rno]).Item1.ToString(); bool visible = true; if (!(engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")) { if (engineers != "All") { var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>()); visible &= included.Count() > 0; } if (modules != "All") { var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>()); visible &= included.Count() > 0; } if (levels != "All") { visible &= lvlArray.Contains(Recipes.EngineeringRecipes[rno].level); } if (upgrades != "All") { visible &= upgArray.Contains(Recipes.EngineeringRecipes[rno].Name); } if (materials != "All") { var inglongname = Recipes.EngineeringRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewEngineering.Rows[i].Visible = visible; if (visible) { Recipes.Recipe r = Recipes.EngineeringRecipes[i]; Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, Recipes.EngineeringRecipes[rno], Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); dataGridViewEngineering[WantedCol.Index, i].Value = Wanted[rno].ToString(); dataGridViewEngineering[AvailableCol.Index, i].Value = res.Item2.ToString(); dataGridViewEngineering[NotesCol.Index, i].Value = res.Item3; dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4; dataGridViewEngineering[RecipeCol.Index, i].Value = r.IngredientsStringvsCurrent(last_he.MaterialCommodity); dataGridViewEngineering[RecipeCol.Index, i].ToolTipText = r.IngredientsStringLong; } if (Wanted[rno] > 0 && (visible || isEmbedded)) // embedded, need to { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], Wanted[rno])); } } if (!isEmbedded) { MaterialCommoditiesRecipe.ResetUsed(mcl); List <MaterialCommodities> shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count; // truncate previous shopping list.. foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.Details.Name)) // and add new.. { var cur = last_he.MaterialCommodity.Find(c.Details); // may be null int rn = dataGridViewEngineering.Rows.Add(); foreach (var cell in dataGridViewEngineering.Rows[rn].Cells.OfType <DataGridViewCell>()) { if (cell.OwningColumn == UpgradeCol) { cell.Value = c.Details.Name; } else if (cell.OwningColumn == MaxCol) { cell.Value = (cur?.Count ?? 0).ToString(); } else if (cell.OwningColumn == WantedCol) { cell.Value = c.scratchpad.ToString(); } else if (cell.OwningColumn == RecipeCol) { cell.Value = c.Details.Shortname; } else if (cell.ValueType == null || cell.ValueType.IsAssignableFrom(typeof(string))) { cell.Value = string.Empty; } } dataGridViewEngineering.Rows[rn].ReadOnly = true; // disable editing wanted.. } } if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewEngineering.FirstDisplayedScrollingRowIndex = fdrow; } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this) + " EN " + displaynumber + " Load Finished"); }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewEngineering.FirstDisplayedScrollingRowIndex; // remember where we were displaying var totals = MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present wantedList = new List <Tuple <Recipes.Recipe, int> >(); string engineers = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbEngFilterSave, "All"); List <string> engList = engineers.Split(';').ToList <string>(); string modules = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbModFilterSave, "All"); List <string> modList = modules.Split(';').ToList <string>(); string levels = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string upgrades = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbUpgradeFilterSave, "All"); string[] upgArray = upgrades.Split(';'); string materials = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { int rno = (int)dataGridViewEngineering.Rows[i].Tag; dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, Recipes.EngineeringRecipes[rno]).Item1.ToString(); bool visible = true; if (!(engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")) { if (engineers != "All") { var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>()); visible &= included.Count() > 0; } if (modules != "All") { var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>()); visible &= included.Count() > 0; } if (levels != "All") { visible &= lvlArray.Contains(Recipes.EngineeringRecipes[rno].level); } if (upgrades != "All") { visible &= upgArray.Contains(Recipes.EngineeringRecipes[rno].Name); } if (materials != "All") { var inglongname = Recipes.EngineeringRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewEngineering.Rows[i].Visible = visible; if (visible) { Recipes.Recipe r = Recipes.EngineeringRecipes[i]; Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals, Recipes.EngineeringRecipes[rno], Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); dataGridViewEngineering[WantedCol.Index, i].Value = Wanted[rno].ToString(); dataGridViewEngineering[AvailableCol.Index, i].Value = res.Item2.ToString(); dataGridViewEngineering[NotesCol.Index, i].Value = res.Item3; dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4; dataGridViewEngineering[RecipeCol.Index, i].Value = r.IngredientsStringvsCurrent(last_he.MaterialCommodity); dataGridViewEngineering[RecipeCol.Index, i].ToolTipText = r.IngredientsStringLong; } if (Wanted[rno] > 0 && (visible || isEmbedded)) // embedded, need to { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], Wanted[rno])); } } if (!isEmbedded) { var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count; // truncate previous shopping list.. foreach (var c in shoppinglist) // and add new.. { var cur = last_he.MaterialCommodity.Find(c.Item1.Details); // may be null DataGridViewRow r = dataGridViewEngineering.RowTemplate.Clone() as DataGridViewRow; r.CreateCells(dataGridViewEngineering, c.Item1.Details.Name, "", "", "", c.Item2.ToString(), (cur?.Count ?? 0).ToString(), "", c.Item1.Details.Shortname, ""); r.ReadOnly = true; dataGridViewEngineering.Rows.Add(r); } } if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewEngineering.FirstDisplayedScrollingRowIndex = fdrow; } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this, true) + " SY " + displaynumber + " Begin Display"); if (last_he != null) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); int fdrow = dataGridViewSynthesis.FirstDisplayedScrollingRowIndex; // remember where we were displaying MaterialCommoditiesRecipe.ResetUsed(mcl); wantedList = new List <Tuple <Recipes.Recipe, int> >(); string recep = SQLiteDBClass.GetSettingString(DbRecipeFilterSave, "All"); string[] recipeArray = recep.Split(';'); string levels = SQLiteDBClass.GetSettingString(DbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string materials = SQLiteDBClass.GetSettingString(DbMaterialFilterSave, "All"); List <string> matList = new List <string>(); if (materials != "All" && materials != "None") // if an active list { foreach (string m in materials.Split(';')) { var e = matLookUp.Find(x => x.Item2 == m); // find it, add if (e != null) { matList.Add(e.Item1); } } } for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) { int rno = (int)dataGridViewSynthesis.Rows[i].Tag; dataGridViewSynthesis.Rows[i].Cells[2].Value = MaterialCommoditiesRecipe.HowManyLeft(mcl, Recipes.SynthesisRecipes[rno]).Item1.ToStringInvariant(); bool visible = true; if (recep != "All" || levels != "All" || materials != "All") { visible = false; // presume off if (recep == "All") { visible = true; } else { visible = recipeArray.Contains(Recipes.SynthesisRecipes[rno].name); } if (levels != "All") { visible = visible && lvlArray.Contains(Recipes.SynthesisRecipes[rno].level); } if (materials != "All") { var included = matList.Intersect <string>(Recipes.SynthesisRecipes[rno].ingredients.ToList <string>()); visible = visible && included.Count() > 0; } } dataGridViewSynthesis.Rows[i].Visible = visible; } for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) { int rno = (int)dataGridViewSynthesis.Rows[i].Tag; if (dataGridViewSynthesis.Rows[i].Visible) { Tuple <int, int, string, string> res = MaterialCommoditiesRecipe.HowManyLeft(mcl, Recipes.SynthesisRecipes[rno], Wanted[rno]); //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2); using (DataGridViewRow row = dataGridViewSynthesis.Rows[i]) { row.Cells[3].Value = Wanted[rno].ToStringInvariant(); row.Cells[4].Value = res.Item2.ToStringInvariant(); row.Cells[5].Value = res.Item3; row.Cells[5].ToolTipText = res.Item4; } } if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded)) { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.SynthesisRecipes[rno], Wanted[rno])); } } dataGridViewSynthesis.RowCount = Recipes.SynthesisRecipes.Count; // truncate previous shopping list.. if (!isEmbedded) { MaterialCommoditiesRecipe.ResetUsed(mcl); List <MaterialCommodities> shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcl); shoppinglist.Sort(delegate(MaterialCommodities left, MaterialCommodities right) { return(left.Details.Name.CompareTo(right.Details.Name)); }); foreach (MaterialCommodities c in shoppinglist) // and add new.. { Object[] values = { c.Details.Name, "", c.scratchpad.ToStringInvariant(), "", c.Details.Shortname }; int rn = dataGridViewSynthesis.Rows.Add(values); dataGridViewSynthesis.Rows[rn].ReadOnly = true; // disable editing wanted.. } } if (fdrow >= 0 && dataGridViewSynthesis.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewSynthesis.FirstDisplayedScrollingRowIndex = fdrow; } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this) + " SY " + displaynumber + " Load Finished"); }
private async void Display() { HistoryEntry last_he = userControlSynthesis.CurrentHistoryEntry; // sync with what its showing if (EngineeringWanted != null && SynthesisWanted != null && last_he != null) // if we have all the ingredients (get it!) { List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false); var totals = MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; Color backcolour = this.BackColor; List <Tuple <Recipes.Recipe, int> > totalWanted = EngineeringWanted.Concat(SynthesisWanted).ToList(); string techBrokers = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DBTechBrokerFilterSave, "None"); if (techBrokers != "None") { List <string> techBrokerList = techBrokers.Split(';').ToList <string>(); foreach (Recipes.Recipe r in Recipes.TechBrokerUnlocks) { if (techBrokers == "All" || techBrokerList.Contains(r.Name)) { totalWanted.Add(new Tuple <Recipes.Recipe, int>(r, 1)); } } } string specialeffects = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString(DBSpecialEffectsFilterSave, "None"); if (specialeffects != "None") { List <string> seList = specialeffects.Split(';').ToList <string>(); foreach (Recipes.Recipe r in Recipes.SpecialEffects) { if (specialeffects == "All" || specialeffects.Contains(r.Name)) { totalWanted.Add(new Tuple <Recipes.Recipe, int>(r, 1)); } } } var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(totalWanted, mcl); JournalScan sd = null; StarScan.SystemNode last_sn = null; if (last_he.IsLanded && (showListAvailability || showPlanetMats)) { sd = discoveryform.history.GetScans(last_he.System.Name).Where(sc => sc.BodyName == last_he.WhereAmI).FirstOrDefault(); } if (!last_he.IsLanded && showSystemAvailability) { last_sn = await discoveryform.history.starscan.FindSystemAsync(last_he.System, useEDSMForSystemAvailability); } StringBuilder wantedList = new StringBuilder(); if (shoppinglist.Any()) { double available; wantedList.Append("Needed Mats".T(EDTx.UserControlShoppingList_NM) + ":" + Environment.NewLine); List <string> capExceededMats = new List <string>(); foreach (var c in shoppinglist) // and add new.. { string present = ""; if (showListAvailability) { if (sd != null && sd.HasMaterials) { if (sd.Materials.TryGetValue(c.Item1.Details.FDName, out available)) { present = $" {available.ToString("N1")}%"; } else { present = " -"; } } } wantedList.Append($" {c.Item2} {c.Item1.Details.Name}{present}"); int?onHand = mcl.Where(m => m.Details.Shortname == c.Item1.Details.Shortname).FirstOrDefault()?.Count; int totalReq = c.Item2 + (onHand.HasValue ? onHand.Value : 0); if ((c.Item1.Details.Type == MaterialCommodityData.ItemType.VeryCommon && totalReq > VeryCommonCap) || (c.Item1.Details.Type == MaterialCommodityData.ItemType.Common && totalReq > CommonCap) || (c.Item1.Details.Type == MaterialCommodityData.ItemType.Standard && totalReq > StandardCap) || (c.Item1.Details.Type == MaterialCommodityData.ItemType.Rare && totalReq > RareCap) || (c.Item1.Details.Type == MaterialCommodityData.ItemType.VeryRare && totalReq > VeryRareCap)) { capExceededMats.Add(c.Item1.Details.Name); } if (!last_he.IsLanded && last_sn != null) { var landables = last_sn.Bodies.Where(b => b.ScanData != null && (!b.ScanData.IsEDSMBody || useEDSMForSystemAvailability) && b.ScanData.HasMaterials && b.ScanData.Materials.ContainsKey(c.Item1.Details.FDName)); if (landables.Count() > 0) { wantedList.Append("\n "); List <Tuple <string, double> > allMats = new List <Tuple <string, double> >(); foreach (StarScan.ScanNode sn in landables) { sn.ScanData.Materials.TryGetValue(c.Item1.Details.FDName, out available); allMats.Add(new Tuple <string, double>(sn.fullname.Replace(last_he.System.Name, "", StringComparison.InvariantCultureIgnoreCase).Trim(), available)); } allMats = allMats.OrderByDescending(m => m.Item2).ToList(); int n = 1; foreach (Tuple <string, double> m in allMats) { if (n % 6 == 0) { wantedList.Append("\n "); } wantedList.Append($"{m.Item1.ToUpperInvariant()}: {m.Item2.ToString("N1")}% "); n++; } } } wantedList.Append("\n"); } if (capExceededMats.Any()) { wantedList.Append(Environment.NewLine + "Filling Shopping List would exceed capacity for:".T(EDTx.UserControlShoppingList_FS)); foreach (string mat in capExceededMats) { wantedList.Append($"\n {mat}"); } } } else { wantedList.Append("No materials currently required.".T(EDTx.UserControlShoppingList_NoMat)); } if (showMaxInjections) { var totals2 = MaterialCommoditiesRecipe.TotalList(mcl); // start with totals present Tuple <int, int, string, string> basic = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals2, Recipes.SynthesisRecipes.First(r => r.Name == "FSD" && r.level == "Basic")); Tuple <int, int, string, string> standard = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals2, Recipes.SynthesisRecipes.First(r => r.Name == "FSD" && r.level == "Standard")); Tuple <int, int, string, string> premium = MaterialCommoditiesRecipe.HowManyLeft(mcl, totals2, Recipes.SynthesisRecipes.First(r => r.Name == "FSD" && r.level == "Premium")); wantedList.Append(Environment.NewLine + string.Format("Max FSD Injections\r\n {0} Basic\r\n {1} Standard\r\n {2} Premium".T(EDTx.UserControlShoppingList_FSD), basic.Item1, standard.Item1, premium.Item1)); } if (showPlanetMats && sd != null && sd.HasMaterials) { wantedList.Append(Environment.NewLine + Environment.NewLine + string.Format("Materials on {0}".T(EDTx.UserControlShoppingList_MO), last_he.WhereAmI) + Environment.NewLine); foreach (KeyValuePair <string, double> mat in sd.Materials) { int?onHand = mcl.Where(m => m.Details.FDName == mat.Key).FirstOrDefault()?.Count; MaterialCommodityData md = GetByFDName(mat.Key); int max = md.MaterialLimit().Value; if (!hidePlanetMatsWithNoCapacity || (onHand.HasValue ? onHand.Value : 0) < max) { wantedList.AppendFormat(" {0} {1}% ({2}/{3})\n", System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(mat.Key.ToLowerInvariant()), mat.Value.ToString("N1"), (onHand.HasValue ? onHand.Value : 0), max); } } } Font font = discoveryform.theme.GetFont; pictureBoxList.ClearImageList(); ExtPictureBox.ImageElement displayList = pictureBoxList.AddTextAutoSize(new Point(0, 0), new Size(1000, 1000), wantedList.ToNullSafeString(), font, textcolour, backcolour, 1.0F); pictureBoxList.Render(); font.Dispose(); try { splitContainerVertical.Panel1MinSize = displayList.Image.Width + 8; // panel left has minimum width to accomodate the text } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Swallowed exception " + e); // swallow the exception - seen an instance of it but wan't reproduce. #2512. } if (IsTransparent) { RevertToNormalSize(); int minWidth = Math.Max(((UserControlForm)FindForm()).TitleBarMinWidth(), displayList.Image.Width) + 8; RequestTemporaryResize(new Size(minWidth, displayList.Image.Height + 4)); } else { RevertToNormalSize(); // eng/synth is on, normal size } } // if transparent, we don't show the eng/synth panels userControlEngineering.Visible = userControlSynthesis.Visible = !IsTransparent; userControlEngineering.Enabled = userControlSynthesis.Enabled = !IsTransparent; buttonTechBroker.Visible = buttonSpecialEffects.Visible = !IsTransparent; }
private void Display() { //DONT turn on sorting in the future, thats not how it works. You click and drag to sort manually since it gives you // the order of recipies. List <Tuple <Recipes.Recipe, int> > wantedList = null; if (last_he != null) { var mcllist = discoveryform.history.MaterialCommoditiesMicroResources.Get(last_he.MaterialCommodity); // mcl at this point var lastengprog = discoveryform.history.GetLastHistoryEntry(x => x.EntryType == JournalTypeEnum.EngineerProgress, last_he); int fdrow = dataGridViewEngineering.SafeFirstDisplayedScrollingRowIndex(); // remember where we were displaying var totals = MaterialCommoditiesRecipe.TotalList(mcllist); // start with totals present wantedList = new List <Tuple <Recipes.Recipe, int> >(); string engineers = GetSetting(dbEngFilterSave, "All"); List <string> engList = engineers.Split(';').ToList <string>(); string modules = GetSetting(dbModFilterSave, "All"); List <string> modList = modules.Split(';').ToList <string>(); string levels = GetSetting(dbLevelFilterSave, "All"); string[] lvlArray = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';'); string upgrades = GetSetting(dbUpgradeFilterSave, "All"); string[] upgArray = upgrades.Split(';'); string materials = GetSetting(dbMaterialFilterSave, "All"); var matList = materials.Split(';'); // list of materials to show for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { int rno = (int)dataGridViewEngineering.Rows[i].Tag; // maximum we can make, not taking any, so not changing totals dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesRecipe.HowManyLeft(mcllist, totals, Recipes.EngineeringRecipes[rno]).Item1.ToString(); bool visible = true; if (!(engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")) { if (engineers != "All") { var included = engList.Intersect <string>(Recipes.EngineeringRecipes[rno].engineers.ToList <string>()); visible &= included.Count() > 0; } if (modules != "All") { var included = modList.Intersect <string>(Recipes.EngineeringRecipes[rno].modules.ToList <string>()); visible &= included.Count() > 0; } if (levels != "All") { visible &= lvlArray.Contains(Recipes.EngineeringRecipes[rno].level); } if (upgrades != "All") { visible &= upgArray.Contains(Recipes.EngineeringRecipes[rno].Name); } if (materials != "All") { var inglongname = Recipes.EngineeringRecipes[rno].Ingredients.Select(x => x.Name); var included = matList.Intersect <string>(inglongname); visible &= included.Count() > 0; } } dataGridViewEngineering.Rows[i].Visible = visible; if (visible) { Recipes.Recipe r = Recipes.EngineeringRecipes[i]; var res = MaterialCommoditiesRecipe.HowManyLeft(mcllist, totals, Recipes.EngineeringRecipes[rno], WantedPerRecipe[rno]); // System.Diagnostics.Debug.WriteLine($"{i} Recipe {rno} executed {WantedPerRecipe[rno]}; {res.Item2}, {res.Item3} "); dataGridViewEngineering[WantedCol.Index, i].Value = WantedPerRecipe[rno].ToString(); dataGridViewEngineering[AvailableCol.Index, i].Value = res.Item2.ToString(); dataGridViewEngineering[PercentageCol.Index, i].Value = res.Item5.ToString("N0"); dataGridViewEngineering[NotesCol.Index, i].Value = res.Item3; dataGridViewEngineering[NotesCol.Index, i].ToolTipText = res.Item4; dataGridViewEngineering[RecipeCol.Index, i].Value = r.IngredientsStringvsCurrent(mcllist); dataGridViewEngineering[RecipeCol.Index, i].ToolTipText = r.IngredientsStringLong; dataGridViewEngineering.Rows[i].DefaultCellStyle.BackColor = (res.Item5 >= 100.0) ? ExtendedControls.Theme.Current.GridHighlightBack : ExtendedControls.Theme.Current.GridCellBack; } if (WantedPerRecipe[rno] > 0 && (visible || isEmbedded)) // embedded, need to { wantedList.Add(new Tuple <Recipes.Recipe, int>(Recipes.EngineeringRecipes[rno], WantedPerRecipe[rno])); } if (lastengprog != null) { string[] list = dataGridViewEngineering[EngineersCol.Index, i].Tag as string[]; string[] state = ((EliteDangerousCore.JournalEvents.JournalEngineerProgress)lastengprog.journalEntry).ApplyProgress(list); dataGridViewEngineering[EngineersCol.Index, i].Value = string.Join(Environment.NewLine, state); } } if (!isEmbedded) { var shoppinglist = MaterialCommoditiesRecipe.GetShoppingList(wantedList, mcllist); dataGridViewEngineering.RowCount = Recipes.EngineeringRecipes.Count; // truncate previous shopping list.. foreach (var c in shoppinglist) // and add new.. { var cur = mcllist.Find((x) => x.Details == c.Item1.Details); // may be null DataGridViewRow r = dataGridViewEngineering.RowTemplate.Clone() as DataGridViewRow; r.CreateCells(dataGridViewEngineering, c.Item1.Details.Name, "", "", "", c.Item2.ToString(), (cur?.Count ?? 0).ToString(), "", c.Item1.Details.Shortname, ""); r.ReadOnly = true; dataGridViewEngineering.Rows.Add(r); } } if (fdrow >= 0 && dataGridViewEngineering.Rows[fdrow].Visible) // better check visible, may have changed.. { dataGridViewEngineering.SafeFirstDisplayedScrollingRowIndex(fdrow); } } if (OnDisplayComplete != null) { OnDisplayComplete(wantedList); } }
// mcllist may be null, cursystem may be null as may crafts public void UpdateStatus(string status, ISystem cursystem, List <MaterialCommodityMicroResource> mcllist, List <HistoryEntry> crafts) { labelEngineerStatus.Text = status; string dist = ""; if (cursystem != null && EngineerInfo != null) { var d = cursystem.Distance(EngineerInfo.X, EngineerInfo.Y, EngineerInfo.Z); dist = d.ToString("0.#") + " ly"; } labelEngineerDistance.Text = dist; if (mcllist != null) // may be null { var totals = MaterialCommoditiesRecipe.TotalList(mcllist); // start with totals present dataViewScrollerPanel.Suspend(); dataGridViewEngineering.SuspendLayout(); var wwmode = dataGridViewEngineering.DefaultCellStyle.WrapMode; dataGridViewEngineering.DefaultCellStyle.WrapMode = DataGridViewTriState.False; // seems to make it a tad faster foreach (DataGridViewRow row in dataGridViewEngineering.Rows) { row.Visible = true; // if we hide stuff, we just make it invisible, we do not remove it Recipes.EngineeringRecipe r = row.Tag as Recipes.EngineeringRecipe; string tooltip = ""; int craftcount = 0; foreach (var c in crafts.EmptyIfNull()) // all crafts { var cb = c.journalEntry as EliteDangerousCore.JournalEvents.JournalEngineerCraftBase; if (cb != null) // if an craft base type, check name and level { if (cb.Engineering.BlueprintName.Equals(r.fdname, StringComparison.InvariantCultureIgnoreCase) && cb.Engineering.Level == r.LevelInt) { tooltip = tooltip.AppendPrePad(c.EventTimeUTC.ToString() + " " + (c.ShipInformation?.Name ?? "?") + " " + (cb.Engineering.ExperimentalEffect_Localised ?? ""), Environment.NewLine); craftcount++; } } else if (c.EntryType == JournalTypeEnum.TechnologyBroker) // if tech broker, check name { var tb = c.journalEntry as EliteDangerousCore.JournalEvents.JournalTechnologyBroker; //string unl = string.Join(",", tb.ItemsUnlocked.Select(x=>x.Name)); System.Diagnostics.Debug.WriteLine($"{unl} {r.fdname}"); if (tb.ItemsUnlocked != null && Array.FindIndex(tb.ItemsUnlocked, x => x.Name.Equals(r.fdname, StringComparison.InvariantCultureIgnoreCase)) >= 0) { tooltip = tooltip.AppendPrePad(c.EventTimeUTC.ToString() + " " + (tb.BrokerType ?? "") + " " + string.Join(",", tb.ItemsUnlocked.Select(x => x.Name_Localised))); craftcount++; } } } row.Cells[CraftedCol.Index].ToolTipText = tooltip; var res = MaterialCommoditiesRecipe.HowManyLeft(mcllist, totals, r, WantedPerRecipe[row.Index], reducetotals: false); // recipes not chained not in order row.Cells[MaxCol.Index].Value = res.Item1.ToString(); row.Cells[CraftedCol.Index].Value = CraftedCol.HeaderText == "-" ? "" : craftcount.ToString(); row.Cells[PercentageCol.Index].Value = res.Item5.ToString("N0"); row.Cells[NotesCol.Index].Value = res.Item3; row.Cells[NotesCol.Index].ToolTipText = res.Item4; row.Cells[RecipeCol.Index].Value = r.IngredientsStringvsCurrent(mcllist); row.DefaultCellStyle.BackColor = (res.Item5 >= 100.0) ? ExtendedControls.Theme.Current.GridHighlightBack : ExtendedControls.Theme.Current.GridCellBack; } dataGridViewEngineering.DefaultCellStyle.WrapMode = wwmode; dataGridViewEngineering.ResumeLayout(); dataViewScrollerPanel.Resume(); } labelCrafts.Text = crafts != null ? (crafts.Count + " crafts") : ""; }