本文整理匯總了C#中SharpDX.Direct2D1.RenderTarget.DrawRectangle方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderTarget.DrawRectangle方法的具體用法?C# RenderTarget.DrawRectangle怎麽用?C# RenderTarget.DrawRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpDX.Direct2D1.RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.DrawRectangle方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnRender
public void OnRender(RenderTarget target)
{
if(gBorderBrush == null)
{
gBackgroundBrush = Brushes.Solid[0xCC555555];
gBackgroundHoverBrush = Brushes.Solid[0xCC888888];
gClickBrush = Brushes.Solid[0xFFFF7F00];
gBackgroundClickedBrush = Brushes.Solid[0xCCBBBBBB];
gBorderBrush = Brushes.White;
}
target.DrawTextLayout(new Vector2(Position.X + Size + 7, Position.Y - 2), mTextDraw, Brushes.White);
var brush = gBackgroundBrush;
if (mIsPressed)
brush = gBackgroundClickedBrush;
else if (mIsHovered)
brush = gBackgroundHoverBrush;
target.FillRectangle(mTargetRect, brush);
target.DrawRectangle(mTargetRect, gBorderBrush);
if (!Checked) return;
target.DrawLine(Position + new Vector2(3, 3), Position + new Vector2(mSize - 3, mSize - 3), gClickBrush,
mSize / 4.0f);
target.DrawLine(new Vector2(Position.X + 3, Position.Y + mSize - 3),
new Vector2(Position.X + mSize - 3, Position.Y + 3), gClickBrush, mSize / 4.0f);
}
示例2: Render
public override void Render(RenderTarget pRender, float pPercent)
{
pRender.Transform = Matrix3x2.Identity;
RectangleF rect = new RectangleF(x, y, width, height);
pRender.FillRectangle(rect, highlight ? highlightBrush : backBrush);
pRender.DrawRectangle(rect, borderBrush);
pRender.DrawTextLayout(new Vector2(x + dx * (pPercent - 1), y + dy * (pPercent - 1)), textLayout, textBrush);
}
示例3: Draw
public void Draw(RenderTarget g)
{
g.DrawRectangle(Bounds, Resources.SCBRUSH_RED, 2f);
foreach(BaseEntity ent in Objects)
{
g.DrawText(Level.ToString(), Resources.TEXT_FORMAT, ent.Hitbox, Resources.SCBRUSH_RED);
}
for (int i = 0; i < Nodes.Length; i++)
{
if (Nodes[i] != null)
{
Nodes[i].Draw(g);
}
}
}
示例4: OnRender
public void OnRender(RenderTarget target)
{
if (gBorder == null)
InitBrushes();
if(mIsHovered || mIsClicked)
{
if (mIsClicked)
target.FillRectangle(mTargetRect, gClick);
else if (mIsHovered)
target.FillRectangle(mTargetRect, gHover);
target.DrawRectangle(mTargetRect, gBorder);
}
target.DrawBitmap(mImage.GetBitmap(), mImageRect, 1.0f, BitmapInterpolationMode.Linear);
}
示例5: Render
public override void Render( RenderTarget target ) {
target.Clear( new RawColor4( 1.0f, 1.0f, 1.0f, 1.0f ) );
Brush brush = null;
switch( rnd.Next( 3 ) ) {
case 0: brush = resCache["RedBrush" ] as Brush; break;
case 1: brush = resCache["GreenBrush"] as Brush; break;
case 2: brush = resCache["BlueBrush" ] as Brush; break;
}
target.DrawRectangle( new RawRectangleF( x, y, x + w, y + h ), brush );
x = x + dx;
y = y + dy;
if ( x >= ActualWidth - w || x <= 0 ) {
dx = -dx;
}
if ( y >= ActualHeight - h || y <= 0 ) {
dy = -dy;
}
}
示例6: OnRender
public void OnRender(RenderTarget target)
{
UpdateCaret();
var transform = target.Transform;
target.Transform *= Matrix3x2.Translation(Position);
target.AntialiasMode = AntialiasMode.Aliased;
target.FillRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[0xCC111111]);
target.DrawRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[System.Drawing.Color.White]);
target.PushAxisAlignedClip(new RectangleF(4, 0, mSize.X - 8, mSize.Y), AntialiasMode.Aliased);
target.DrawTextLayout(new Vector2(mStartPosition, 0), mTextDraw, Brushes.Solid[0xFFFFFFFF]);
target.PopAxisAlignedClip();
if (mCaretVisible && mIsFocused)
{
target.DrawLine(new Vector2(mCaretOffset, 4), new Vector2(mCaretOffset, 23),
Brushes.Solid[0xFFFFFFFF], 2.0f);
}
target.Transform = transform;
}
示例7: OnRender
public void OnRender(RenderTarget target)
{
target.AntialiasMode = AntialiasMode.Aliased;
target.FillRectangle(mClientRectangle, gBackground);
target.DrawRectangle(mClientRectangle, gBorder);
if (HasCaption)
{
target.FillRectangle(mCaptionRect, gBorder);
target.DrawTextLayout(new Vector2(Position.X + 5, Position.Y - 18.0f), mCaptionText, gCaptionText);
}
var oldTransform = target.Transform;
target.Transform *= mTransform;
target.PushAxisAlignedClip(mClipRect, AntialiasMode.Aliased);
lock(Children)
foreach (var child in Children) child.OnRender(target);
target.PopAxisAlignedClip();
target.Transform = oldTransform;
}
示例8: OnEditViewportDrawPrimitives
private void OnEditViewportDrawPrimitives(Device device, RenderTarget target2D, Rectangle cliprectangle)
{
UiEncodingWindowSource source = _currentSource;
WflContent info = source?.Info;
if (info?.Header.TableType != WflHeader.LargeTable)
return;
int viewportX = _editViewport.X;
int viewportY = _editViewport.Y;
RectangleF rectangle = new RectangleF {Height = info.Header.LineHeight};
target2D.BeginDraw();
for (int i = 0; i < 256 * 2; i++)
{
if (i % 256 < 0x20)
continue;
int x, y;
info.GetOffsets(i, out x, out y);
x -= viewportX;
y -= viewportY;
byte before, width, after;
info.GetSizes(i, out before, out width, out after);
rectangle.X = x;
rectangle.Y = y;
rectangle.Width = width & 0x7F;
if (_charactersControl.CurrentMainIndices.Contains(i))
{
target2D.FillRectangle(rectangle, _selectedColorBrush);
if (before > 0x7F)
{
rectangle.Width = (0xFF - before) + 1;
rectangle.X = x;
}
else
{
rectangle.Width = before;
rectangle.X = x - before;
}
target2D.FillRectangle(rectangle, _spacingColorBrush);
if (after > 0x7F)
{
rectangle.Width = (0xFF - after) + 1;
rectangle.X = x + (width & 0x7F) - rectangle.Width;
}
else
{
rectangle.Width = after;
rectangle.X = x + width & 0x7F;
}
target2D.FillRectangle(rectangle, _spacingColorBrush);
}
else if (source.Chars[i % 256] == 0x00)
{
target2D.FillRectangle(rectangle, _notMappedColorBrush);
}
else
{
target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f);
}
}
int squareSize = info.Header.LineSpacing + info.Header.SquareDiff;
rectangle.Height = squareSize;
rectangle.Width = squareSize;
for (int i = 0; i < info.AdditionalTable.Length; i++)
{
int value = info.AdditionalTable[i];
if (value == 0)
continue;
rectangle.Y = (value >> 8) * squareSize - viewportY;
rectangle.X = (value & 0xFF) * squareSize - viewportX;
if (_charactersControl.CurrentAdditionalIndices.Contains(i))
target2D.FillRectangle(rectangle, _selectedColorBrush);
else if (source.Chars[i + 256] == 0x00)
target2D.FillRectangle(rectangle, _notMappedColorBrush);
else
target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f);
}
target2D.EndDraw();
}
示例9: OnRender
public void OnRender(RenderTarget target)
{
++mFrameCount;
var now = DateTime.Now;
if((now - mLastMemorySample).TotalSeconds > 0.5f)
{
mLastMemorySample = now;
mMemorySamples.Add(Environment.WorkingSet);
while (mMemorySamples.Count > 20)
mMemorySamples.RemoveAt(0);
}
if((now - mLastFpsSample).TotalSeconds >= 1.0f)
{
mFpsSamples.Add(mFrameCount / (float) (now - mLastFpsSample).TotalSeconds);
mLastFpsSample = now;
mFrameCount = 0;
while (mFpsSamples.Count > 20)
mFpsSamples.RemoveAt(0);
}
target.FillRectangle(mMemoryRectangle, Brushes.Solid[0xBB333333]);
target.DrawRectangle(mMemoryRectangle, Brushes.White);
target.FillRectangle(mFpsRectangle, Brushes.Solid[0xBB333333]);
target.DrawRectangle(mFpsRectangle, Brushes.White);
DrawMemorySamples(target);
DrawFpsSamples(target);
target.DrawTextLayout(new Vector2(Position.X, mMemoryRectangle.Top - 20.0f), mMemoryCaption, Brushes.White);
target.DrawTextLayout(new Vector2(Position.X, mFpsRectangle.Top - 20.0f), mFpsCaption, Brushes.White);
}
示例10: Draw
public virtual void Draw(RenderTarget g)
{
//Texture draw call
if (Texture != null)
{
DrawingPositionRect = new RectangleF(X - Game.VIEWPORT.X, Y - Game.VIEWPORT.Y, Width, Height);
Texture.DrawTexture(g, new RectangleF(X, Y, Width, Height));
}
//Debug drawing options
if (Config.DEBUG_MODE == DebugMode.DISPLAY_HITBOX)
{
g.DrawRectangle(new RectangleF(Hitbox.X, Hitbox.Y, Hitbox.Width, Hitbox.Height), Resources.SCBRUSH_RED);
}
else if (Config.DEBUG_MODE == DebugMode.DISPLAY_RECT)
{
g.DrawRectangle(new RectangleF(X, Y, Width, Height), Resources.SCBRUSH_RED);
g.DrawLine(new Vector2(X, Y), new Vector2(X + Width, Y + Height), Resources.SCBRUSH_RED);
g.DrawLine(new Vector2(X, Y + Height), new Vector2(X + Width, Y), Resources.SCBRUSH_RED);
}
/* Used for debug purposes
if (drawHitbox)
g.DrawRectangle(Hitbox, Resources.SCBRUSH_BLACK, 3f);
*/
}