Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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)
            {
                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);
            }
        }