예제 #1
0
        Dictionary <Bitmap, float> imageintensities = new Dictionary <Bitmap, float>();       // cached

        // return right bottom of area used from curpos

        Point DrawNode(List <ExtPictureBox.ImageElement> pc,
                       StarScan.ScanNode sn,
                       MaterialCommoditiesList curmats,     // curmats may be null
                       HistoryList hl,
                       Image notscanned,                    // image if sn is not known
                       Point position,                      // position is normally left/middle, unless xiscentre is set.
                       bool xiscentre,
                       out Rectangle imagepos,
                       Size size,                        // nominal size
                       DrawLevel drawtype,               // drawing..
                       Color?backwash         = null,    // optional back wash on image
                       string appendlabeltext = ""       // any label text to append
                       )
        {
            string tip;
            Point  endpoint = position;

            imagepos = Rectangle.Empty;

            JournalScan sc = sn.ScanData;

            if (sc != null && (!sc.IsEDSMBody || CheckEDSM))     // has a scan and its our scan, or we are showing EDSM
            {
                if (sn.NodeType != StarScan.ScanNodeType.ring)   // not rings
                {
                    tip = sc.DisplayString(historicmatlist: curmats, currentmatlist: hl.GetLast?.MaterialCommodity);
                    if (sn.Signals != null)
                    {
                        tip += "\n" + "Signals".T(EDTx.ScanDisplayUserControl_Signals) + ":\n" + JournalSAASignalsFound.SignalList(sn.Signals, 4, "\n");
                    }

                    Bitmap nodeimage = (Bitmap)(sc.IsStar ? sc.GetStarTypeImage() : sc.GetPlanetClassImage());

                    string overlaytext = "";
                    var    nodelabels  = new string[2] {
                        "", ""
                    };

                    nodelabels[0] = sn.CustomNameOrOwnname;
                    if (sc.IsEDSMBody)
                    {
                        nodelabels[0] = "_" + nodelabels[0];
                    }

                    if (sc.IsStar)
                    {
                        if (ShowStarClasses)
                        {
                            overlaytext = sc.StarClassificationAbv;
                        }

                        if (sc.nStellarMass.HasValue)
                        {
                            nodelabels[1] = nodelabels[1].AppendPrePad($"{sc.nStellarMass.Value:N2} SM", Environment.NewLine);
                        }

                        if (drawtype == DrawLevel.TopLevelStar)
                        {
                            if (sc.nAge.HasValue)
                            {
                                nodelabels[1] = nodelabels[1].AppendPrePad($"{sc.nAge.Value:N0} MY", Environment.NewLine);
                            }

                            if (ShowHabZone)
                            {
                                var habZone = sc.GetHabZoneStringLs();
                                if (habZone.HasChars())
                                {
                                    nodelabels[1] = nodelabels[1].AppendPrePad($"{habZone}", Environment.NewLine);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ShowPlanetClasses)
                        {
                            overlaytext = Bodies.PlanetAbv(sc.PlanetTypeID);
                        }

                        if ((sn.ScanData.IsLandable || ShowAllG) && sn.ScanData.nSurfaceGravity != null)
                        {
                            nodelabels[1] = nodelabels[1].AppendPrePad($"{(sn.ScanData.nSurfaceGravity / JournalScan.oneGee_m_s2):N2}g", Environment.NewLine);
                        }
                    }

                    if (ShowDist)
                    {
                        if (drawtype != DrawLevel.MoonLevel)       // other than moons
                        {
                            if (sn.ScanData.IsOrbitingBaryCentre)  // if in orbit of barycentre
                            {
                                string s = $"{(sn.ScanData.DistanceFromArrivalLS):N1}ls";
                                if (sn.ScanData.nSemiMajorAxis.HasValue)
                                {
                                    s += "/" + sn.ScanData.SemiMajorAxisLSKM;
                                }
                                nodelabels[1] = nodelabels[1].AppendPrePad(s, Environment.NewLine);
                            }
                            else
                            {
                                //System.Diagnostics.Debug.WriteLine(sn.ScanData.BodyName + " SMA " + sn.ScanData.nSemiMajorAxis + " " + sn.ScanData.DistanceFromArrivalm);
                                string s = sn.ScanData.nSemiMajorAxis.HasValue && Math.Abs(sn.ScanData.nSemiMajorAxis.Value - sn.ScanData.DistanceFromArrivalm) > JournalScan.oneAU_m ? (" / " + sn.ScanData.SemiMajorAxisLSKM) : "";
                                nodelabels[1] = nodelabels[1].AppendPrePad($"{sn.ScanData.DistanceFromArrivalLS:N1}ls" + s, Environment.NewLine);
                            }
                        }
                        else
                        {
                            if (!sn.ScanData.IsOrbitingBaryCentre && sn.ScanData.nSemiMajorAxis.HasValue)          // if not in orbit of barycentre
                            {
                                nodelabels[1] = nodelabels[1].AppendPrePad($"{(sn.ScanData.nSemiMajorAxis / JournalScan.oneLS_m):N1}ls", Environment.NewLine);
                            }
                        }
                    }

                    nodelabels[1] = nodelabels[1].AppendPrePad(appendlabeltext, Environment.NewLine);

                    //  nodelabels[1] = nodelabels[1].AppendPrePad("" + sn.ScanData?.BodyID, Environment.NewLine);

                    bool valuable     = sc.EstimatedValue >= ValueLimit;
                    bool isdiscovered = sc.IsPreviouslyDiscovered && sc.IsPlanet;
                    int  iconoverlays = ShowOverlays ? ((sc.Terraformable ? 1 : 0) + (sc.HasMeaningfulVolcanism ? 1 : 0) +
                                                        (valuable ? 1 : 0) + (sc.Mapped ? 1 : 0) + (isdiscovered ? 1 : 0) + (sc.IsPreviouslyMapped ? 1 : 0) +
                                                        (sn.Signals != null ? 1 : 0)) : 0;

                    //   if (sc.BodyName.Contains("4 b"))  iconoverlays = 0;

                    bool materialsicon = sc.HasMaterials && !ShowMaterials;
                    bool imageoverlays = sc.IsLandable || (sc.HasRings && drawtype != DrawLevel.TopLevelStar) || materialsicon;

                    int bitmapheight   = size.Height * nodeheightratio / noderatiodivider;
                    int overlaywidth   = bitmapheight / 6;
                    int imagewidtharea = (imageoverlays ? 2 : 1) * size.Width;             // area used by image+overlay if any
                    int iconwidtharea  = (iconoverlays > 0 ? overlaywidth : 0);            // area used by icon width area on left

                    int bitmapwidth = iconwidtharea + imagewidtharea;                      // total width
                    int imageleft   = iconwidtharea + imagewidtharea / 2 - size.Width / 2; // calculate where the left of the image is
                    int imagetop    = bitmapheight / 2 - size.Height / 2;                  // and the top

                    Bitmap bmp = new Bitmap(bitmapwidth, bitmapheight);

                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        //  backwash = Color.FromArgb(128, 40, 40, 40); // debug

                        if (backwash.HasValue)
                        {
                            using (Brush b = new SolidBrush(backwash.Value))
                            {
                                g.FillRectangle(b, new Rectangle(iconwidtharea, 0, imagewidtharea, bitmapheight));
                            }
                        }

                        g.DrawImage(nodeimage, imageleft, imagetop, size.Width, size.Height);

                        if (sc.IsLandable)
                        {
                            int offset = size.Height * 4 / 16;
                            int scale  = 5;
                            g.DrawImage(Icons.Controls.Scan_Bodies_Landable, new Rectangle(imageleft + size.Width / 2 - offset * scale / 2,
                                                                                           imagetop + size.Height / 2 - offset * scale / 2, offset * scale, offset * scale));
                        }

                        if (sc.HasRings && drawtype != DrawLevel.TopLevelStar)
                        {
                            g.DrawImage(sc.Rings.Count() > 1 ? Icons.Controls.Scan_Bodies_RingGap : Icons.Controls.Scan_Bodies_RingOnly,
                                        new Rectangle(imageleft - size.Width / 2, imagetop, size.Width * 2, size.Height));
                        }

                        if (iconoverlays > 0)
                        {
                            int ovsize = bmp.Height / 6;
                            int pos    = 4;

                            if (sc.Terraformable)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Terraformable, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sc.HasMeaningfulVolcanism) //this renders below the terraformable icon if present
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Volcanism, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (valuable)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_HighValue, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sc.Mapped)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Mapped, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sc.IsPreviouslyMapped)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_MappedByOthers, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (isdiscovered)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_DiscoveredByOthers, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sn.Signals != null)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Signals, new Rectangle(0, pos, ovsize, ovsize));
                            }
                        }

                        if (materialsicon)
                        {
                            Image mm = Icons.Controls.Scan_Bodies_MaterialMore;
                            g.DrawImage(mm, new Rectangle(bmp.Width - mm.Width, bmp.Height - mm.Height, mm.Width, mm.Height));
                        }

                        if (overlaytext.HasChars())
                        {
                            float ii;
                            if (imageintensities.ContainsKey(nodeimage))        // find cache
                            {
                                ii = imageintensities[nodeimage];
                                //System.Diagnostics.Debug.WriteLine("Cached Image intensity of " + sn.fullname + " " + ii);
                            }
                            else
                            {
                                var imageintensity = nodeimage.Function(BitMapHelpers.BitmapFunction.Brightness, nodeimage.Width * 3 / 8, nodeimage.Height * 3 / 8, nodeimage.Width * 2 / 8, nodeimage.Height * 2 / 8);
                                ii = imageintensity.Item2;
                                imageintensities[nodeimage] = ii;
                                //System.Diagnostics.Debug.WriteLine("Calculated Image intensity of " + sn.fullname + " " + ii);
                            }

                            Color text = ii > 0.3f ? Color.Black : Color.FromArgb(255, 200, 200, 200);

                            using (Font f = new Font(EDDTheme.Instance.FontName, size.Width / 5.0f))
                            {
                                using (Brush b = new SolidBrush(text))
                                {
                                    g.DrawString(overlaytext, f, b, new Rectangle(iconwidtharea, 0, bitmapwidth - iconwidtharea, bitmapheight), new StringFormat()
                                    {
                                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                                    });
                                }
                            }
                        }
                    }

                    // need left middle, if xiscentre, translate to it
                    Point postoplot = xiscentre ? new Point(position.X - bmp.Width / 2, position.Y) : position;

                    //System.Diagnostics.Debug.WriteLine("Body " + sc.BodyName + " plot at "  + postoplot + " " + bmp.Size + " " + (postoplot.X+imageleft) + "," + (postoplot.Y-bmp.Height/2+imagetop));
                    endpoint = CreateImageAndLabel(pc, bmp, postoplot, bmp.Size, out imagepos, nodelabels, tip);
                    //System.Diagnostics.Debug.WriteLine("Draw {0} at {1} {2} out {3}", nodelabels[0], postoplot, bmp.Size, imagepos);

                    if (sc.HasMaterials && ShowMaterials)
                    {
                        Point matpos = new Point(endpoint.X + 4, position.Y);
                        Point endmat = CreateMaterialNodes(pc, sc, curmats, hl, matpos, materialsize);
                        endpoint = new Point(Math.Max(endpoint.X, endmat.X), Math.Max(endpoint.Y, endmat.Y)); // record new right point..
                    }
                }
            }
            else if (sn.NodeType == StarScan.ScanNodeType.belt)
            {
                if (sn.BeltData != null)
                {
                    tip = sn.BeltData.RingInformationMoons(true, "");
                }
                else
                {
                    tip = sn.OwnName + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD);
                }

                if (sn.Children != null && sn.Children.Count != 0)
                {
                    foreach (StarScan.ScanNode snc in sn.Children.Values)
                    {
                        if (snc.ScanData != null)
                        {
                            string sd = snc.ScanData.DisplayString() + "\n";
                            tip += "\n" + sd;
                        }
                    }
                }

                Size bmpsize = new Size(size.Width, planetsize.Height * nodeheightratio / noderatiodivider);

                endpoint = CreateImageAndLabel(pc, Icons.Controls.Scan_Bodies_Belt, position, bmpsize, out imagepos, new string[] { sn.OwnName.AppendPrePad(appendlabeltext, Environment.NewLine) }, tip, false);
            }
            else
            {
                if (sn.NodeType == StarScan.ScanNodeType.barycentre)
                {
                    tip = string.Format("Barycentre of {0}".T(EDTx.ScanDisplayUserControl_BC), sn.OwnName);
                }
                else
                {
                    tip = sn.OwnName + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD);
                }

                string nodelabel = sn.CustomName ?? sn.OwnName;
                nodelabel = nodelabel.AppendPrePad(appendlabeltext, Environment.NewLine);

                endpoint = CreateImageAndLabel(pc, notscanned, position, size, out imagepos, new string[] { nodelabel }, tip, false);
            }

            //    System.Diagnostics.Debug.WriteLine("Node " + sn.ownname + " " + position + " " + size + " -> "+ endpoint);
            return(endpoint);
        }
