Пример #1
0
        public void Render(ViewContext viewContext, System.IO.TextWriter writer)
        {
            object dataContext = null;

            if (viewContext.ViewData.Model != null)
            {
                dataContext = viewContext.ViewData.Model;
            }
            else
            {
                dataContext = (dynamic)(new DynamicDictionary(viewContext.ViewData));
            }

            var xamlPath = viewContext.HttpContext.Server.MapPath(this.ViewPath);

            var response = viewContext.HttpContext.Response;

            response.ContentType = GetContentType(this.ImageFormat);
            XamlImage.RenderPath(xamlPath, dataContext, response.OutputStream, this.ImageFormat);
        }
Пример #2
0
 /// <summary>
 /// Renders the XAML contained within a file to PNG format and writes it to the Stream
 /// </summary>
 /// <param name="xamlPath">The path of the XAML file to render</param>
 /// <param name="dataContext">The DataContext to pass to the XAML control</param>
 /// <param name="streamToWriteTo">The Stream to write the renderd image to</param>
 public static void RenderPath(string xamlPath, object dataContext, Stream streamToWriteTo)
 {
     XamlImage.RenderPath(xamlPath, dataContext, streamToWriteTo, ImageFormat.Png);
 }
Пример #3
0
 /// <summary>
 /// Renders the XAML contained within a file to PNG format and writes it to the Stream
 /// </summary>
 /// <param name="xamlPath">The path of the XAML file to render</param>
 /// <param name="streamToWriteTo">The Stream to write the renderd image to</param>
 public static void RenderPath(string xamlPath, Stream streamToWriteTo)
 {
     XamlImage.RenderPath(xamlPath, null, streamToWriteTo);
 }