diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index d7f39b0582..e577fbe951 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -443,7 +443,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender endPoint.X = (int) x; endPoint.Y = (int) y; Image image = ImageHttpRequest(nextLine); - graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); + if (image != null) + { + graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y); + } + else + { + graph.DrawString("URL couldn't be resolved or is", new Font("Arial",6), myBrush, startPoint); + graph.DrawString("not an image. Please check URL.", new Font("Arial", 6), myBrush, new Point(startPoint.X, 12 + startPoint.Y)); + graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); + } startPoint.X += endPoint.X; startPoint.Y += endPoint.Y; } @@ -539,6 +548,57 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); drawPen.Width = size; } + else if (nextLine.StartsWith("PenCap")) + { + bool start = true, end = true; + nextLine = nextLine.Remove(0, 6); + nextLine = nextLine.Trim(); + string[] cap = nextLine.Split(partsDelimiter); + if (cap[0].ToLower() == "start") + end = false; + else if (cap[0].ToLower() == "end") + start = false; + else if (cap[0].ToLower() != "both") + return; + string type = cap[1].ToLower(); + + if (end) + { + switch (type) + { + case "arrow": + drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; + break; + case "round": + drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor; + break; + case "diamond": + drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor; + break; + case "flat": + drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat; + break; + } + } + if (start) + { + switch (type) + { + case "arrow": + drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; + break; + case "round": + drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor; + break; + case "diamond": + drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor; + break; + case "flat": + drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat; + break; + } + } + } else if (nextLine.StartsWith("PenColour")) { nextLine = nextLine.Remove(0, 9); @@ -610,16 +670,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender private Bitmap ImageHttpRequest(string url) { + try + { WebRequest request = HttpWebRequest.Create(url); //Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. //Ckrinke Stream str = null; - HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); - if (response.StatusCode == HttpStatusCode.OK) - { - Bitmap image = new Bitmap(response.GetResponseStream()); - return image; + HttpWebResponse response = (HttpWebResponse)(request).GetResponse(); + if (response.StatusCode == HttpStatusCode.OK) + { + Bitmap image = new Bitmap(response.GetResponseStream()); + return image; + } } - + catch { } return null; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b40e441315..b1c357c002 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -879,6 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return drawList; } + public string osSetPenCap(string drawList, string direction, string type) + { + CheckThreatLevel(ThreatLevel.None, "osSetPenColour"); + + m_host.AddScriptLPS(1); + drawList += "PenCap " + direction + "," + type + "; "; + return drawList; + } + public string osDrawImage(string drawList, int width, int height, string imageUrl) { CheckThreatLevel(ThreatLevel.None, "osDrawImage"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 202bf4172f..2365beeb71 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -101,6 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osSetFontSize(string drawList, int fontSize); string osSetPenSize(string drawList, int penSize); string osSetPenColour(string drawList, string colour); + string osSetPenCap(string drawList, string direction, string type); string osDrawImage(string drawList, int width, int height, string imageUrl); vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); void osSetStateEvents(int events); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index b6bfb43cb0..f877acb7e9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -282,6 +282,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osSetPenSize(drawList, penSize); } + public string osSetPenCap(string drawList, string direction, string type) + { + return m_OSSL_Functions.osSetPenCap(drawList, direction, type); + } + public string osSetPenColour(string drawList, string colour) { return m_OSSL_Functions.osSetPenColour(drawList, colour);