Exemple #1
0
        public override void Render(IRenderArgs renderArgs)
        {
            if (!CanRender)
            {
                return;
            }

            ItemRenderer?.Render(renderArgs);
        }
Exemple #2
0
 public void Render(IRenderArgs renderArgs)
 {
     if (RenderEntity)
     {
         ModelRenderer.Render(renderArgs, KnownPosition);
     }
     if (ShowItemInHand)
     {
         ItemRenderer?.Render(renderArgs.GraphicsDevice);
     }
 }
Exemple #3
0
        public override void Render(IGraphScene <TItem, TEdge> data, IRenderEventArgs e)
        {
            var camera     = this.Camera();
            var clipBounds = camera.ToSource(e.Clipper.Bounds);

#if TraceRender
            Trace.WriteLine($"\t{nameof(Render)}.{nameof(clipBounds)}:\t{clipBounds}");
            //+"\toffset(g)"+new SizeS(g.Transform.OffsetX, g.Transform.OffsetY)
#endif

            var focused = data.Focused;
            var hovered = data.Hovered;

            var layout = this.Layout();
            ItemRenderer.Layout = this.Layout;

            foreach (var item in data.ElementsIn(clipBounds, ZOrder.EdgesFirst))
            {
                bool rendered = true;
                if (!item.Equals(focused) && !item.Equals(hovered))
                {
                    ItemRenderer.Render(item, e);

#if countVisuals
                    if (rendered)
                    {
                        iItems++;
                    }
#endif
                }
            }

            if (hovered != null && DrawingExtensions.Intersects(clipBounds, layout.GetShape(hovered).BoundsRect))
            {
                ItemRenderer.Render(hovered, e);
            }


            if (focused != null && layout.GetShape(focused) != null && DrawingExtensions.Intersects(clipBounds, layout.GetShape(focused).BoundsRect))
            {
                ItemRenderer.Render(focused, e);
            }
        }
Exemple #4
0
        public virtual void Render(IRenderArgs renderArgs)
        {
            long rendered = 0;

            if (RenderEntity || ShowItemInHand)
            {
                ModelRenderer.Render(renderArgs, KnownPosition, !RenderEntity);

                if (ModelRenderer.Valid)
                {
                    rendered += ModelRenderer.Vertices;
                }
            }
            if (ShowItemInHand && ItemRenderer != null)
            {
                ItemRenderer.Render(renderArgs);

                rendered += ItemRenderer.VertexCount;
            }

            RenderedVertices = rendered;
        }
        //TODO: Animations

        public void CacheTexture()
        {
            //Caches the texture of the item into InventoryGraphic
            InventoryGraphic = ItemRenderer.Render(itemModel, PreviewViewMatrix, PreviewWorldMatrix);
        }
    public string Render()
    {
      var fileName = FileUtil.MapPath(Path.Combine(TempFolder, this.FiddleId));
      FileUtil.CreateFolder(Path.GetDirectoryName(fileName));

      var viewFileName = Path.ChangeExtension(fileName, ".cshtml");
      File.WriteAllText(viewFileName, this.View, Encoding.UTF8);

      var codeFileName = Path.ChangeExtension(fileName, ".js");

      if (!string.IsNullOrWhiteSpace(this.Code))
      {
        this.WriteCode(codeFileName);
      }
      else if (File.Exists(codeFileName))
      {
        File.Delete(codeFileName);
      }

      try
      {
        if (string.IsNullOrEmpty(this.Renderings))
        {
          throw new InvalidOperationException("The Layout Renderings field must be a well-formed XML document.");
        }

        XDocument doc;
        try
        {
          doc = XDocument.Parse(this.Renderings);
        }
        catch
        {
          throw new InvalidOperationException("The Layout Renderings field is not well-formed.");
        }

        var root = doc.Root;
        if (root == null)
        {
          throw new InvalidOperationException("The Layout Renderings field is not well-formed.");
        }

        var fiddleRendering = this.CreateFiddleRendering();
        try
        {
          this.CreateItems(fiddleRendering, root, FileUtil.UnmapPath(viewFileName, false));

          var child = fiddleRendering.Children.FirstOrDefault() ?? Context.Item;

          var renderings = this.ParseLayout(root, fiddleRendering);

          var itemRenderer = new ItemRenderer(renderings, "/")
          {
            UsePlaceholders = true
          };

          using (new ContextItemSwitcher(child))
          {
            return itemRenderer.Render();
          }
        }
        finally
        {
          fiddleRendering.Delete();
        }
      }
      catch (Exception ex)
      {
        var text = string.Empty;
        while (ex != null)
        {
          text += "<p>" + ex.Message + "</p>";
          ex = ex.InnerException;
        }

        WebUtil.SetSessionValue("SC_FIDDLE_ERROR", text);
        HttpContext.Current.Response.Redirect("/sitecore/client/Reference/Fiddle/FiddleError");
        return string.Empty;
      }
    }