当前位置: 首页>>代码示例>>C#>>正文


C# IRenderContext类代码示例

本文整理汇总了C#中IRenderContext的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext类的具体用法?C# IRenderContext怎么用?C# IRenderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IRenderContext类属于命名空间,在下文中一共展示了IRenderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderView

        public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext)
        {
            var response = new HtmlResponse();

            var html = renderContext.ViewCache.GetOrAdd(viewLocationResult, result =>
                                                                                {
                                                                                    string markDown =
                                                                                        viewLocationResult.Contents()
                                                                                                          .ReadToEnd();


                                                                                    var parser = new Markdown();
                                                                                    return parser.Transform(markDown);
                                                                                });


            var serverHtml = ParagraphSubstitution.Replace(html, "$1");

            var renderHtml = this.engineWrapper.Render(serverHtml, model, new MarkdownViewEngineHost(new NancyViewEngineHost(renderContext), renderContext));

            response.Contents = stream =>
            {
                var writer = new StreamWriter(stream);
                writer.Write(renderHtml);
                writer.Flush();
            };

            return response;
        }
开发者ID:jchannon,项目名称:Nancy.ViewEngines.Markdown,代码行数:29,代码来源:MarkDownEngine.cs

示例2: RenderView

        /// <summary>
        /// Renders the view.
        /// </summary>
        /// <param name="viewLocationResult">A <see cref="ViewLocationResult"/> instance, containing information on how to get the view template.</param>
        /// <param name="model">The model that should be passed into the view</param>
        /// <param name="renderContext"></param>
        /// <returns>A delegate that can be invoked with the <see cref="Stream"/> that the view should be rendered to.</returns>
        public Action<Stream> RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext)
        {
            return stream =>{

                var templateManagerProvider =
                    new TemplateManagerProvider()
                        .WithLoader(new TemplateLoader(viewLocationResult.Contents.Invoke()));

                var templateManager =
                    templateManagerProvider.GetNewManager();

                var template = renderContext.ViewCache.GetOrAdd(
                    viewLocationResult,
                    x => templateManager.GetTemplate(string.Empty));

                var context = new Dictionary<string, object> { { "Model", model } };
                var reader = template.Walk(templateManager, context);

                var writer =
                    new StreamWriter(stream);

                writer.Write(reader.ReadToEnd());
                writer.Flush();
            };
        }
开发者ID:nuxleus,项目名称:Nancy,代码行数:32,代码来源:NDjangoViewEngine.cs

示例3: RazorViewEngineFixture

        public RazorViewEngineFixture()
        {
            this.configuration = A.Fake<IRazorConfiguration>();
            this.engine = new RazorViewEngine(this.configuration);

            var cache = A.Fake<IViewCache>();
            A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, Func<NancyRazorViewBase>>>.Ignored))
                .ReturnsLazily(x =>
                {
                    var result = x.GetArgument<ViewLocationResult>(0);
                    return x.GetArgument<Func<ViewLocationResult, Func<NancyRazorViewBase>>>(1).Invoke(result);
                });

            this.renderContext = A.Fake<IRenderContext>();
            A.CallTo(() => this.renderContext.ViewCache).Returns(cache);
            A.CallTo(() => this.renderContext.LocateView(A<string>.Ignored, A<object>.Ignored))
                .ReturnsLazily(x =>
                {
                    var viewName = x.GetArgument<string>(0);
                    return FindView(viewName); ;
                });

            this.rootPathProvider = A.Fake<IRootPathProvider>();
            A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews"));

            this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader());
        }
开发者ID:GraemeF,项目名称:Nancy,代码行数:27,代码来源:RazorViewEngineFixture.cs

示例4: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            base.Render(gameContext, renderContext);

            // For each of the chunk AIs, process them.  It's not ideal to have this in
            // the Render() call, but some AIs need access to the render context so that
            // they can do bounding frustum checks to find out what's on screen.
            using (this.m_Profiler.Measure("tychaia-chunk_ai"))
            {
                foreach (var ai in this.m_ChunkAI)
                {
                    var result = ai.Process(this.m_World, this, gameContext, renderContext);
                    if (result != null)
                    {
                        this.m_ChunksToRenderNext = result;
                    }
                }
            }

            // Find the chunk that belongs at this position.
            using (this.m_Profiler.Measure("tychaia-chunk_render"))
            {
                foreach (var chunk in this.m_ChunksToRenderNext)
                {
                    if (chunk != null)
                    {
                        this.m_ChunkRenderer.Render(renderContext, chunk);
                    }
                }
            }
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:31,代码来源:ChunkManagerEntity.cs

