public async Task <RenderResult> Post([FromBody] RenderRequest renderRequest) { try { var layoutServiceResult = renderRequest.Args.LayoutServiceResult; _layoutServiceResultProvider.Result = layoutServiceResult; var appType = _blazorAppConfiguration.AppComponentType; var appDomElementSelector = _blazorAppConfiguration.AppDomElementSelector; var pageEditing = layoutServiceResult.Sitecore.Context.PageEditing; var appHtml = await _preRenderer.RenderAppAsync(appType, appDomElementSelector, ControllerContext, ViewData, TempData, pageEditing); var resultModel = new RenderResult { Html = appHtml, Status = (int)HttpStatusCode.OK }; return(resultModel); } catch (Exception ex) { return(new RenderResult { Html = $"<html><body><h1>An error occurred during server-side rendering.</h1><div>{ex.Message}</div></body></html>", Status = (int)HttpStatusCode.InternalServerError }); } }
[WriteOnly] public NativeArray <RenderResult> RenderResult; // Would be nice if we could write these and read on main thread public void Execute() { var rng = new Unity.Mathematics.Random(14387 + ((uint)PixelIndex * 7)); var screenPos = Math.ToXYFloat(PixelIndex, Resolution); float3 pixel = new float3(0f); ushort rayCount = 0; for (int r = 0; r < RaysPerPixel; r++) { float2 jitter = new float2(rng.NextFloat(), rng.NextFloat()); float2 p = (screenPos + jitter) / (float2)Resolution; var ray = Camera.GetRay(p, ref rng); pixel += Trace.TraceRecursive(ray, Scene, ref rng, Fibs, 0, MaxDepth, ref rayCount); // float3 col = new float3(1f); // ushort t = 0; // for (; t < Quality.MaxDepth; t++) { // if (!Trace.TraceStep(ref ray, Scene, ref rng, Fibs, ref col)) { // break; // } // } // pixel += col; // rayCount += t; } pixel = math.sqrt(pixel / (float)RaysPerPixel); RenderResult[0] = new RenderResult { Color = pixel, RayCount = rayCount }; }
private void RenderFiles() { if (leftFile == null && rightFile == null) { return; } Block result = null; if (leftFile == null) { result = rightFile.DiffWith(rightFile); } else if (rightFile == null) { result = leftFile.DiffWith(leftFile); } else { result = leftFile.DiffWith(rightFile); } // Render result :-) Graphics tempGraphics = CreateGraphics(); float longestLine = GetLongestLine(result, tempGraphics); int lines = GetNumberOfLines(result); int width = (int)Math.Ceiling(longestLine); bool evenLine = false; RenderResult graphics = RenderBlock(result, width, ref evenLine); // Set the fiels where we have something to set panelLeft.Controls.Clear(); panelRight.Controls.Clear(); if (leftFile != null) { panelLeft.Controls.Add(new PictureBox { Top = 0, Left = 0, Height = graphics.Left.Height, Width = graphics.Left.Width, Image = graphics.Left, }); } if (rightFile != null) { panelRight.Controls.Add(new PictureBox { Top = 0, Left = 0, Height = graphics.Right.Height, Width = graphics.Right.Width, Image = graphics.Right, }); } }
public RenderResult GenerateRenderResult(DateTime from, DateTime to, bool isRealTime) { GraphicsLayer layer; if (isRealTime) { var entity = new HydrologicReader().RetrieveEntity(from, to); //var entity = FakeDataSource(); layer = GenerateGraphicLayer(entity); } else { var entity = new HydrologicReader().RetrieveHisEntity(from, to); //var entity = FakeDataSource(); layer = GenerateGraphicLayer(entity); } var labelListSetting = GenerateDefaultLabelSetting(); layer.Labeling = GenerateLabelProperties(labelListSetting); layer.DisplayName = $"水情数据 {from} - {to}"; var result = new RenderResult { Layer = layer, LabelSettings = labelListSetting, GraphicGroupVM = GraphicGroupVM }; return(result); }
private void OnTick(object sender, EventArgs e) { if (RenderResult == null) { return; } bool isUpdated; lock (RenderResult) { isUpdated = RenderResult.IsUpdated; } if (isUpdated) { Bitmap bitmap = RenderResult.CreateBitmap(); using (Stream stream = new MemoryStream()) { bitmap.Save(stream, ImageFormat.Png); stream.Seek(0, SeekOrigin.Begin); image.Source = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); } lock (RenderResult) { RenderResult.IsUpdated = false; } } }
private void ShowReadonlyLayerHelperZilao(string keyName, string filePath, string settingKey = null) { if (!File.Exists(filePath)) { throw new Exception($"找不到路径{filePath}"); } if (!InternalNavDict.Keys.Contains(keyName)) { throw new Exception("Interal Mapping Error!"); } var render = new Diamond3RenderZilao(); RenderResult result = null; if (settingKey == null) { result = render.GenerateRenderResult(filePath); } else { result = render.GenerateRenderResult(filePath, settingKey); } if (InternalNavDict[keyName].CurrentLayer != null) { this.mapVm.DeleteReadonlyLayer(InternalNavDict[keyName].CurrentLayer); this.NavDict.Remove(InternalNavDict[keyName].CurrentLayer); } InternalNavDict[keyName].CurrentLayer = result.Layer; NavDict[result.Layer] = InternalNavDict[keyName]; this.mapVm.AddReadonlyLayer(result); this.mapVm.TreeViewVm.SelectLayer(result.Layer); }
public Renderer(AST <Node> sourceModule, RenderResult result, CancellationToken cancel = default(CancellationToken)) { Contract.Requires(sourceModule != null && sourceModule.Node.IsModule); this.result = result; this.cancel = cancel; this.sourceModule = sourceModule; }
public override void ProcessUniqueItem(RenderResult renderResult, RenderTaskUniqItemParameters parameters) { // This method is called once for every subscriber. It will give you the tracking item to get personal data the subscriber. // The only thing we know about the reciver at this time is its email and name found in emailTrackItem and we'll aslso give you // the actual newsletter thats about to be sent. // Ths will replace [subscriber] with both the name and email of the subscriber. renderResult.MessageBody = renderResult.MessageBody.Replace("[subscriber]", String.Format("{0} ({1})", parameters.EmailTrackingItem.Name, parameters.EmailTrackingItem.Email)); }
public override void ProcessPreview(RenderResult renderResult, RenderTaskParameters parameters) { // This method will be called when the letter is previewed. Sometimes you don't want to perform exacly the same rendering in preview mode as // in the real send out. This method lets you do that. If you don't overide this, the base class will call ProcessPreRender. So if you want to do nothing on // preview: Override this method and leave it blank. // This line of code will replace any appearances of [prePreview] with "Preview: From Custom Render". renderResult.MessageBody = renderResult.MessageBody.Replace("[prePreview]", "Preview: From Custom Render"); }
public override void ProcessUniqueItem(RenderResult renderResult, RenderTaskUniqueItemParameters parameters) { // This method is called once for every subscriber. It will give you the tracking item to get personal data the subscriber. // The only thing we know about the reciver at this time is its email and name found in emailTrackItem and we'll aslso give you // the actual newsletter thats about to be sent. // Ths will replace [subscriber] with both the name and email of the subscriber. renderResult.MessageBody = renderResult.MessageBody.Replace("[subscriber]", String.Format("{0} ({1})", parameters.EmailTrackingItem.Name, parameters.EmailTrackingItem.Email)); }
public override void ProcessPreRender(RenderResult renderResult, RenderTaskParameters parameters) { // This method will run once per send out and can be used to create over all changes that's not dependent on the uniq subscriber. // if your render task only works with uniq subscriber data, this method can be left empty. // This demo is very simple but you could use regular expressions to find/replace content, connect to databases, // interact with the umbraco api, call external webserivces or what every you like inside this method. // This line of code will replace any appearances of [preRender] with "Send out: From Custom Render Task". renderResult.MessageBody = renderResult.MessageBody.Replace("[preRender]", "Send out: From Custom Render Task"); }
private void Render() { RenderResult = Renderer.CreateRenderResult(); Renderer.Render(RenderResult, 1, 0, p => true, progress => { lock (RenderResult) RenderResult.IsUpdated = true; Console.WriteLine(progress); }); }
private static void OnRequestComplete(RenderResult <GameObject> result) { if (!Application.isEditor) { return; } foreach (KeyValuePair <GameObject, double> pair in result) { FARLogger.InfoFormat("{0}: {1}", pair.Key, pair.Value); } }
private RenderResult RenderBlock(Block block, float width, ref bool evenLine) { int lines = GetNumberOfLines(block); int intWidth = (int)Math.Ceiling(width); int intHeight = lines * lineHeight; Bitmap leftBitmap = new Bitmap(intWidth, intHeight); Bitmap rightBitmap = new Bitmap(intWidth, intHeight); using (Graphics leftGraphics = Graphics.FromImage(leftBitmap)) using (Graphics rightGraphics = Graphics.FromImage(rightBitmap)) { PrepareBackground(block.EntryType, leftGraphics, rightGraphics, intWidth, intHeight, evenLine); int currentLine = 0; foreach (Line line in block.Before) { RenderLine(line, leftGraphics, rightGraphics, currentLine++); evenLine = !evenLine; } int childrenHeight = currentLine * lineHeight; foreach (Block child in block.Children) { RenderResult result = RenderBlock(child, width - indent, ref evenLine); Rectangle sourceRectangle = new Rectangle(0, 0, result.Left.Width, result.Left.Height); Rectangle destinationRegion = new Rectangle(intWidth - result.Left.Width, childrenHeight, result.Left.Width, result.Left.Height); leftGraphics.DrawImage(result.Left, destinationRegion, sourceRectangle, GraphicsUnit.Pixel); rightGraphics.DrawImage(result.Right, destinationRegion, sourceRectangle, GraphicsUnit.Pixel); childrenHeight += result.Left.Height; evenLine = !evenLine; } currentLine = (lines - block.After.Count()); foreach (Line line in block.Before) { RenderLine(line, leftGraphics, rightGraphics, currentLine++); evenLine = !evenLine; } } return(new RenderResult { Left = leftBitmap, Right = rightBitmap, }); }
public override void ProcessUniqueItem(RenderResult renderResult, RenderTaskUniqueItemParameters parameters) { //compress information to create final URL var e = GlobalFactory.Current.Compressor.Compress(parameters.EmailTrackingItem.Email.ToString()); var nid = GlobalFactory.Current.Compressor.Compress(parameters.Newsletter.Id.ToString()); var sid = GlobalFactory.Current.Compressor.Compress(parameters.Newsletter.SubscriptionAlias.ToString()); //get the url and replace the information string listUnsubscribeUrl = GetOriginalUnsubscribeUrl(); listUnsubscribeUrl = listUnsubscribeUrl.Replace("[compress_email]", e); listUnsubscribeUrl = listUnsubscribeUrl.Replace("[compress_subscriptionId]", sid); listUnsubscribeUrl = listUnsubscribeUrl.Replace("[compress_newsletterId]", nid); parameters.MailMessage.Headers.Add("List-Unsubscribe", listUnsubscribeUrl); }
public RenderResult GenerateRenderResult(string path, Color color) { var reader = new CitynamesDataAccess(path); var entity = reader.RetrieveEntity(); var layer = GenerateGraphicLayer(entity, color); var labelListSetting = GenerateDefaultLabelSetting(); layer.Labeling = GenerateLabelProperties(labelListSetting); var result = new RenderResult { Layer = layer, LabelSettings = labelListSetting, }; return(result); }
public RenderResult Render(string worldname, string worldFolder, string outputFolder) { var result = new RenderResult(worldname); try { result.StartedOn = DateTime.UtcNow; var configFilepath = createRenderConfig(worldname, worldFolder, outputFolder); var stdout = runOverviewer(configFilepath); result.EndedOn = DateTime.UtcNow; result.Success = true; result.StdOut = stdout; } catch (Exception ex) { result.EndedOn = DateTime.UtcNow; result.Success = false; result.Message = ex.Message; } return(result); }
private void renderWorker_DoWork(object sender, DoWorkEventArgs e) { _map.Save(); //We must sync up runtime map state before rendering var args = (RenderWorkArgs)e.Argument; var res = new RenderResult() { RaiseEvents = args.RaiseEvents, InvalidateRegardless = args.InvalidateRegardless }; if (args.MapRenderingOptions != null) { if (args.UseRenderMap) res.Image = Image.FromStream(_map.Render(args.MapRenderingOptions.Format)); else res.Image = Image.FromStream(_map.RenderDynamicOverlay(null, args.MapRenderingOptions.Format, args.MapRenderingOptions.Color, args.MapRenderingOptions.Behavior)); } if (args.SelectionRenderingOptions != null) { //HACK: HTTP provider is stateless, so passing the selection is not only redundant, but will probably break on large selections. var sel = (_map.CurrentConnection.ProviderName.ToUpper().Equals("MAESTRO.HTTP")) ? null : _map.Selection; res.SelectionImage = Image.FromStream(_map.RenderDynamicOverlay(sel, args.SelectionRenderingOptions.Format, args.SelectionRenderingOptions.Color, args.SelectionRenderingOptions.Behavior)); } e.Result = res; }
public override void ProcessPreRender(RenderResult renderResult, RenderTaskParameters parameters) { }
private static void OnRequestComplete(RenderResult result, object _) { OnRequestComplete(result as RenderResult <GameObject>); }
//renderResult.Miscellaneous.Add(Diamond14Attributes.LevelSetting, productDialog.LevelSetting); //renderResult.Miscellaneous.Add(Diamond14Attributes.ProductType, productDialog.Type); public GraphicsLayer Generate(RenderResult renderResult) { if (renderResult == null || renderResult.Miscellaneous == null || !renderResult.Miscellaneous.Keys.Contains(Diamond14Attributes.LevelSetting)) { throw new Exception("找不到颜色配置"); } if (string.IsNullOrEmpty(renderResult.Miscellaneous[Diamond14Attributes.LevelSetting].ToString())) { throw new ArgumentNullException("无效的颜色配置"); } var sourceLayer = renderResult.Layer; var settings = LevelValueManager.Settings[renderResult.Miscellaneous[Diamond14Attributes.LevelSetting].ToString()]; var layer = new GraphicsLayer { DisplayName = sourceLayer.DisplayName }; //layer.Opacity = 0.5; var dict = new SortedDictionary <double, Graphic>(); foreach (var graphic in sourceLayer.Graphics) { if (graphic.Geometry is MapPoint) { graphic.ZIndex = 5; layer.Graphics.Add(graphic); } if (graphic.Geometry is Polyline) { // Level value will be int. If null, value will be 0 int value = Convert.ToInt32(graphic.Attributes[Diamond14Attributes.LineValue]); var polyline = graphic.Geometry as Polyline; var polygon = ToPolygon(polyline); var polygonSymbol = new SimpleFillSymbol { //Color = Color.FromArgb(0x66, 0xff, 0, 0) Color = settings.GetValueColor(value) }; var newGraphic = new Graphic { Geometry = polygon, Symbol = polygonSymbol }; layer.Graphics.Add(newGraphic); //double area = GeometryEngine.Area(polygon); clock wise will be positive double area = Math.Abs(GeometryEngine.Area(polygon)); dict.Add(area, newGraphic); } } int zindex = dict.Keys.Count; foreach (var graphic in dict.Values) { graphic.ZIndex = zindex--; } return(layer); }
private void renderWorker_DoWork(object sender, DoWorkEventArgs e) { var args = (RenderWorkArgs)e.Argument; var res = new RenderResult() { RaiseEvents = args.RaiseEvents, InvalidateRegardless = args.InvalidateRegardless }; if (args.MapRenderingOptions != null) { MgByteReader br = null; if (args.UseRenderMap) br = _provider.RenderMap(null, args.MapRenderingOptions.Format); else br = _provider.RenderDynamicOverlay(null, args.MapRenderingOptions); byte[] b = new byte[br.GetLength()]; br.Read(b, b.Length); using (var ms = new MemoryStream(b)) { res.Image = Image.FromStream(ms); } } if (args.SelectionRenderingOptions != null) { var br = _provider.RenderDynamicOverlay(_selection, args.SelectionRenderingOptions); byte[] b = new byte[br.GetLength()]; br.Read(b, b.Length); using (var ms = new MemoryStream(b)) { res.SelectionImage = Image.FromStream(ms); } } e.Result = res; }