예제 #2
0
        // return right bottom of area used from curpos
        Point DrawNode(List <PictureBoxHotspot.ImageElement> pc, StarScan.ScanNode sn, Image notscanned, Point curpos,
                       Size size, ref int offset, bool alignhorz)
        {
            string tip;
            Point  endpoint  = curpos;
            int    hoff      = size.Height / 4;
            int    alignhoff = (alignhorz) ? hoff : 0;

            JournalScan sc = sn.scandata;

            if (sc != null)
            {
                tip = sc.DisplayString(true);

                if (sc.IsStar)
                {
                    endpoint = CreateImageLabel(pc, sc.GetStarTypeImage().Item1,
                                                new Point(curpos.X + offset, curpos.Y + alignhoff),
                                                size, sn.ownname, tip, alignhoff);

                    if (sc.HasRings)
                    {
                        curpos = new Point(endpoint.X + itemsepar.Width, curpos.Y);

                        Point endbelt = curpos;

                        for (int i = 0; i < sc.Rings.Length; i++)
                        {
                            string name = sc.Rings[i].Name;
                            if (name.Length > sn.fullname.Length && name.Substring(0, sn.fullname.Length).Equals(sn.fullname))
                            {
                                name = name.Substring(sn.fullname.Length).Trim();
                            }

                            curpos.X += 4;      // a little spacing, image is tight

                            endbelt = CreateImageLabel(pc, EDDiscovery.Properties.Resources.Belt,
                                                       new Point(curpos.X, curpos.Y + alignhoff), new Size(size.Width / 2, size.Height), name,
                                                       sc.RingInformationMoons(i), alignhoff);

                            curpos = new Point(endbelt.X + itemsepar.Width, curpos.Y);
                        }

                        endpoint = new Point(curpos.X, endpoint.Y);
                    }

                    offset += size.Width / 2;       // return the middle used was this..
                }
                else
                {
                    bool indicatematerials = sc.HasMaterials && !checkBoxMaterials.Checked;

                    Image nodeimage = sc.GetPlanetClassImage();

                    if (sc.IsLandable || sc.HasRings || indicatematerials)
                    {
                        Bitmap bmp = new Bitmap(size.Width * 2, hoff * 6);

                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            g.DrawImage(nodeimage, size.Width / 2, hoff, size.Width, size.Height);

                            if (sc.IsLandable)
                            {
                                g.DrawImage(EDDiscovery.Properties.Resources.planet_landing, new Rectangle(hoff, 0, hoff * 6, hoff * 6));
                            }

                            if (sc.HasRings)
                            {
                                g.DrawImage(sc.Rings.Count() > 1 ? EDDiscovery.Properties.Resources.RingGap512 : EDDiscovery.Properties.Resources.Ring_Only_512,
                                            new Rectangle(-2, hoff, size.Width * 2, size.Height));
                            }

                            if (indicatematerials)
                            {
                                Image mm = EDDiscovery.Properties.Resources.materiamoreindicator;
                                g.DrawImage(mm, new Rectangle(bmp.Width - mm.Width, bmp.Height - mm.Height, mm.Width, mm.Height));
                            }
                        }

                        endpoint = CreateImageLabel(pc, bmp, curpos, new Size(bmp.Width, bmp.Height), sn.ownname, tip, 0);
                        offset   = size.Width;                                      // return that the middle is now this
                    }
                    else
                    {
                        endpoint = CreateImageLabel(pc, nodeimage, new Point(curpos.X + offset, curpos.Y + alignhoff), size,
                                                    sn.ownname, tip, alignhoff);
                        offset += size.Width / 2;
                    }

                    if (sc.HasMaterials && checkBoxMaterials.Checked)
                    {
                        Point matpos = new Point(endpoint.X + 4, curpos.Y);
                        Point endmat = CreateMaterialNodes(pc, sc, matpos, materialsize);
                        endpoint = new Point(Math.Max(endpoint.X, endmat.X), Math.Max(endpoint.Y, endmat.Y)); // record new right point..
                    }
                }
            }
            else
            {
                if (sn.type == StarScan.ScanNodeType.barycentre)
                {
                    tip = "Barycentre of " + sn.ownname;
                }
                else
                {
                    tip = sn.ownname + "\n\nNo scan data available";
                }

                endpoint = CreateImageLabel(pc, notscanned, new Point(curpos.X + offset, curpos.Y + alignhoff), size, sn.ownname, tip, alignhoff);
                offset  += size.Width / 2;      // return the middle used was this..
            }

            return(endpoint);
        }