示例5: Render

        /// <summary>
        /// Renders the ocean
        /// </summary>
        /// <param name="context">Rendering context</param>
        public override void Render( IRenderContext context )
        {
            if ( Planet == null || Planet.PlanetModel.OceanModel == null )
            {
                return;
            }

            GameProfiles.Game.Rendering.PlanetRendering.OceanRendering.Begin( );

            float seaLevel = ( SpherePlanet.PlanetModel.Radius + Planet.PlanetModel.OceanModel.SeaLevel ).ToRenderUnits;
            seaLevel /= 10.0f;
            Graphics.Renderer.PushTransform( TransformType.LocalToWorld );
            Graphics.Renderer.Scale( TransformType.LocalToWorld, seaLevel, seaLevel, seaLevel );

            m_WaveAnimation.UpdateAnimation( context.RenderTime );
            m_Technique.Effect.Parameters[ "OceanTexture0" ].Set( m_WaveAnimation.SourceTexture );
            m_Technique.Effect.Parameters[ "OceanTexture1" ].Set( m_WaveAnimation.DestinationTexture );
            m_Technique.Effect.Parameters[ "OceanTextureT" ].Set( m_WaveAnimation.LocalT );

            context.ApplyTechnique( m_Technique, m_OceanGeometry );

            Graphics.Renderer.PopTransform( TransformType.LocalToWorld );

            GameProfiles.Game.Rendering.PlanetRendering.OceanRendering.End( );
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:29,代码来源:SpherePlanetOceanRenderer.cs

示例6: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            base.Render(gameContext, renderContext);

            if (renderContext.IsCurrentRenderPass<I2DDirectRenderPass>())
            {
                if (_analyzerEntity.TopLeftNormalized != null && _analyzerEntity.TopRightNormalized != null &&
                    _analyzerEntity.BottomLeftNormalized != null && _analyzerEntity.BottomRightNormalized != null)
                {
                    _cachedTopLeft = _analyzerEntity.TopLeftNormalized;
                    _cachedTopRight = _analyzerEntity.TopRightNormalized;
                    _cachedBottomLeft = _analyzerEntity.BottomLeftNormalized;
                    _cachedBottomRight = _analyzerEntity.BottomRightNormalized;
                }

                if (_cachedTopLeft != null && _cachedTopRight != null &&
                    _cachedBottomLeft != null && _cachedBottomRight != null)
                { 
                    _warpFromPolygonEffect.Effect.Parameters["TopLeft"].SetValue(_cachedTopLeft.Value);
                    _warpFromPolygonEffect.Effect.Parameters["TopRight"].SetValue(_cachedTopRight.Value);
                    _warpFromPolygonEffect.Effect.Parameters["BottomLeft"].SetValue(_cachedBottomLeft.Value);
                    _warpFromPolygonEffect.Effect.Parameters["BottomRight"].SetValue(_cachedBottomRight.Value);
                    _warpFromPolygonEffect.Effect.Parameters["Alpha"].SetValue(_alpha);

                    _graphicsBlit.Blit(
                        renderContext,
                        _webcamEntity.VideoCaptureFrame,
                        null,
                        _warpFromPolygonEffect.Effect,
                        BlendState.AlphaBlend);
                }
            }
        }
开发者ID:hach-que,项目名称:Augmented-Board-Game,代码行数:33,代码来源:BoardRendererEntity.cs

示例7: RenderRow

 public override void RenderRow (IRenderContext context, int rowIndex, StatusType statusType, int width, int height)
 {
     if (statusType == StatusType.Normal && rowIndex % 2 != 0) {
         context.Theme.RenderRule (context.Context, width, height);
     }
     base.RenderRow (context, rowIndex, statusType);
 }
开发者ID:lunchtimemama,项目名称:hyena.rendering,代码行数:7,代码来源:RuledRowRenderer.cs

