private string InfoLine(ISystem sys, StarScan.ScanNode sn, JournalScan js) { var information = new StringBuilder(); if (js.Mapped) { information.Append("\u2713"); // let the cmdr see that this body is already mapped - this is a check } string bodyname = js.BodyDesignationOrName.ReplaceIfStartsWith(sys.Name); // Name information.Append(bodyname); // Additional information information.Append((js.AmmoniaWorld) ? @" is an ammonia world.".T(EDTx.UserControlSurveyor_isanammoniaworld) : null); information.Append((js.Earthlike) ? @" is an earth like world.".T(EDTx.UserControlSurveyor_isanearthlikeworld) : null); information.Append((js.WaterWorld && !js.Terraformable) ? @" is a water world.".T(EDTx.UserControlSurveyor_isawaterworld) : null); information.Append((js.WaterWorld && js.Terraformable) ? @" is a terraformable water world.".T(EDTx.UserControlSurveyor_isaterraformablewaterworld) : null); information.Append((js.Terraformable && !js.WaterWorld) ? @" is a terraformable planet.".T(EDTx.UserControlSurveyor_isaterraformableplanet) : null); information.Append((js.HasRings) ? @" Has ring.".T(EDTx.UserControlSurveyor_Hasring) : null); information.Append((js.HasMeaningfulVolcanism) ? @" Has ".T(EDTx.UserControlSurveyor_Has) + js.Volcanism + "." : null); information.Append((js.nRadius < lowRadiusLimit) ? @" Low Radius.".T(EDTx.UserControlSurveyor_LowRadius) : null); information.Append((sn.Signals != null) ? " Has Signals.".T(EDTx.UserControlSurveyor_Signals) : null); information.Append((js.IsLandable) ? @" is landable.".T(EDTx.UserControlSurveyor_islandable) : null); var ev = js.GetEstimatedValues(); if (js.WasMapped == true && js.WasDiscovered == true) { information.Append(" (Mapped & Discovered)".T(EDTx.UserControlSurveyor_MandD)); if (showValuesToolStripMenuItem.Checked) { information.Append(' ').Append(ev.EstimatedValueBase.ToString("N0")).Append(" cr"); } } else if (js.WasMapped == true && js.WasDiscovered == false) { information.Append(" (Mapped)".T(EDTx.UserControlSurveyor_MP)); if (showValuesToolStripMenuItem.Checked) { information.Append(' ').Append(ev.EstimatedValueBase.ToString("N0")).Append(" cr"); } } else if (js.WasDiscovered == true && js.WasMapped == false) { information.Append(" (Discovered)".T(EDTx.UserControlSurveyor_DIS)); if (showValuesToolStripMenuItem.Checked) { information.Append(' ').Append(ev.EstimatedValueFirstMappedEfficiently.ToString("N0")).Append(" cr"); } } else { if (showValuesToolStripMenuItem.Checked) { information.Append(' ').Append((ev.EstimatedValueFirstDiscoveredFirstMappedEfficiently > 0 ? ev.EstimatedValueFirstDiscoveredFirstMappedEfficiently : ev.EstimatedValueBase).ToString("N0")).Append(" cr"); } } if (showMoreInformationToolStripMenuItem.Checked) { information.Append(' ').Append(js.ShortInformation()); } else { information.Append(' ').Append(js.DistanceFromArrivalText); } return(information.ToString()); }
static private string InfoLine(ISystem sys, StarScan.ScanNode sn, JournalScan js, bool volcanism, bool showvalues, bool shortinfo, bool showGravity) { var information = new StringBuilder(); if (js.Mapped) { information.Append("\u2713"); // let the cmdr see that this body is already mapped - this is a check } string bodyname = js.BodyDesignationOrName.ReplaceIfStartsWith(sys.Name); // Name information.Append((bodyname) + @" is a ".T(EDTx.UserControlSurveyor_isa)); // Additional information information.Append((js.IsStar) ? Bodies.StarName(js.StarTypeID) + "." : null); information.Append((js.CanBeTerraformable) ? @"terraformable ".T(EDTx.UserControlSurveyor_terraformable) : null); information.Append((js.IsPlanet) ? Bodies.PlanetTypeName(js.PlanetTypeID) + "." : null); information.Append((js.nRadius < lowRadiusLimit && js.IsPlanet) ? @" Is tiny.".T(EDTx.UserControlSurveyor_LowRadius) : null); information.Append((js.nRadius > largeRadiusLimit && js.IsPlanet && js.IsLandable) ? @" Is large.".T(EDTx.UserControlSurveyor_LargeRadius) : null); information.Append((js.IsLandable) ? @" Is landable.".T(EDTx.UserControlSurveyor_islandable) : null); information.Append((js.IsLandable && showGravity && js.nSurfaceGravityG.HasValue) ? @" (" + Math.Round(js.nSurfaceGravityG.Value, 2, MidpointRounding.AwayFromZero) + "g)" : null); information.Append((js.HasAtmosphericComposition && js.IsLandable) ? @" Atmosphere: ".T(EDTx.UserControlSurveyor_Atmosphere) + (js.Atmosphere ?? "unknown atmosphere".T(EDTx.UserControlSurveyor_unknownAtmosphere)) + "." : null); information.Append((js.HasMeaningfulVolcanism && js.IsLandable | volcanism) ? @" Has ".T(EDTx.UserControlSurveyor_Has) + js.Volcanism + "." : null); information.Append((sn.Signals != null) ? " Has signals.".T(EDTx.UserControlSurveyor_Signals) : null); information.Append((js.HasRings) ? @" Is ringed.".T(EDTx.UserControlSurveyor_Hasring) : null); information.Append((js.nEccentricity >= eccentricityLimit) ? @" Has an high eccentricity of ".T(EDTx.UserControlSurveyor_eccentricity) + js.nEccentricity + "." : null); var ev = js.GetEstimatedValues(); if (js.WasMapped == true && js.WasDiscovered == true) { information.Append(" (Mapped & Discovered)".T(EDTx.UserControlSurveyor_MandD)); if (showvalues) { information.Append(' ').Append(ev.EstimatedValueMappedEfficiently.ToString("N0")).Append(" cr"); } } else if (js.WasMapped == true && js.WasDiscovered == false) { information.Append(" (Mapped)".T(EDTx.UserControlSurveyor_MP)); if (showvalues) { information.Append(' ').Append(ev.EstimatedValueFirstMappedEfficiently.ToString("N0")).Append(" cr"); } } else if (js.WasDiscovered == true && js.WasMapped == false) { information.Append(" (Discovered)".T(EDTx.UserControlSurveyor_DIS)); if (showvalues) { information.Append(' ').Append(ev.EstimatedValueFirstMappedEfficiently.ToString("N0")).Append(" cr"); } } else { if (showvalues) { information.Append(' ').Append((ev.EstimatedValueFirstDiscoveredFirstMappedEfficiently > 0 ? ev.EstimatedValueFirstDiscoveredFirstMappedEfficiently : ev.EstimatedValueBase).ToString("N0")).Append(" cr"); } } if (shortinfo) { information.Append(' ').Append(js.ShortInformation()); } else { information.Append(' ').Append(js.DistanceFromArrivalText); } return(information.ToString()); }
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, List <MaterialCommodityMicroResource> historicmats, // curmats may be null List <MaterialCommodityMicroResource> curmats, // curmats may be null 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 || ShowEDSMBodies)) // has a scan and its our scan, or we are showing EDSM { if (sn.NodeType != StarScan.ScanNodeType.ring) // not rings { tip = sc.DisplayString(0, historicmats, curmats); if (sn.Signals != null) { tip += "\n" + "Signals".T(EDTx.ScanDisplayUserControl_Signals) + ":\n" + JournalSAASignalsFound.SignalList(sn.Signals, 4, "\n"); } Bitmap nodeimage = (Bitmap)BaseUtils.Icons.IconSet.GetIcon(sc.GetStarPlanetTypeImageName()); 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.GetEstimatedValues().EstimatedValue(sc.WasDiscovered, sc.WasMapped, true, true) >= 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(BaseUtils.Icons.IconSet.GetIcon("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 ? BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.RingGap") : BaseUtils.Icons.IconSet.GetIcon("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(BaseUtils.Icons.IconSet.GetIcon("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(BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.Volcanism"), new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (valuable) { g.DrawImage(BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.HighValue"), new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sc.Mapped) { g.DrawImage(BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.Mapped"), new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sc.IsPreviouslyMapped) { g.DrawImage(BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.MappedByOthers"), new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (isdiscovered) { g.DrawImage(BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.DiscoveredByOthers"), new Rectangle(0, pos, ovsize, ovsize)); pos += ovsize + 1; } if (sn.Signals != null) { g.DrawImage(BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.Signals"), new Rectangle(0, pos, ovsize, ovsize)); } } if (materialsicon) { Image mm = BaseUtils.Icons.IconSet.GetIcon("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(Font.Name, 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, historicmats, curmats, 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, BaseUtils.Icons.IconSet.GetIcon("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); }