예제 #3
0
        // Width:  Nodes are allowed 2 widths
        // Height: Nodes are allowed 1.5 Heights.  0 = top, 1/2/3/4 = image, 5 = bottom.
        // offset: pass in horizonal offset, return back middle of image
        // aligndown : if true, compensate for drawing normal size images and ones 1.5 by shifting down the image and the label by the right amounts
        // labelvoff : any additional compensation for label pos

        // return right bottom of area used from curpos
        Point DrawNode(List <PictureBoxHotspot.ImageElement> pc, StarScan.ScanNode sn, Image notscanned, Point curpos,
                       Size size, ref int offset, bool aligndown = false, int labelvoff = 0)
        {
            string tip;
            Point  endpoint      = curpos;
            int    quarterheight = size.Height / 4;
            int    alignv        = aligndown ? quarterheight : 0;

            JournalScan sc = sn.ScanData;

            //System.Diagnostics.Debug.WriteLine("Node " + sn.ownname + " " + curpos + " " + size + " hoff " + offset + " EDSM " + ((sc!= null) ? sc.IsEDSMBody.ToString() : ""));

            if (sc != null && (!sc.IsEDSMBody || checkBoxEDSM.Checked))     // if got one, and its our scan, or we are showing EDSM
            {
                tip = sc.DisplayString();

                if (sc.IsStar)
                {
                    endpoint = CreateImageLabel(pc, sc.GetStarTypeImage().Item1,
                                                new Point(curpos.X + offset, curpos.Y + alignv),                                   // WE are basing it on a 1/4 + 1 + 1/4 grid, this is not being made bigger, move off
                                                size, sn.customname ?? sn.ownname, tip, alignv + labelvoff, sc.IsEDSMBody, false); // and the label needs to be a quarter height below it..

                    if (sc.HasRings)
                    {
                        curpos = new Point(endpoint.X + itemsepar.Width, curpos.Y);

                        Point endbelt = curpos;

                        for (int i = 0; i < sc.Rings.Length; i++)
                        {
                            string name = sc.Rings[i].Name;
                            if (name.Length > sn.fullname.Length && name.Substring(0, sn.fullname.Length).Equals(sn.fullname))
                            {
                                name = name.Substring(sn.fullname.Length).Trim();
                            }

                            curpos.X += 4;      // a little spacing, image is tight

                            endbelt = CreateImageLabel(pc, EDDiscovery.Properties.Resources.Belt,
                                                       new Point(curpos.X, curpos.Y + alignv), new Size(size.Width / 2, size.Height), name,
                                                       sc.RingInformationMoons(i), alignv + labelvoff, sc.IsEDSMBody, false);

                            curpos = new Point(endbelt.X + itemsepar.Width, curpos.Y);
                        }

                        endpoint = new Point(curpos.X, endpoint.Y);
                    }

                    offset += size.Width / 2;       // return the middle used was this..
                }
                else
                {
                    bool indicatematerials = sc.HasMaterials && !checkBoxMaterials.Checked;

                    Image nodeimage = sc.GetPlanetClassImage();

                    if ((sc.IsLandable || sc.HasRings || indicatematerials))
                    {
                        Bitmap bmp = new Bitmap(size.Width * 2, quarterheight * 6);

                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            g.DrawImage(nodeimage, size.Width / 2, quarterheight, size.Width, size.Height);

                            if (sc.IsLandable)
                            {
                                g.DrawImage(EDDiscovery.Properties.Resources.planet_landing, new Rectangle(quarterheight, 0, quarterheight * 6, quarterheight * 6));
                            }

                            if (sc.HasRings)
                            {
                                g.DrawImage(sc.Rings.Count() > 1 ? EDDiscovery.Properties.Resources.RingGap512 : EDDiscovery.Properties.Resources.Ring_Only_512,
                                            new Rectangle(-2, quarterheight, size.Width * 2, size.Height));
                            }

                            if (indicatematerials)
                            {
                                Image mm = EDDiscovery.Properties.Resources.materiamoreindicator;
                                g.DrawImage(mm, new Rectangle(bmp.Width - mm.Width, bmp.Height - mm.Height, mm.Width, mm.Height));
                            }
                        }

                        endpoint = CreateImageLabel(pc, bmp, curpos, new Size(bmp.Width, bmp.Height), sn.customname ?? sn.ownname, tip, labelvoff, sc.IsEDSMBody);
                        offset   = size.Width;                                      // return that the middle is now this
                    }
                    else
                    {
                        endpoint = CreateImageLabel(pc, nodeimage, new Point(curpos.X + offset, curpos.Y + alignv), size,
                                                    sn.customname ?? sn.ownname, tip, alignv + labelvoff, sc.IsEDSMBody);
                        offset += size.Width / 2;
                    }

                    if (sc.HasMaterials && checkBoxMaterials.Checked)
                    {
                        Point matpos = new Point(endpoint.X + 4, curpos.Y);
                        Point endmat = CreateMaterialNodes(pc, sc, matpos, materialsize);
                        endpoint = new Point(Math.Max(endpoint.X, endmat.X), Math.Max(endpoint.Y, endmat.Y)); // record new right point..
                    }
                }
            }
            else
            {
                if (sn.type == StarScan.ScanNodeType.barycentre)
                {
                    tip = "Barycentre of " + sn.ownname;
                }
                else
                {
                    tip = sn.ownname + "\n\nNo scan data available";
                }

                endpoint = CreateImageLabel(pc, notscanned, new Point(curpos.X + offset, curpos.Y + alignv), size, sn.customname ?? sn.ownname, tip, alignv + labelvoff, false);
                offset  += size.Width / 2;      // return the middle used was this..
            }

            return(endpoint);
        }
