Exemple #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 <MaterialCommoditiesList.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

                MaterialCommoditiesList.ResetUsed(mcl);

                wantedList = new List <Tuple <MaterialCommoditiesList.Recipe, int> >();

                string        engineers = SQLiteDBClass.GetSettingString(DbEngFilterSave, "All");
                List <string> engList   = engineers.Split(';').ToList <string>();
                string        modules   = SQLiteDBClass.GetSettingString(DbModFilterSave, "All");
                string[]      modArray  = modules.Split(';');
                string        levels    = SQLiteDBClass.GetSettingString(DbLevelFilterSave, "All");
                int[]         lvlArray  = (levels == "All" || levels == "None") ? new int[0] : levels.Split(';').Where(x => !string.IsNullOrEmpty(x)).Select(x => int.Parse(x)).ToArray();
                string        upgrades  = SQLiteDBClass.GetSettingString(DbUpgradeFilterSave, "All");
                string[]      upgArray  = upgrades.Split(';');
                string        materials = SQLiteDBClass.GetSettingString(DbMaterialFilterSave, "All");
                List <string> matList;
                if (materials == "All" || materials == "None")
                {
                    matList = new List <string>();
                }
                else
                {
                    matList = materials.Split(';').Where(x => !string.IsNullOrEmpty(x)).Select(m => matLookUp.Where(u => u.Item2 == m).First().Item1).ToList();
                }

                for (int i = 0; i < EngineeringRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewEngineering.Rows[i].Tag;
                    dataGridViewEngineering[MaxCol.Index, i].Value = MaterialCommoditiesList.HowManyLeft(mcl, EngineeringRecipes[rno]).Item1.ToStringInvariant();
                    bool visible = true;

                    if (engineers == "All" && modules == "All" && levels == "All" && upgrades == "All" && materials == "All")
                    {
                        visible = true;
                    }
                    else
                    {
                        visible = false;
                        if (engineers == "All")
                        {
                            visible = true;
                        }
                        else
                        {
                            var included = engList.Intersect <string>(EngineeringRecipes[rno].engineers.ToList <string>());
                            visible = included.Count() > 0;
                        }
                        if (modules == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && modArray.Contains(EngineeringRecipes[rno].module);
                        }
                        if (levels == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && lvlArray.Contains(EngineeringRecipes[rno].level);
                        }
                        if (upgrades == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && upgArray.Contains(EngineeringRecipes[rno].name);
                        }
                        if (materials == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            var included = matList.Intersect <string>(EngineeringRecipes[rno].ingredients.ToList <string>());
                            visible = visible && included.Count() > 0;
                        }
                    }

                    dataGridViewEngineering.Rows[i].Visible = visible;

                    if (visible)
                    {
                        Tuple <int, int, string> res = MaterialCommoditiesList.HowManyLeft(mcl, 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].ToStringInvariant();
                        dataGridViewEngineering[Available.Index, i].Value = res.Item2.ToStringInvariant();
                        dataGridViewEngineering[Notes.Index, i].Value     = res.Item3;
                    }
                    if (Wanted[rno] > 0 && (visible || isEmbedded))      // embedded, need to
                    {
                        wantedList.Add(new Tuple <MaterialCommoditiesList.Recipe, int>(EngineeringRecipes[rno], Wanted[rno]));
                    }
                }

                if (!isEmbedded)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.GetShoppingList(wantedList, mcl);
                    dataGridViewEngineering.RowCount = EngineeringRecipes.Count;             // truncate previous shopping list..
                    foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.name)) // and add new..
                    {
                        int rn = dataGridViewEngineering.Rows.Add();

                        foreach (var cell in dataGridViewEngineering.Rows[rn].Cells.OfType <DataGridViewCell>())
                        {
                            if (cell.OwningColumn == UpgradeCol)
                            {
                                cell.Value = c.name;
                            }
                            else if (cell.OwningColumn == WantedCol)
                            {
                                cell.Value = c.scratchpad.ToStringInvariant();
                            }
                            else if (cell.OwningColumn == Notes)
                            {
                                cell.Value = c.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);
            }
        }
