public void SetupDisplay() { //System.Diagnostics.Debug.WriteLine($"Setup {BaseUtils.AppTicks.TickCountLap("s1", true)}"); if (engineerpanels != null) { foreach (var ep in engineerpanels) { ep.UnInstallEvents(); } panelEngineers.ClearControls(); engineerpanels = null; } //System.Diagnostics.Debug.WriteLine($"Cleaned {BaseUtils.AppTicks.TickCountLap("s1")}"); List <string> engineers = Recipes.EngineeringRecipes.SelectMany(r => r.engineers).Distinct().ToList(); engineers.Sort(); engineerpanels = new List <EngineerStatusPanel>(); string engineerssetting = GetSetting(dbEngFilterSave, "All"); string colsetting = DGVSaveName(); panelEngineers.SuspendLayout(); int panelvspacing = 210; int vpos = 0; foreach (var name in engineers) { if (engineerssetting == "All" || engineerssetting.Contains(name)) { var ep = new EngineerStatusPanel(); ItemData.EngineeringInfo ei = ItemData.GetEngineerInfo(name); ep.Init(name, ei?.StarSystem ?? "", ei?.BaseName ?? "", ei?.Planet ?? "", ei, GetSetting(dbWSave + "_" + name, ""), colsetting); ep.UpdateWordWrap(extCheckBoxWordWrap.Checked); ep.Redisplay += () => { PutSetting(dbWSave + "_" + name, ep.WantedPerRecipe.ToString(",")); UpdateDisplay(); }; ep.ColumnSetupChanged += (panel) => { System.Diagnostics.Debug.WriteLine($"Panel {panel.Name} changed"); panel.SaveDGV(colsetting); foreach (var p in engineerpanels) { if (p != panel) { p.LoadDGV(colsetting); } } }; // System.Diagnostics.Debug.WriteLine($"Initial {name} {BaseUtils.AppTicks.TickCountLap("s1")}"); panelEngineers.Controls.Add(ep); // need to set bounds after adding, for some reason ep.Bounds = new Rectangle(0, vpos, panelEngineers.Width - panelEngineers.ScrollBarWidth - 4, panelvspacing); ep.InstallColumnEvents(); engineerpanels.Add(ep); vpos += panelvspacing + 4; // System.Diagnostics.Debug.WriteLine($"Made {name} Complete {BaseUtils.AppTicks.TickCountLap("s1")}"); } } panelEngineers.ResumeLayout(); //System.Diagnostics.Debug.WriteLine($"Setup Complete {BaseUtils.AppTicks.TickCountLap("s1")}"); }
public void Init(string name, string starsystem, string planet, string basename, ItemData.EngineeringInfo ei, string wantedsettings, string colsetting) { this.Name = name; EngineerInfo = ei; ExtendedControls.Theme.Current?.ApplyStd(this); var enumlist = new Enum[] { EDTx.UserControlEngineering_UpgradeCol, EDTx.UserControlEngineering_ModuleCol, EDTx.UserControlEngineering_LevelCol, EDTx.UserControlEngineering_MaxCol, EDTx.UserControlEngineering_WantedCol, EDTx.UserControlEngineering_CraftedCol, EDTx.UserControlEngineering_NotesCol, EDTx.UserControlEngineering_RecipeCol, EDTx.UserControlEngineering_EngineersCol, }; BaseUtils.Translator.Instance.TranslateControls(this, enumlist, null, "UserControlEngineering"); // share IDs with Engineering panel./ dataGridViewEngineering.LoadColumnSettings(colsetting, (a) => EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(a, int.MinValue), (b) => EliteDangerousCore.DB.UserDatabase.Instance.GetSettingDouble(b, double.MinValue)); labelEngineerName.Text = name; labelEngineerStatus.Text = ""; engineerImage.Image = BaseUtils.Icons.IconSet.GetIcon("Engineers." + name); labelEngineerStarSystem.Text = starsystem; labelPlanet.Text = planet; labelBaseName.Text = basename; labelEngineerDistance.Text = ""; labelCrafts.Text = ""; if (name == "Weapon" || name == "Suit") // these are not currently recorded in EngineerList { CraftedCol.HeaderText = "-"; } dataGridViewEngineering.MakeDoubleBuffered(); dataViewScrollerPanel.Suspend(); for (int i = 0; i < Recipes.EngineeringRecipes.Count; i++) { if (Recipes.EngineeringRecipes[i].engineers.Contains(name)) { Recipes.EngineeringRecipe r = Recipes.EngineeringRecipes[i]; var row = dataGridViewEngineering.Rows[dataGridViewEngineering.Rows.Add()]; row.Tag = r; row.Cells[UpgradeCol.Index].Value = r.Name; row.Cells[ModuleCol.Index].Value = r.modulesstring; row.Cells[LevelCol.Index].Value = r.level; row.Cells[EngineersCol.Index].Tag = r.engineers; // keep list in tag row.Cells[EngineersCol.Index].Value = string.Join(Environment.NewLine, r.engineers); row.Cells[RecipeCol.Index].ToolTipText = r.IngredientsStringLong; } } WantedPerRecipe = wantedsettings.RestoreArrayFromString(0, RecipesCount); for (int i = 0; i < RecipesCount; i++) { dataGridViewEngineering.Rows[i].Cells[WantedCol.Index].Value = WantedPerRecipe[i].ToString(); } dataViewScrollerPanel.Resume(); //System.Diagnostics.Debug.WriteLine($"Engineer {name} Recipes {dataGridViewEngineering.RowCount}"); delaytime.Tick += Delaytime_Tick; }