// draw scannode (may be null), // curmats may be null public void DrawSystem(StarScan.SystemNode systemnode, List <MaterialCommodityMicroResource> historicmats, List <MaterialCommodityMicroResource> curmats, string opttext = null, string[] filter = null) { HideInfo(); SystemDisplay.BackColor = this.BackColor; SystemDisplay.LabelColor = EDDTheme.Instance.LabelColor; SystemDisplay.DrawSystem(imagebox, WidthAvailable, systemnode, historicmats, curmats, opttext, filter); imagebox.Render(); // replaces image.. }
public NodeResponse Response(string partialpath, HttpListenerRequest request) { System.Diagnostics.Debug.WriteLine("Serve Scan Display " + partialpath); //foreach (var k in request.QueryString.AllKeys) System.Diagnostics.Debug.WriteLine("Key {0} = {1}", k, request.QueryString[k]); int entry = (request.QueryString["entry"] ?? "-1").InvariantParseInt(-1); bool checkEDSM = (request.QueryString["EDSM"] ?? "false").InvariantParseBool(false); Bitmap img = null; JObject response = new JObject(); response["responsetype"] = "scandisplayobjects"; JArray objectlist = new JArray(); var hl = discoveryform.history; if (hl.Count > 0) { if (entry < 0 || entry >= hl.Count) { entry = hl.Count - 1; } // seen instances of exceptions accessing icons in different threads. so push up to discovery form. need to investigate. discoveryform.Invoke((MethodInvoker) delegate { StarScan.SystemNode sn = hl.StarScan.FindSystemSynchronous(hl.EntryOrder()[entry].System, checkEDSM); if (sn != null) { int starsize = (request.QueryString["starsize"] ?? "48").InvariantParseInt(48); int width = (request.QueryString["width"] ?? "800").InvariantParseInt(800); SystemDisplay sd = new SystemDisplay(); sd.ShowMoons = (request.QueryString["showmoons"] ?? "true").InvariantParseBool(true); sd.ShowOverlays = (request.QueryString["showbodyicons"] ?? "true").InvariantParseBool(true); sd.ShowMaterials = (request.QueryString["showmaterials"] ?? "true").InvariantParseBool(true); sd.ShowAllG = (request.QueryString["showgravity"] ?? "true").InvariantParseBool(true); sd.ShowHabZone = (request.QueryString["showhabzone"] ?? "true").InvariantParseBool(true); sd.ShowStarClasses = (request.QueryString["showstarclass"] ?? "true").InvariantParseBool(true); sd.ShowPlanetClasses = (request.QueryString["showplanetclass"] ?? "true").InvariantParseBool(true); sd.ShowDist = (request.QueryString["showdistance"] ?? "true").InvariantParseBool(true); sd.ValueLimit = (request.QueryString["valuelimit"] ?? "50000").InvariantParseInt(50000); sd.ShowEDSMBodies = checkEDSM; sd.SetSize(starsize); sd.Font = new Font("MS Sans Serif", 8.25f); sd.LargerFont = new Font("MS Sans Serif", 10f); sd.FontUnderlined = new Font("MS Sans Serif", 8.25f, FontStyle.Underline); ExtendedControls.ExtPictureBox imagebox = new ExtendedControls.ExtPictureBox(); sd.DrawSystem(imagebox, width, sn, null, null); //imagebox.AddTextAutoSize(new Point(10, 10), new Size(1000, 48), "Generated on " + DateTime.UtcNow.ToString(), new Font("MS Sans Serif", 8.25f), Color.Red, Color.Black, 0); imagebox.Render(); foreach (var e in imagebox.Elements) { if (e.ToolTipText.HasChars()) { // System.Diagnostics.Debug.WriteLine("{0} = {1}", e.Location, e.ToolTipText); objectlist.Add(new JObject() { ["left"] = e.Position.X, ["top"] = e.Position.Y, ["right"] = e.Location.Right, ["bottom"] = e.Location.Bottom, ["text"] = e.ToolTipText }); } } img = imagebox.Image.Clone() as Bitmap; imagebox.Dispose(); } }); } else { discoveryform.Invoke((MethodInvoker) delegate { img = BaseUtils.Icons.IconSet.GetIcon("Bodies.Unknown") as Bitmap; }); } response["objectlist"] = objectlist; server.SendWebSockets(response, false); // refresh history Bitmap bmpclone = img.Clone() as Bitmap; var cnv = bmpclone.ConvertTo(System.Drawing.Imaging.ImageFormat.Png); // this converts to png and returns the raw PNG bytes.. WebHeaderCollection wc = new WebHeaderCollection(); // indicate don't cache this, this is a temp image wc[HttpRequestHeader.CacheControl] = "no-store"; return(new NodeResponse(cnv, "image/png", wc)); }