本文整理汇总了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;
}
示例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();
};
}
示例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());
}
示例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);
}
}
}
}
示例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( );
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例9: RenderWireframeCube
public void RenderWireframeCube(
IRenderContext renderContext,
Microsoft.Xna.Framework.BoundingBox boundingBox,
Color? color = null)
{
this.RenderWireframeCube(renderContext, boundingBox.ToProtogame(), color);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例14: RenderBelow
public void RenderBelow(IGameContext gameContext, IRenderContext renderContext)
{
using (this.m_Profiler.Measure("clear"))
{
gameContext.Graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
}
}
示例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();
}