예제 #4
0
        // Width:  Nodes are allowed 2 widths
        // Height: Nodes are allowed 1.5 Heights.  0 = top, 1/2/3/4 = image, 5 = bottom.
        // offset: pass in horizonal offset, return back middle of image
        // aligndown : if true, compensate for drawing normal size images and ones 1.5 by shifting down the image and the label by the right amounts
        // labelvoff : any additional compensation for label pos

        // return right bottom of area used from curpos
        // curmats may be null
        Point DrawNode(List <ExtPictureBox.ImageElement> pc, StarScan.ScanNode sn, MaterialCommoditiesList curmats, HistoryList hl,
                       Image notscanned, Point curpos,
                       Size size, ref int offset, bool aligndown = false, int labelvoff = 0,
                       bool toplevel = false)
        {
            string tip;
            Point  endpoint      = curpos;
            int    quarterheight = size.Height / 4;
            int    alignv        = aligndown ? quarterheight : 0;

            JournalScan sc = sn.ScanData;

            //System.Diagnostics.Debug.WriteLine("Node " + sn.ownname + " " + curpos + " " + size + " hoff " + offset + " EDSM " + ((sc!= null) ? sc.IsEDSMBody.ToString() : ""));

            if (sc != null && (!sc.IsEDSMBody || CheckEDSM))     // if got one, and its our scan, or we are showing EDSM
            {
                tip = sc.DisplayString(historicmatlist: curmats, currentmatlist: hl.GetLast?.MaterialCommodity);

                if (sn.type == StarScan.ScanNodeType.ring)
                {
                }
                else if (sc.IsStar && toplevel)
                {
                    var starLabel = sn.customname ?? sn.ownname;

                    var habZone = sc.GetHabZoneStringLs();
                    if (!string.IsNullOrEmpty(habZone))
                    {
                        starLabel += $" ({habZone})";
                    }

                    endpoint = CreateImageLabel(pc, sc.GetStarTypeImage(),
                                                new Point(curpos.X + offset, curpos.Y + alignv),                 // WE are basing it on a 1/4 + 1 + 1/4 grid, this is not being made bigger, move off
                                                size, starLabel, tip, alignv + labelvoff, sc.IsEDSMBody, false); // and the label needs to be a quarter height below it..

                    offset += size.Width / 2;                                                                    // return the middle used was this..
                }
                else //else not a top-level star
                {
                    bool indicatematerials = sc.HasMaterials && !ShowMaterials;
                    bool valuable          = sc.EstimatedValue >= ValueLimit;

                    Image nodeimage = sc.IsStar ? sc.GetStarTypeImage() : sc.GetPlanetClassImage();

                    if (ImageRequiresAnOverlay(sc, indicatematerials, valuable))
                    {
                        Bitmap bmp = new Bitmap(size.Width * 2, quarterheight * 6);

                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            g.DrawImage(nodeimage, size.Width / 2, quarterheight, size.Width, size.Height);

                            if (sc.IsLandable)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Landable, new Rectangle(quarterheight, 0, quarterheight * 6, quarterheight * 6));
                            }

                            if (sc.HasRings)
                            {
                                g.DrawImage(sc.Rings.Count() > 1 ? Icons.Controls.Scan_Bodies_RingGap : Icons.Controls.Scan_Bodies_RingOnly,
                                            new Rectangle(-2, quarterheight, size.Width * 2, size.Height));
                            }

                            if (ShowOverlays)
                            {
                                int overlaystotal = (sc.Terraformable ? 1 : 0) + (sc.HasMeaningfulVolcanism ? 1 : 0) + (valuable ? 1 : 0) + (sc.Mapped ? 1 : 0);
                                int ovsize        = (overlaystotal > 1) ? quarterheight : (quarterheight * 3 / 2);
                                int pos           = 0;

                                if (sc.Terraformable)
                                {
                                    g.DrawImage(Icons.Controls.Scan_Bodies_Terraformable, new Rectangle(0, pos, ovsize, ovsize));
                                    pos += ovsize + 1;
                                }

                                if (sc.HasMeaningfulVolcanism) //this renders below the terraformable icon if present
                                {
                                    g.DrawImage(Icons.Controls.Scan_Bodies_Volcanism, new Rectangle(0, pos, ovsize, ovsize));
                                    pos += ovsize + 1;
                                }

                                if (valuable)
                                {
                                    g.DrawImage(Icons.Controls.Scan_Bodies_HighValue, new Rectangle(0, pos, ovsize, ovsize));
                                    pos += ovsize + 1;
                                }

                                if (sc.Mapped)
                                {
                                    g.DrawImage(Icons.Controls.Scan_Bodies_Mapped, new Rectangle(0, pos, ovsize, ovsize));
                                }
                            }

                            if (indicatematerials)
                            {
                                Image mm = Icons.Controls.Scan_Bodies_MaterialMore;
                                g.DrawImage(mm, new Rectangle(bmp.Width - mm.Width, bmp.Height - mm.Height, mm.Width, mm.Height));
                            }
                        }

                        var nodeLabel = sn.customname ?? sn.ownname;
                        if (sn.ScanData.IsLandable && sn.ScanData.nSurfaceGravity != null)
                        {
                            nodeLabel += $" ({(sn.ScanData.nSurfaceGravity / JournalScan.oneGee_m_s2):N2}g)";
                        }

                        endpoint = CreateImageLabel(pc, bmp, curpos, new Size(bmp.Width, bmp.Height), nodeLabel, tip, labelvoff, sc.IsEDSMBody);
                        offset   = size.Width;                                      // return that the middle is now this
                    }
                    else
                    {
                        endpoint = CreateImageLabel(pc, nodeimage, new Point(curpos.X + offset, curpos.Y + alignv), size,
                                                    sn.customname ?? sn.ownname, tip, alignv + labelvoff, sc.IsEDSMBody, false);
                        offset += size.Width / 2;
                    }

                    if (sc.HasMaterials && ShowMaterials)
                    {
                        Point matpos = new Point(endpoint.X + 4, curpos.Y);
                        Point endmat = CreateMaterialNodes(pc, sc, curmats, hl, matpos, materialsize);
                        endpoint = new Point(Math.Max(endpoint.X, endmat.X), Math.Max(endpoint.Y, endmat.Y)); // record new right point..
                    }
                }
            }
            else if (sn.type == StarScan.ScanNodeType.belt)
            {
                if (sn.BeltData != null)
                {
                    tip = sn.BeltData.RingInformationMoons(true);
                }
                else
                {
                    tip = sn.ownname + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD);
                }

                if (sn.children != null && sn.children.Count != 0)
                {
                    foreach (StarScan.ScanNode snc in sn.children.Values)
                    {
                        if (snc.ScanData != null)
                        {
                            tip += "\n\n" + snc.ScanData.DisplayString();
                        }
                    }
                }

                endpoint = CreateImageLabel(pc, Icons.Controls.Scan_Bodies_Belt,
                                            new Point(curpos.X, curpos.Y + alignv), new Size(size.Width, size.Height), sn.ownname,
                                            tip, alignv + labelvoff, false, false);
                offset += size.Width;
            }
            else
            {
                if (sn.type == StarScan.ScanNodeType.barycentre)
                {
                    tip = string.Format("Barycentre of {0}".T(EDTx.ScanDisplayUserControl_BC), sn.ownname);
                }
                else
                {
                    tip = sn.ownname + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD);
                }

                endpoint = CreateImageLabel(pc, notscanned, new Point(curpos.X + offset, curpos.Y + alignv), size, sn.customname ?? sn.ownname, tip, alignv + labelvoff, false, false);
                offset  += size.Width / 2;      // return the middle used was this..
            }

            return(endpoint);
        }