// return right bottom of area used from curpos Point CreatePlanetTree(List <PictureBoxHotspot.ImageElement> pc, StarScan.ScanNode planetnode, Point curpos) { // PLANETWIDTH|PLANETWIDTH (if drawing a full planet with rings/landing) // or // MOONWIDTH|MOONWIDTH (if drawing a single width planet) // this offset, ONLY used if a single width planet, allows for two moons int offset = moonsize.Width - planetsize.Width / 2; // centre is moon width, back off by planetwidth/2 to place the left edge of the planet Point maxtreepos = DrawNode(pc, planetnode, JournalScan.GetPlanetImageNotScanned(), curpos, planetsize, ref offset, true); // offset passes in the suggested offset, returns the centre offset if (planetnode.children != null && checkBoxMoons.Checked) { offset -= moonsize.Width; // offset is centre of planet image, back off by a moon width to allow for 2 moon widths centred Point moonpos = new Point(curpos.X + offset, maxtreepos.Y + itemsepar.Height); // moon pos foreach (StarScan.ScanNode moonnode in planetnode.children.Values) { int offsetm = moonsize.Width / 2; // pass in normal offset if not double width item (half moon from moonpos.x) Point mmax = DrawNode(pc, moonnode, JournalScan.GetMoonImageNotScanned(), moonpos, moonsize, ref offsetm, false); maxtreepos = new Point(Math.Max(maxtreepos.X, mmax.X), Math.Max(maxtreepos.Y, mmax.Y)); if (moonnode.children != null) { Point submoonpos; if (mmax.X <= moonpos.X + moonsize.Width * 2) // if we have nothing wider than the 2 moon widths, we can go with it right aligned { submoonpos = new Point(moonpos.X + moonsize.Width * 2 + itemsepar.Width, moonpos.Y); // moon pos } else { submoonpos = new Point(moonpos.X + moonsize.Width * 2 + itemsepar.Width, mmax.Y + itemsepar.Height); // moon pos below and right } foreach (StarScan.ScanNode submoonnode in moonnode.children.Values) { int offsetsm = moonsize.Width / 2; // pass in normal offset if not double width item (half moon from moonpos.x) Point sbmax = DrawNode(pc, submoonnode, JournalScan.GetMoonImageNotScanned(), submoonpos, moonsize, ref offsetsm, false); maxtreepos = new Point(Math.Max(maxtreepos.X, sbmax.X), Math.Max(maxtreepos.Y, sbmax.Y)); submoonpos = new Point(submoonpos.X, maxtreepos.Y + itemsepar.Height); } } moonpos = new Point(moonpos.X, maxtreepos.Y + itemsepar.Height); } } return(maxtreepos); }
// return right bottom of area used from curpos Point CreatePlanetTree(List <ExtPictureBox.ImageElement> pc, StarScan.ScanNode planetnode, MaterialCommoditiesList curmats, HistoryList hl, Point leftmiddle, string[] filter, bool habzone, out int planetcentre) { Color?backwash = null; if (habzone) { backwash = Color.FromArgb(64, 0, 128, 0); // transparent in case we have a non black background } Point maxtreepos = DrawNode(pc, planetnode, curmats, hl, (planetnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetPlanetImageNotScanned(), leftmiddle, false, out planetcentre, planetsize, DrawLevel.PlanetLevel, backwash: backwash); // offset passes in the suggested offset, returns the centre offset if (planetnode.children != null && ShowMoons) { Point moonposcentremid = new Point(planetcentre, maxtreepos.Y + moonspacery + moonsize.Height / 2); // moon pos, below planet, centre x coord var moonnodes = planetnode.children.Values.Where(n => n.type != StarScan.ScanNodeType.barycentre).ToList(); var mooncentres = new Dictionary <StarScan.ScanNode, Point>(); for (int mn = 0; mn < moonnodes.Count; mn++) { StarScan.ScanNode moonnode = moonnodes[mn]; if (filter != null && moonnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { continue; } bool nonedsmscans = moonnode.DoesNodeHaveNonEDSMScansBelow(); // is there any scans here, either at this node or below? if (nonedsmscans || CheckEDSM) { Point mmax = DrawNode(pc, moonnode, curmats, hl, (moonnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetMoonImageNotScanned(), moonposcentremid, true, out int mooncentre, moonsize, DrawLevel.MoonLevel); maxtreepos = new Point(Math.Max(maxtreepos.X, mmax.X), Math.Max(maxtreepos.Y, mmax.Y)); if (moonnode.children != null) { Point submoonpos = new Point(mmax.X + moonspacerx, moonposcentremid.Y); // first its left mid bool xiscentre = false; foreach (StarScan.ScanNode submoonnode in moonnode.children.Values) { if (filter != null && submoonnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { continue; } bool nonedsmsubmoonscans = submoonnode.DoesNodeHaveNonEDSMScansBelow(); // is there any scans here, either at this node or below? if (nonedsmsubmoonscans || CheckEDSM) { Point sbmax = DrawNode(pc, submoonnode, curmats, hl, (moonnode.type == StarScan.ScanNodeType.barycentre) ? Icons.Controls.Scan_Bodies_Barycentre : JournalScan.GetMoonImageNotScanned(), submoonpos, xiscentre, out int xsubmooncentre, moonsize, DrawLevel.MoonLevel); if (xiscentre) { submoonpos = new Point(submoonpos.X, sbmax.Y + moonspacery + moonsize.Height / 2); } else { submoonpos = new Point(xsubmooncentre, sbmax.Y + moonspacery + moonsize.Height / 2); xiscentre = true; // now go to centre placing } maxtreepos = new Point(Math.Max(maxtreepos.X, sbmax.X), Math.Max(maxtreepos.Y, sbmax.Y)); } } } mooncentres[moonnode] = new Point(mooncentre, moonposcentremid.Y); moonposcentremid = new Point(moonposcentremid.X, maxtreepos.Y + moonspacery + moonsize.Height / 2); //System.Diagnostics.Debug.WriteLine("Next moon centre at " + moonposcentremid ); } } //// now, taking the moon modes, create a barycentre tree with those inserted in var barynodes = StarScan.ScanNode.PopulateBarycentres(moonnodes); // children always made, barynode tree foreach (var k in barynodes.children) // for all barynodes.. display { DisplayBarynode(k.Value, 0, mooncentres, moonnodes, pc, moonsize.Width * 5 / 4, true); } } return(maxtreepos); }
// return right bottom of area used from curpos Point CreatePlanetTree(List <ExtPictureBox.ImageElement> pc, StarScan.ScanNode planetnode, MaterialCommoditiesList curmats, HistoryList hl, Point curpos, string[] filter) { // PLANETWIDTH|PLANETWIDTH (if drawing a full planet with rings/landing) // or // MOONWIDTH|MOONWIDTH (if drawing a single width planet) // this offset, ONLY used if a single width planet, allows for two moons int offset = moonsize.Width - planetsize.Width / 2; // centre is moon width, back off by planetwidth/2 to place the left edge of the planet Point maxtreepos = DrawNode(pc, planetnode, curmats, hl, JournalScan.GetPlanetImageNotScanned(), curpos, planetsize, ref offset, true); // offset passes in the suggested offset, returns the centre offset if (planetnode.children != null && ShowMoons) { offset -= moonsize.Width; // offset is centre of planet image, back off by a moon width to allow for 2 moon widths centred Point moonpos = new Point(curpos.X + offset, maxtreepos.Y + moonspacery); // moon pos foreach (StarScan.ScanNode moonnode in planetnode.children.Values.Where(n => n.type != StarScan.ScanNodeType.barycentre)) { if (filter != null && moonnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { continue; } bool nonedsmscans = moonnode.DoesNodeHaveNonEDSMScansBelow(); // is there any scans here, either at this node or below? if (nonedsmscans || CheckEDSM) { int offsetm = moonsize.Width / 2; // pass in normal offset if not double width item (half moon from moonpos.x) Point mmax = DrawNode(pc, moonnode, curmats, hl, JournalScan.GetMoonImageNotScanned(), moonpos, moonsize, ref offsetm); maxtreepos = new Point(Math.Max(maxtreepos.X, mmax.X), Math.Max(maxtreepos.Y, mmax.Y)); if (moonnode.children != null) { Point submoonpos; if (mmax.X <= moonpos.X + moonsize.Width * 2) // if we have nothing wider than the 2 moon widths, we can go with it right aligned { submoonpos = new Point(moonpos.X + moonsize.Width * 2 + moonspacerx, moonpos.Y); // moon pos } else { submoonpos = new Point(moonpos.X + moonsize.Width * 2 + moonspacerx, mmax.Y + moonspacery); // moon pos below and right } foreach (StarScan.ScanNode submoonnode in moonnode.children.Values) { if (filter != null && submoonnode.IsBodyInFilter(filter, true) == false) // if filter active, but no body or children in filter { continue; } bool nonedsmsubmoonscans = submoonnode.DoesNodeHaveNonEDSMScansBelow(); // is there any scans here, either at this node or below? if (nonedsmsubmoonscans || CheckEDSM) { int offsetsm = moonsize.Width / 2; // pass in normal offset if not double width item (half moon from moonpos.x) Point sbmax = DrawNode(pc, submoonnode, curmats, hl, JournalScan.GetMoonImageNotScanned(), submoonpos, moonsize, ref offsetsm); maxtreepos = new Point(Math.Max(maxtreepos.X, sbmax.X), Math.Max(maxtreepos.Y, sbmax.Y)); submoonpos = new Point(submoonpos.X, maxtreepos.Y + moonspacery); } } } moonpos = new Point(moonpos.X, maxtreepos.Y + moonspacery); } } } return(maxtreepos); }