Exemple #2
0
        private 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);
                MaterialCommoditiesList.ResetUsed(mcl);
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = this.BackColor;
                List <Tuple <MaterialCommoditiesList.Recipe, int> > totalWanted = EngineeringWanted.Concat(SynthesisWanted).ToList();

                List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.GetShoppingList(totalWanted, mcl);

                StringBuilder wantedList = new StringBuilder();

                if (shoppinglist.Any())
                {
                    wantedList.Append("Needed Mats:\n");
                    foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.name))      // and add new..
                    {
                        wantedList.AppendFormat("  {0} {1}\n", c.scratchpad, c.name);
                    }

                    int currentMats = mcl.Where(m => m.category == MaterialCommodityDB.MaterialManufacturedCategory || m.category == MaterialCommodityDB.MaterialRawCategory)
                                      .Sum(i => i.count);
                    int currentData = mcl.Where(m => m.category == MaterialCommodityDB.MaterialEncodedCategory).Sum(i => i.count);
                    int neededMats  = shoppinglist.Where(m => m.category == MaterialCommodityDB.MaterialManufacturedCategory || m.category == MaterialCommodityDB.MaterialRawCategory)
                                      .Sum(i => i.scratchpad);
                    int neededData = shoppinglist.Where(m => m.category == MaterialCommodityDB.MaterialEncodedCategory).Sum(i => i.scratchpad);

                    if (currentMats + neededMats > PhysicalInventoryCapacity || currentData + neededData > DataInventoryCapacity)
                    {
                        wantedList.Append("\nNeeded capacity");
                        if (currentMats + neededMats > PhysicalInventoryCapacity)
                        {
                            wantedList.AppendFormat("\n  {0} materials", currentMats + neededMats - PhysicalInventoryCapacity);
                        }
                        if (currentData + neededData > DataInventoryCapacity)
                        {
                            wantedList.AppendFormat("\n  {0} data", currentData + neededData - DataInventoryCapacity);
                        }
                    }
                }
                else
                {
                    wantedList.Append("No materials currently required.");
                }

                if (showMaxInjections)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    Tuple <int, int, string> basic    = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Basic"));
                    Tuple <int, int, string> standard = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Standard"));
                    Tuple <int, int, string> premium  = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Premium"));
                    wantedList.Append($"\nMax FSD Injections\n   {basic.Item1} Basic\n   {standard.Item1} Standard\n   {premium.Item1} Premium");
                }

                Font font = discoveryform.theme.GetFont;
                pictureBoxList.ClearImageList();
                PictureBoxHotspot.ImageElement displayList = pictureBoxList.AddTextAutoSize(new Point(0, 0), new Size(1000, 1000), wantedList.ToNullSafeString(), font, textcolour, backcolour, 1.0F);
                pictureBoxList.Render();
                font.Dispose();

                // if transparent, we don't show the eng/synth panels

                userControlEngineering.Visible = userControlSynthesis.Visible = !IsTransparent;
                userControlEngineering.Enabled = userControlSynthesis.Enabled = !IsTransparent;

                splitContainerVertical.Panel1MinSize = displayList.img.Width + 8;       // panel left has minimum width to accomodate the text

                if (IsTransparent)
                {
                    RevertToNormalSize();
                    int minWidth = Math.Max(((UserControlForm)FindForm()).TitleBarMinWidth(), displayList.img.Width) + 8;
                    RequestTemporaryResize(new Size(minWidth, displayList.img.Height + 4));
                }
                else
                {
                    RevertToNormalSize();       // eng/synth is on, normal size
                }
            }
        }
        private 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);
                MaterialCommoditiesList.ResetUsed(mcl);
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = this.BackColor;
                List <Tuple <MaterialCommoditiesList.Recipe, int> > totalWanted = EngineeringWanted.Concat(SynthesisWanted).ToList();

                List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.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)  //replace true with a setting
                {
                    last_sn = discoveryform.history.starscan.FindSystem(last_he.System, useEDSMForSystemAvailability);
                }

                StringBuilder wantedList = new StringBuilder();

                if (shoppinglist.Any())
                {
                    double available;
                    wantedList.Append("Needed Mats:\n");
                    foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.name))      // and add new..
                    {
                        string present = "";
                        if (showListAvailability)
                        {
                            if (sd != null)
                            {
                                if (sd.Materials.TryGetValue(c.fdname, out available))
                                {
                                    present = $" {available.ToString("N1")}%";
                                }
                                else
                                {
                                    present = " -";
                                }
                            }
                        }
                        wantedList.Append($"  {c.scratchpad} {c.name}{present}");
                        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.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.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();
                                foreach (Tuple <string, double> m in allMats)
                                {
                                    wantedList.Append($"{m.Item1}: {m.Item2.ToString("N1")}% ");
                                }
                            }
                        }
                        wantedList.Append("\n");
                    }

                    int currentMats = mcl.Where(m => m.category == MaterialCommodityDB.MaterialManufacturedCategory || m.category == MaterialCommodityDB.MaterialRawCategory)
                                      .Sum(i => i.count);
                    int currentData = mcl.Where(m => m.category == MaterialCommodityDB.MaterialEncodedCategory).Sum(i => i.count);
                    int neededMats  = shoppinglist.Where(m => m.category == MaterialCommodityDB.MaterialManufacturedCategory || m.category == MaterialCommodityDB.MaterialRawCategory)
                                      .Sum(i => i.scratchpad);
                    int neededData = shoppinglist.Where(m => m.category == MaterialCommodityDB.MaterialEncodedCategory).Sum(i => i.scratchpad);

                    if (currentMats + neededMats > PhysicalInventoryCapacity || currentData + neededData > DataInventoryCapacity)
                    {
                        wantedList.Append("\nCapacity Warning:");
                        if (currentMats + neededMats > PhysicalInventoryCapacity)
                        {
                            wantedList.Append($"\n  {PhysicalInventoryCapacity - currentMats}/{neededMats} materials space free");
                        }
                        if (currentData + neededData > DataInventoryCapacity)
                        {
                            wantedList.Append($"\n  {DataInventoryCapacity - currentData}/{neededData} data space free");
                        }
                        wantedList.Append("\n");
                    }
                }
                else
                {
                    wantedList.Append("No materials currently required.");
                }

                if (showMaxInjections)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    Tuple <int, int, string> basic    = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Basic"));
                    Tuple <int, int, string> standard = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Standard"));
                    Tuple <int, int, string> premium  = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Premium"));
                    wantedList.Append($"\nMax FSD Injections\n   {basic.Item1} Basic\n   {standard.Item1} Standard\n   {premium.Item1} Premium");
                }

                if (showPlanetMats && sd != null)  //for user configurable setting
                {
                    wantedList.Append($"\n\nMaterials on {last_he.WhereAmI}\n");
                    foreach (KeyValuePair <string, double> mat in sd.Materials)
                    {
                        wantedList.AppendFormat("   {0} {1}%\n", System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(mat.Key.ToLower()),
                                                mat.Value.ToString("N1"));
                    }
                }

                Font font = discoveryform.theme.GetFont;
                pictureBoxList.ClearImageList();
                PictureBoxHotspot.ImageElement displayList = pictureBoxList.AddTextAutoSize(new Point(0, 0), new Size(1000, 1000), wantedList.ToNullSafeString(), font, textcolour, backcolour, 1.0F);
                pictureBoxList.Render();
                font.Dispose();

                // if transparent, we don't show the eng/synth panels

                userControlEngineering.Visible = userControlSynthesis.Visible = !IsTransparent;
                userControlEngineering.Enabled = userControlSynthesis.Enabled = !IsTransparent;

                splitContainerVertical.Panel1MinSize = displayList.img.Width + 8;       // panel left has minimum width to accomodate the text

                if (IsTransparent)
                {
                    RevertToNormalSize();
                    int minWidth = Math.Max(((UserControlForm)FindForm()).TitleBarMinWidth(), displayList.img.Width) + 8;
                    RequestTemporaryResize(new Size(minWidth, displayList.img.Height + 4));
                }
                else
                {
                    RevertToNormalSize();       // eng/synth is on, normal size
                }
            }
        }