示例8: Render

 /// <summary>
 /// Internally called by <see cref="SensorEngineHook"/> to update sensors
 /// during the render step.
 /// </summary>
 /// <param name="gameContext">The current game context.</param>
 /// <param name="renderContext">The current render context.</param>
 public void Render(IGameContext gameContext, IRenderContext renderContext)
 {
     foreach (var sensor in _sensors)
     {
         sensor.Render(gameContext, renderContext);
     }
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:13,代码来源:DefaultSensorEngine.cs

示例9: RenderWireframeCube

 public void RenderWireframeCube(
     IRenderContext renderContext,
     Microsoft.Xna.Framework.BoundingBox boundingBox,
     Color? color = null)
 {
     this.RenderWireframeCube(renderContext, boundingBox.ToProtogame(), color);
 }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:7,代码来源:DefaultDebugCubeRenderer.cs

示例10: Render

        /// <summary>
        /// Renders the polygon annotation.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="model">The plot model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.screenPosition = this.Transform(this.X, this.Y);

            // clip to the area defined by the axes
            var clippingRectangle = this.GetClippingRect();

            rc.DrawMarker(clippingRectangle, this.screenPosition, this.Shape, this.CustomOutline, this.Size, this.Fill, this.Stroke, this.StrokeThickness);

            if (!string.IsNullOrEmpty(this.Text))
            {
                var dx = -(int)this.TextHorizontalAlignment * (this.Size + this.TextMargin);
                var dy = -(int)this.TextVerticalAlignment * (this.Size + this.TextMargin);
                var textPosition = this.screenPosition + new ScreenVector(dx, dy);
                rc.DrawClippedText(
                    clippingRectangle,
                    textPosition,
                    this.Text,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    this.TextRotation,
                    this.TextHorizontalAlignment,
                    this.TextVerticalAlignment);
            }
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:34,代码来源:PointAnnotation.cs

示例11: Process

        public ClientChunk[] Process(
            TychaiaGameWorld world, 
            ChunkManagerEntity manager, 
            IGameContext gameContext, 
            IRenderContext renderContext)
        {
            foreach (
                var position in
                    this.m_PredeterminedChunkPositions.GetPurgableAbsolutePositions(
                        new Vector3(
                            world.IsometricCamera.Chunk.X,
                            world.IsometricCamera.Chunk.Y,
                            world.IsometricCamera.Chunk.Z)))
            {
                var chunk = world.ChunkOctree.Get((long)position.X, (long)position.Y, (long)position.Z);
                if (chunk != null)
                {
                    Console.WriteLine("FIXME: PURGING CHUNK");

                    // chunk.Purge();
                }
            }

            return null;
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:25,代码来源:PredeterminedChunkPurgerAI.cs

示例12: CurrentRequestSessions

        /// <summary>
        /// Generates some script tags that you insert into your view.
        /// You should probably call this from a helper depending on your view engine.
        /// </summary>
        /// <param name="renderContext">The current Nancy Render Context</param>
        /// <returns></returns>
        public static string CurrentRequestSessions(IRenderContext renderContext)
        {
            var rootUrl = renderContext.ParsePath("~" + ModulePath) + "/";
            var sessionIdList = GetCurrentSessionIdList(renderContext.Context);

            return CurrentRequestSessions(rootUrl, sessionIdList);
        }
开发者ID:thefringeninja,项目名称:randy,代码行数:13,代码来源:RavenProfiler.cs

示例13: RenderText

 public void RenderText(IRenderContext context, Vector2 position, string text, FontAsset font,
     HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
     VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color? textColor = null, bool renderShadow = true,
     Color? shadowColor = null)
 {
     throw new NotSupportedException();
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:Null2DRenderUtilities.cs

示例14: RenderBelow

 public void RenderBelow(IGameContext gameContext, IRenderContext renderContext)
 {
     using (this.m_Profiler.Measure("clear"))
     {
         gameContext.Graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
     }
 }
开发者ID:RedpointGames,项目名称:Protogame.Template.Platformer,代码行数:7,代码来源:PROJECT_SAFE_NAMEWorld.cs

示例15: RenderText

 public void RenderText(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix matrix,
     string text, FontAsset font, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
     VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color? textColor = null, bool renderShadow = true,
     Color? shadowColor = null)
 {
     throw new NotSupportedException();
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:Null3DRenderUtilities.cs


注:本文中的IRenderContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。