本文整理汇总了C#中this.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# this.Begin方法的具体用法?C# this.Begin怎么用?C# this.Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.Begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisableScissor
public static void DisableScissor(this SpriteBatch spriteBatch)
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = _oldScissor;
spriteBatch.Begin(_sortMode, _blendState, _samplerState, _depthStencilState, _rasterizerState, _effect,
_matrix);
}
示例2: DrawFilledCircle
public static void DrawFilledCircle(this PrimitiveBatch primitiveBatch, Vector2 position, float radius, Color color)
{
primitiveBatch.Begin(PrimitiveType.TriangleList);
int steps = 20;
float step = MathHelper.TwoPi / steps;
for (int i = 0; i < (steps + 1); i++)
{
float x = radius * (float)Math.Cos(i * step);
float y = radius * (float)Math.Sin(i * step);
if (i != 0)
{
primitiveBatch.AddVertex(position + new Vector2(x, y), color);
}
if (i != steps)
{
primitiveBatch.AddVertex(position, color);
primitiveBatch.AddVertex(position + new Vector2(x, y), color);
}
}
primitiveBatch.End();
}
示例3: Start
/// <summary>
/// Starts the specified batch.
/// </summary>
/// <param name="batch">The batch.</param>
/// <param name="useCamera">if set to <c>true</c> camera matrix will be applied.</param>
/// <param name="sortMode">The sort mode.</param>
/// <param name="blendState">State of the blend.</param>
/// <param name="samplerState">State of the sampler.</param>
/// <param name="depthStencilState">State of the depth stencil.</param>
/// <param name="rasterizerState">State of the rasterizer.</param>
/// <param name="effect">The effect.</param>
/// <param name="transform">The transformation matrix.</param>
public static void Start(this SpriteBatch batch,
bool useCamera = false,
SpriteSortMode sortMode = SpriteSortMode.Deferred,
BlendState blendState = null,
SamplerState samplerState = null,
DepthStencilState depthStencilState = null,
RasterizerState rasterizerState = null,
Effect effect = null,
Matrix? transform = null)
{
var matrix = Manager.IsWinForms ? Matrix.Identity : Manager.Settings.Resolution.Matrix;
if (useCamera)
{
matrix = Manager.Camera.Matrix*matrix;
}
if (transform.HasValue)
{
matrix = transform.Value*matrix;
}
_sortMode = sortMode;
_blendState = blendState;
_samplerState = samplerState;
_depthStencilState = depthStencilState;
_rasterizerState = rasterizerState;
_effect = effect;
_matrix = matrix;
batch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, matrix);
}
示例4: BeginAsync
/// <summary>
/// Asynchronously initiates the set of animations associated with the storyboard.
/// </summary>
/// <param name="storyboard">A storyboard which will be executed asynchronously.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
public static Task BeginAsync(this Storyboard storyboard)
{
if (storyboard == null)
throw new NullReferenceException();
// it doesn't really matter which type is used here.
var tcs = new TaskCompletionSource<bool>();
EventHandler handler = null;
handler = (sender, e) =>
{
storyboard.Completed -= handler;
tcs.TrySetResult(true);
};
storyboard.Completed += handler;
try
{
storyboard.Begin();
}
catch
{
storyboard.Completed -= handler;
throw;
}
return tcs.Task;
}
示例5: EnableScissor
public static void EnableScissor(this SpriteBatch spriteBatch, Rectangle rect)
{
spriteBatch.End();
_oldScissor = spriteBatch.GraphicsDevice.ScissorRectangle;
spriteBatch.GraphicsDevice.ScissorRectangle = rect;
spriteBatch.Begin(_sortMode, _blendState, _samplerState, _depthStencilState,
new RasterizerState {ScissorTestEnable = true}, _effect, _matrix);
}
示例6: Begin
public static void Begin(this Storyboard storyboard, int duration)
{
var d = new Duration(TimeSpan.FromMilliseconds(duration));
foreach (var child in storyboard.Children) {
child.Duration = d;
}
storyboard.Begin();
}
示例7: DrawPolyLine
/// <summary>
/// Draws a poly line.
/// Doesn't require SpriteBatch.Begin() or SpriteBatch.End()
/// <param name="points">The points.</param>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <param name="closed">Whether the shape should be closed.</param>
public static void DrawPolyLine(this SpriteBatch spriteBatch, Vector2[] points, Color color, int width = 1, bool closed = false)
{
spriteBatch.Begin();
for (int i = 0; i < points.Length - 1; i++)
spriteBatch.DrawLine(points[i], points[i + 1], color, width);
if (closed)
spriteBatch.DrawLine(points[points.Length - 1], points[0], color, width);
spriteBatch.End();
}
示例8: DrawLine
public static void DrawLine(this PrimitiveBatch primBatch, Line line, Color color)
{
primBatch.Begin(PrimitiveType.LineList);
primBatch.AddVertex((Vector2)line.Start, color);
primBatch.AddVertex((Vector2)line.End, color);
primBatch.End();
}
示例9: PlayAsync
public static Task<Storyboard> PlayAsync(this Storyboard storyboard)
{
var tcs = new TaskCompletionSource<Storyboard>();
storyboard.Completed += (sender, o) => tcs.SetResult(storyboard);
storyboard.Begin();
return tcs.Task;
}
示例10: DrawImmediate
public static void DrawImmediate( this SpriteBatch sb,
Texture2D texture,
Rectangle destinationRectangle,
Color color ) {
sb.Begin();
sb.Draw( texture, destinationRectangle, color );
sb.End();
}
示例11: DrawStringImmediate
public static void DrawStringImmediate( this SpriteBatch sb, SpriteFont font,
string text, Vector2 pos, Color color ) {
sb.Begin( SpriteBlendMode.AlphaBlend,
SpriteSortMode.Immediate,
SaveStateMode.SaveState );
sb.DrawString( font,
text,
pos,
color );
sb.End();
}
示例12: RunAsync
public static Task RunAsync(this Storyboard @this)
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
EventHandler handler = null;
handler = delegate
{
@this.Completed -= handler;
tcs.TrySetResult(null);
};
@this.Completed += handler;
@this.Begin();
return tcs.Task;
}
示例13: FadeBackBufferToBlack
/// <summary>
/// Helper draws a translucent black fullscreen sprite, used for fading
/// screens in and out, and for darkening the background behind popups.
/// </summary>
public static void FadeBackBufferToBlack(this SpriteBatch spriteBatch, float alpha)
{
GraphicsDevice device = spriteBatch.GraphicsDevice;
Viewport viewport = device.Viewport;
Texture2D blankTexture = new Texture2D(device, 1, 1);
blankTexture.SetData<Color>(new Color[] { Color.White });
spriteBatch.Begin();
spriteBatch.Draw(blankTexture,
new Rectangle(0, 0, viewport.Width, viewport.Height),
Color.Black * alpha);
spriteBatch.End();
}
示例14: BeginAsync
public static Task BeginAsync(this Storyboard storyboard) {
var tcs = new TaskCompletionSource<bool>();
if (storyboard == null) {
tcs.SetException(new ArgumentNullException());
}
else {
EventHandler onComplete = null;
onComplete = delegate(object s, EventArgs e) {
storyboard.Completed -= onComplete;
tcs.SetResult(true);
};
storyboard.Completed += onComplete;
storyboard.Begin();
}
return tcs.Task;
}
示例15: DoInTransaction
//private readonly static ILog Log = LogManager.GetLogger(typeof(UnitOfWorkHelpers).FullName);
public static void DoInTransaction(this IUnitOfWork uow, Action action)
{
uow.Begin();
try
{
action.Invoke();
uow.Commit();
}
catch (Exception ex)
{
//Log.Error(string.Format("Exception thrown in transaction. Action method: {0}, action Target: {1}.",
// action.Method, action.Target), ex);
uow.RollBack();
throw;
}
}