Exemple #4
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 <MaterialCommoditiesList.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

                MaterialCommoditiesList.ResetUsed(mcl);

                wantedList = new List <Tuple <MaterialCommoditiesList.Recipe, int> >();

                string sel = (string)comboBoxSynthesis.SelectedItem;

                for (int i = 0; i < Recipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    dataGridViewSynthesis.Rows[i].Cells[1].Value = MaterialCommoditiesList.HowManyLeft(mcl, Recipes[rno]).Item1.ToStringInvariant();
                    bool visible = true;
                    if (sel == "Travel")
                    {
                        visible = (rno < FirstAmmoRow);
                    }
                    if (sel == "Ammo")
                    {
                        visible = (rno >= FirstAmmoRow);
                    }
                    if (sel == "SRV")
                    {
                        visible = (rno >= FirstSRVRow && rno < FirstAmmoRow);
                    }

                    dataGridViewSynthesis.Rows[i].Visible = visible;
                }

                for (int i = 0; i < Recipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    if (dataGridViewSynthesis.Rows[i].Visible)
                    {
                        Tuple <int, int, string> res = MaterialCommoditiesList.HowManyLeft(mcl, Recipes[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[2].Value = Wanted[rno].ToStringInvariant();
                            row.Cells[3].Value = res.Item2.ToStringInvariant();
                            row.Cells[4].Value = res.Item3;
                        }
                    }
                    if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded))
                    {
                        wantedList.Add(new Tuple <MaterialCommoditiesList.Recipe, int>(Recipes[rno], Wanted[rno]));
                    }
                }

                dataGridViewSynthesis.RowCount = Recipes.Count;         // truncate previous shopping list..

                if (!isEmbedded)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.GetShoppingList(wantedList, mcl);
                    shoppinglist.Sort(delegate(MaterialCommodities left, MaterialCommodities right) { return(left.name.CompareTo(right.name)); });

                    foreach (MaterialCommodities c in shoppinglist)        // and add new..
                    {
                        Object[] values = { c.name, "", c.scratchpad.ToStringInvariant(), "", c.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);
            }
        }
