public override void Init() { dataGridViewSynthesis.MakeDoubleBuffered(); dataGridViewSynthesis.DefaultCellStyle.WrapMode = DataGridViewTriState.False; dataGridViewSynthesis.RowTemplate.Height = 26; Order = SQLiteDBClass.GetSettingString(DbOSave, "").RestoreArrayFromString(0, Recipes.SynthesisRecipes.Count); if (Order.Max() >= Recipes.SynthesisRecipes.Count || Order.Min() < 0 || Order.Distinct().Count() != Recipes.SynthesisRecipes.Count) // if not distinct.. { for (int i = 0; i < Order.Length; i++) // reset { Order[i] = i; } } Wanted = SQLiteDBClass.GetSettingString(DbWSave, "").RestoreArrayFromString(0, Recipes.SynthesisRecipes.Count); var rcpes = Recipes.SynthesisRecipes.Select(r => r.name).Distinct().ToList(); rcpes.Sort(); rfs = new RecipeFilterSelector(rcpes); rfs.Changed += FilterChanged; var lvls = Recipes.SynthesisRecipes.Select(r => r.level).Distinct().ToList(); lvls.Sort(); lfs = new RecipeFilterSelector(lvls); lfs.Changed += FilterChanged; List <string> matShortNames = Recipes.SynthesisRecipes.SelectMany(r => r.ingredients).Distinct().ToList(); matLookUp = matShortNames.Select(sn => Tuple.Create <string, string>(sn, MaterialCommodityData.GetByShortName(sn).Name)).ToList(); List <string> matLongNames = matLookUp.Select(lu => lu.Item2).ToList(); matLongNames.Sort(); mfs = new RecipeFilterSelector(matLongNames); mfs.Changed += FilterChanged; for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++) // pre-fill array.. preventing the crash on cell edit when you { int rno = Order[i]; Recipes.SynthesisRecipe r = Recipes.SynthesisRecipes[rno]; int rown = dataGridViewSynthesis.Rows.Add(); using (DataGridViewRow row = dataGridViewSynthesis.Rows[rown]) { row.Cells[0].Value = r.name; // debug rno + ":" + r.name; row.Cells[1].Value = r.level; row.Cells[6].Value = r.ingredientsstring; row.Cells[6].ToolTipText = r.ingredientsstringlong; row.Tag = rno; row.Visible = false; } } isHistoric = SQLiteDBClass.GetSettingBool(DbHistoricMatsSave, false); discoveryform.OnNewEntry += Discoveryform_OnNewEntry; BaseUtils.Translator.Instance.Translate(this); BaseUtils.Translator.Instance.Translate(toolTip, this); }
public override void Init() { dataGridViewEngineering.MakeDoubleBuffered(); dataGridViewEngineering.DefaultCellStyle.WrapMode = DataGridViewTriState.False; dataGridViewEngineering.RowTemplate.Height = 26; Order = SQLiteDBClass.GetSettingString(DbOSave, "").RestoreArrayFromString(0, Recipes.EngineeringRecipes.Count); if (Order.Max() >= Recipes.EngineeringRecipes.Count || Order.Min() < 0 || Order.Distinct().Count() != Recipes.EngineeringRecipes.Count) // if not distinct.. { for (int i = 0; i < Order.Length; i++) // reset { Order[i] = i; } } Wanted = SQLiteDBClass.GetSettingString(DbWSave, "").RestoreArrayFromString(0, Recipes.EngineeringRecipes.Count); List <string> engineers = Recipes.EngineeringRecipes.SelectMany(r => r.engineers).Distinct().ToList(); engineers.Sort(); efs = new RecipeFilterSelector(engineers); efs.Changed += FilterChanged; lfs = new RecipeFilterSelector(levels); lfs.Changed += FilterChanged; List <string> modules = Recipes.EngineeringRecipes.SelectMany(r => r.modules).Distinct().ToList(); modules.Sort(); mfs = new RecipeFilterSelector(modules); mfs.Changed += FilterChanged; var upgrades = Recipes.EngineeringRecipes.Select(r => r.name).Distinct().ToList(); upgrades.Sort(); ufs = new RecipeFilterSelector(upgrades); ufs.Changed += FilterChanged; List <string> matShortNames = Recipes.EngineeringRecipes.SelectMany(r => r.ingredients).Distinct().ToList(); matLookUp = matShortNames.ToDictionary(sn => MaterialCommodityData.GetByShortName(sn).Name, sn => sn); List <string> matLongNames = matLookUp.Keys.ToList(); matLongNames.Sort(); matfs = new RecipeFilterSelector(matLongNames); matfs.Changed += FilterChanged; for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) // pre-fill array.. preventing the crash on cell edit when you { int rno = Order[i]; Recipes.EngineeringRecipe r = Recipes.EngineeringRecipes[rno]; int rown = dataGridViewEngineering.Rows.Add(); DataGridViewRow row = dataGridViewEngineering.Rows[rown]; row.Cells[UpgradeCol.Index].Value = r.name; // debug rno + ":" + r.name; row.Cells[ModuleCol.Index].Value = r.modulesstring; row.Cells[LevelCol.Index].Value = r.level; row.Cells[RecipeCol.Index].Value = r.ingredientsstring; row.Cells[RecipeCol.Index].ToolTipText = r.ingredientsstringlong; row.Cells[EngineersCol.Index].Value = r.engineersstring; row.Tag = rno; row.Visible = false; } isHistoric = SQLiteDBClass.GetSettingBool(DbHistoricMatsSave, false); discoveryform.OnNewEntry += Discoveryform_OnNewEntry; BaseUtils.Translator.Instance.Translate(this); BaseUtils.Translator.Instance.Translate(toolTip, this); }