private void DrawToScreen(WantedBodies body, int bodiesCount) { var information = new StringBuilder(); // Is already surface mapped or not? if (body.Mapped) { information.Append("o "); // let the cmdr see that this body is already mapped } // Name information.Append(body.Name); // Additional information information.Append((body.Ammonia) ? @" is an ammonia world." : null); information.Append((body.Earthlike) ? @" is an earth like world." : null); information.Append((body.WaterWorld && !body.Terraformable) ? @" is a water world." : null); information.Append((body.WaterWorld && body.Terraformable) ? @" is a terraformable water world." : null); information.Append((body.Terraformable && !body.WaterWorld) ? @" is a terraformable planet." : null); information.Append((body.Ringed) ? @" Has ring." : null); information.Append((body.Volcanism) ? @" Has " + body.VolcanismString : null); information.Append(@" " + body.DistanceFromArrival); //Debug.Print(information.ToString()); // for testing // Drawing Elements const int rowHeight = 24; var vPos = (bodiesCount * rowHeight) - rowHeight; var textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; var backcolour = IsTransparent ? Color.Transparent : this.BackColor; if (body != null) { if (!body.Mapped || (body.Mapped && !hideAlreadyMappedBodiesToolStripMenuItem.Checked)) { pictureBoxSurveyor?.AddTextAutoSize( new Point(0, vPos + 4), new Size(pictureBoxSurveyor.Width, 24), information.ToString(), displayfont, textcolour, backcolour, 1.0F); } } pictureBoxSurveyor.Refresh(); }
private void DrawToScreen(WantedBodies body, int bodiesCount) { var information = new StringBuilder(); // Is already surface mapped or not? if (body.Mapped) { information.Append("o "); // let the cmdr see that this body is already mapped } // Name information.Append(body.Name); // Additional information information.Append((body.Ammonia) ? @" is an ammonia world.".Tx(this) : null); information.Append((body.Earthlike) ? @" is an earth like world.".Tx(this) : null); information.Append((body.WaterWorld && !body.Terraformable) ? @" is a water world.".Tx(this) : null); information.Append((body.WaterWorld && body.Terraformable) ? @" is a terraformable water world.".Tx(this) : null); information.Append((body.Terraformable && !body.WaterWorld) ? @" is a terraformable planet.".Tx(this) : null); information.Append((body.Ringed) ? @" Has ring.".Tx(this) : null); information.Append((body.Volcanism) ? @" Has ".Tx(this) + body.VolcanismString : null); information.Append(@" " + body.DistanceFromArrival); //Debug.Print(information.ToString()); // for testing // Drawing Elements const int rowHeight = 24; var vPos = (bodiesCount * rowHeight) - rowHeight; var textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; var backcolour = IsTransparent ? Color.Transparent : this.BackColor; using (var bitmap = new Bitmap(1, 1)) { var grfx = Graphics.FromImage(bitmap); using (var font = new Font(displayfont, FontStyle.Regular)) { if (body != null) { if (!body.Mapped || (body.Mapped && !hideAlreadyMappedBodiesToolStripMenuItem.Checked)) { var containerSize = new Size(Math.Max(pictureBoxSurveyor.Width, 24), 24); // note when minimized, we could have a tiny width, so need to protect var label = information.ToString(); var bounds = BitMapHelpers.DrawTextIntoAutoSizedBitmap(label, containerSize, displayfont, textcolour, backcolour, 1.0F); if (align == Alignment.center) { labelOffset = (int)((containerSize.Width - bounds.Width) / 2); } else if (align == Alignment.right) { labelOffset = (int)(containerSize.Width - bounds.Width); } else { labelOffset = 0; } pictureBoxSurveyor?.AddTextAutoSize( new Point(labelOffset, vPos + 4), new Size((int)bounds.Width, 24), information.ToString(), displayfont, textcolour, backcolour, 1.0F); } pictureBoxSurveyor.Refresh(); } } } }