Exemple #5
0
        private 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);
                MaterialCommoditiesList.ResetUsed(mcl);
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = this.BackColor;
                List <Tuple <MaterialCommoditiesList.Recipe, int> > totalWanted = EngineeringWanted.Concat(SynthesisWanted).ToList();
                string techBrokers = SQLiteDBClass.GetSettingString(DBTechBrokerFilterSave, "None");
                if (techBrokers != "None")
                {
                    List <string> techBrokerList = techBrokers.Split(';').ToList <string>();
                    foreach (MaterialCommoditiesList.Recipe r in TechBrokerUnlocks)
                    {
                        if (techBrokers == "All" || techBrokerList.Contains(r.name))
                        {
                            totalWanted.Add(new Tuple <MaterialCommoditiesList.Recipe, int>(r, 1));
                        }
                    }
                }

                List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.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 = discoveryform.history.starscan.FindSystem(last_he.System, useEDSMForSystemAvailability);
                }

                StringBuilder wantedList = new StringBuilder();

                if (shoppinglist.Any())
                {
                    double available;
                    wantedList.Append("Needed Mats:\n");
                    List <string> capExceededMats = new List <string>();
                    foreach (MaterialCommodities c in shoppinglist.OrderBy(mat => mat.name))      // and add new..
                    {
                        string present = "";
                        if (showListAvailability)
                        {
                            if (sd != null)
                            {
                                if (sd.Materials.TryGetValue(c.fdname, out available))
                                {
                                    present = $" {available.ToString("N1")}%";
                                }
                                else
                                {
                                    present = " -";
                                }
                            }
                        }
                        wantedList.Append($"  {c.scratchpad} {c.name}{present}");
                        int?onHand   = mcl.Where(m => m.shortname == c.shortname).FirstOrDefault()?.count;
                        int totalReq = c.scratchpad + (onHand.HasValue ? onHand.Value : 0);
                        if ((c.type == MaterialCommodityDB.MaterialFreqVeryCommon && totalReq > VeryCommonCap) ||
                            (c.type == MaterialCommodityDB.MaterialFreqCommon && totalReq > CommonCap) ||
                            (c.type == MaterialCommodityDB.MaterialFreqStandard && totalReq > StandardCap) ||
                            (c.type == MaterialCommodityDB.MaterialFreqRare && totalReq > RareCap) ||
                            (c.type == MaterialCommodityDB.MaterialFreqVeryRare && totalReq > VeryRareCap))
                        {
                            capExceededMats.Add(c.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.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.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("\nFilling Shopping List would exceed capacity for:");
                        foreach (string mat in capExceededMats)
                        {
                            wantedList.Append($"\n  {mat}");
                        }
                    }
                }
                else
                {
                    wantedList.Append("No materials currently required.");
                }

                if (showMaxInjections)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    Tuple <int, int, string> basic    = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Basic"));
                    Tuple <int, int, string> standard = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Standard"));
                    Tuple <int, int, string> premium  = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes.First(r => r.name == "FSD" && r.level == "Premium"));
                    wantedList.Append($"\nMax FSD Injections\n   {basic.Item1} Basic\n   {standard.Item1} Standard\n   {premium.Item1} Premium");
                }

                if (showPlanetMats && sd != null && sd.HasMaterials)
                {
                    wantedList.Append($"\n\nMaterials on {last_he.WhereAmI}\n");
                    foreach (KeyValuePair <string, double> mat in sd.Materials)
                    {
                        int?onHand             = mcl.Where(m => m.fdname == mat.Key).FirstOrDefault()?.count;
                        MaterialCommodityDB md = MaterialCommodityDB.GetCachedMaterial(mat.Key);
                        int max;
                        if (md.type == MaterialCommodityDB.MaterialFreqVeryCommon)
                        {
                            max = VeryCommonCap;
                        }
                        else if (md.type == MaterialCommodityDB.MaterialFreqCommon)
                        {
                            max = CommonCap;
                        }
                        else if (md.type == MaterialCommodityDB.MaterialFreqStandard)
                        {
                            max = StandardCap;
                        }
                        else if (md.type == MaterialCommodityDB.MaterialFreqRare)
                        {
                            max = RareCap;
                        }
                        else
                        {
                            max = VeryRareCap;
                        }
                        wantedList.AppendFormat("   {0} {1}% ({2}/{3})\n", System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(mat.Key.ToLower(System.Globalization.CultureInfo.InvariantCulture)),
                                                mat.Value.ToString("N1"), (onHand.HasValue ? onHand.Value : 0), max);
                    }
                }

                Font font = discoveryform.theme.GetFont;
                pictureBoxList.ClearImageList();
                PictureBoxHotspot.ImageElement displayList = pictureBoxList.AddTextAutoSize(new Point(0, 0), new Size(1000, 1000), wantedList.ToNullSafeString(), font, textcolour, backcolour, 1.0F);
                pictureBoxList.Render();
                font.Dispose();

                // if transparent, we don't show the eng/synth panels

                userControlEngineering.Visible = userControlSynthesis.Visible = !IsTransparent;
                userControlEngineering.Enabled = userControlSynthesis.Enabled = !IsTransparent;
                buttonTechBroker.Visible       = buttonTechBroker.Enabled = !IsTransparent;

                splitContainerVertical.Panel1MinSize = displayList.img.Width + 8;       // panel left has minimum width to accomodate the text

                if (IsTransparent)
                {
                    RevertToNormalSize();
                    int minWidth = Math.Max(((UserControlForm)FindForm()).TitleBarMinWidth(), displayList.img.Width) + 8;
                    RequestTemporaryResize(new Size(minWidth, displayList.img.Height + 4));
                }
                else
                {
                    RevertToNormalSize();       // eng/synth is on, normal size
                }
            }
        }
Exemple #6
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 <MaterialCommoditiesList.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

                MaterialCommoditiesList.ResetUsed(mcl);

                wantedList = new List <Tuple <MaterialCommoditiesList.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;
                if (materials == "All" || materials == "None")
                {
                    matList = new List <string>();
                }
                else
                {
                    matList = materials.Split(';').Where(x => !string.IsNullOrEmpty(x)).Select(m => matLookUp.Where(u => u.Item2 == m).First().Item1).ToList();
                }

                for (int i = 0; i < SynthesisRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    dataGridViewSynthesis.Rows[i].Cells[2].Value = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes[rno]).Item1.ToStringInvariant();
                    bool visible = true;

                    if (recep == "All" && levels == "All" && materials == "All")
                    {
                        visible = true;
                    }
                    else
                    {
                        visible = false;
                        if (recep == "All")
                        {
                            visible = true;
                        }
                        else
                        {
                            visible = recipeArray.Contains(SynthesisRecipes[rno].name);
                        }
                        if (levels == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && lvlArray.Contains(SynthesisRecipes[rno].level);
                        }
                        if (materials == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            var included = matList.Intersect <string>(SynthesisRecipes[rno].ingredients.ToList <string>());
                            visible = visible && included.Count() > 0;
                        }
                    }

                    dataGridViewSynthesis.Rows[i].Visible = visible;
                }

                for (int i = 0; i < SynthesisRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    if (dataGridViewSynthesis.Rows[i].Visible)
                    {
                        Tuple <int, int, string> res = MaterialCommoditiesList.HowManyLeft(mcl, 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;
                        }
                    }
                    if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded))
                    {
                        wantedList.Add(new Tuple <MaterialCommoditiesList.Recipe, int>(SynthesisRecipes[rno], Wanted[rno]));
                    }
                }

                dataGridViewSynthesis.RowCount = SynthesisRecipes.Count;         // truncate previous shopping list..

                if (!isEmbedded)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.GetShoppingList(wantedList, mcl);
                    shoppinglist.Sort(delegate(MaterialCommodities left, MaterialCommodities right) { return(left.name.CompareTo(right.name)); });

                    foreach (MaterialCommodities c in shoppinglist)        // and add new..
                    {
                        Object[] values = { c.name, "", c.scratchpad.ToStringInvariant(), "", c.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);
            }
        }