本文整理匯總了C#中SharpDX.Direct2D1.RenderTarget.DrawTextLayout方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderTarget.DrawTextLayout方法的具體用法?C# RenderTarget.DrawTextLayout怎麽用?C# RenderTarget.DrawTextLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpDX.Direct2D1.RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.DrawTextLayout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: OnRender
public void OnRender(RenderTarget target)
{
target.PushAxisAlignedClip(new RectangleF(Position.X, Position.Y, Size.X, Size.Y), AntialiasMode.Aliased);
target.DrawTextLayout(Position, mTextDraw, Color, mMultiline ? DrawTextOptions.None : DrawTextOptions.Clip);
target.PopAxisAlignedClip();
}
示例3: 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);
}
示例4: OnRender
public void OnRender(RenderTarget target)
{
var brush = gBackground;
if (mIsClicked)
brush = gBackgroundClick;
else if (mIsHovered)
brush = gBackgroundHover;
target.FillRectangle(mClientRectangle, gBorder);
target.FillRectangle(new RectangleF(Position.X + 1, Position.Y + 1, Size.X - 2, Size.Y - 2), brush);
target.DrawTextLayout(new Vector2(Position.X + 2, Position.Y + 2), mTextDraw, gCaptionColor, DrawTextOptions.Clip);
}
示例5: OnRender
public void OnRender(RenderTarget target)
{
var offset = mIsClicked ? new Vector2(1, 1) : new Vector2(0, 0);
target.FillRectangle(
!mIsClicked
? mRectangle
: new RectangleF(Position.X + offset.X, Position.Y + offset.Y, mSize.X - 2 * offset.X, mSize.Y - 2 * offset.Y),
mIsHovered ? mColorHover : mColor);
target.PushAxisAlignedClip(new RectangleF(Position.X + 2, Position.Y + 2, mSize.X - 4, mSize.Y - 4),
AntialiasMode.Aliased);
target.DrawTextLayout(new Vector2(Position.X + 2 + offset.X, Position.Y + 2 + offset.Y), mTextDraw, mIsHovered ? Brushes.Black : Brushes.White);
target.PopAxisAlignedClip();
}
示例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: 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);
}
示例9: DrawFpsSamples
private void DrawFpsSamples(RenderTarget target)
{
var maxValue = mFpsSamples.Max();
var minValue = mFpsSamples.Min();
if (MathUtil.WithinEpsilon(minValue, maxValue, 0.5f)) maxValue = minValue + 10;
var baseOffset = 0.0f;
var step = mSize.X / 19.0f;
var diff = (DateTime.Now - mLastFpsSample);
if (mFpsSamples.Count == 20)
baseOffset = (float)diff.TotalSeconds * step;
var curPos = mFpsRectangle.Left - baseOffset;
var endY = mFpsRectangle.Bottom - 5;
var height = mFpsRectangle.Height - 20;
target.PushAxisAlignedClip(mFpsRectangle, AntialiasMode.Aliased);
for (var i = 1; i < mFpsSamples.Count; ++i)
{
var sat = (mFpsSamples[i] - minValue) / (maxValue - minValue);
var satPrev = (mFpsSamples[i - 1] - minValue) / (maxValue - minValue);
target.DrawLine(new Vector2(curPos, endY - satPrev * height), new Vector2(curPos + step, endY - sat * height), Brushes.White);
curPos += step;
}
var satLast = (mFpsSamples.Last() - minValue) / (maxValue - minValue);
target.DrawLine(new Vector2(curPos, endY - satLast * height),
new Vector2(curPos + (float)diff.TotalSeconds * step, endY - satLast * height), Brushes.White);
target.PopAxisAlignedClip();
mFpsMin.Text = minValue.ToString("F2");
mFpsMax.Text = maxValue.ToString("F2");
target.DrawTextLayout(new Vector2(Position.X + 3.0f, mFpsRectangle.Top - 20.0f), mFpsMax, Brushes.White);
target.DrawTextLayout(new Vector2(Position.X + 3.0f, mFpsRectangle.Bottom + 2.0f), mFpsMin, Brushes.White);
}
示例10: DrawMemoryStrings
private void DrawMemoryStrings(RenderTarget target, long maxValue, long minValue)
{
float maxMemValue = maxValue;
var maxSuffix = " B";
if (maxMemValue > 1000)
{
maxSuffix = " KB";
maxMemValue /= 1000.0f;
if (maxMemValue > 1000)
{
maxSuffix = " MB";
maxMemValue /= 1000.0f;
if (maxMemValue > 1000)
{
maxSuffix = " GB";
maxMemValue /= 1000.0f;
}
}
}
float minMemValue = minValue;
var minSuffix = " B";
if(minMemValue > 1000)
{
minSuffix = " KB";
minMemValue /= 1000.0f;
if(minMemValue > 1000)
{
minSuffix = " MB";
minMemValue /= 1000.0f;
if(minMemValue > 1000)
{
minSuffix = " GB";
minMemValue /= 1000.0f;
}
}
}
mMemoryMax.Text = maxMemValue.ToString("F2") + maxSuffix;
mMemoryMin.Text = minMemValue.ToString("F2") + minSuffix;
target.DrawTextLayout(new Vector2(mPosition.X + 3.0f, mMemoryRectangle.Top - 20.0f), mMemoryMax, Brushes.White);
target.DrawTextLayout(new Vector2(mPosition.X + 3.0f, mMemoryRectangle.Bottom + 2), mMemoryMin, Brushes.White);
}
示例11: Draw
public void Draw(RenderTarget renderTarget)
{
renderTarget.FillRectangle(OutputRectangle, _backgroundColor.Resource);
var bufferedLine = _buffer.First;
// Move to current line
for (int i = 0; i < _currentLine; i++)
bufferedLine = bufferedLine.Next;
DrawingPointF origin = new DrawingPointF(0f, OutputRectangle.Bottom);
while (origin.Y > 0f && bufferedLine != null) {
origin.Y -= bufferedLine.Value.Text.Metrics.Height;
renderTarget.DrawTextLayout(origin, bufferedLine.Value.Text, bufferedLine.Value.TextColor);
bufferedLine = bufferedLine.Next;
}
}
示例12: OnRender
public void OnRender(RenderTarget target)
{
if (mImage == null)
return;
target.DrawBitmap(mImage, mTargetRectangle, 1.0f, BitmapInterpolationMode.Linear, mSourceRectangle);
if (mIndexLocation == 0)
{
target.FillRoundedRectangle(new RoundedRectangle
{
RadiusX = 5,
RadiusY = 5,
Rect = new RectangleF(Position.X + 5, Position.Y + 2, mIndexDraw.GetLayout().Metrics.Width + 10, mIndexDraw.GetLayout().Metrics.Height + 4)
}, Brushes.Solid[0xDD555555]);
}
else
{
target.FillRoundedRectangle(new RoundedRectangle
{
RadiusX = 5,
RadiusY = 5,
Rect = new RectangleF(Position.X + mTargetRectangle.Width - mIndexDraw.GetLayout().Metrics.Width - 15, Position.Y + 2, mIndexDraw.GetLayout().Metrics.Width + 10, mIndexDraw.GetLayout().Metrics.Height + 4)
}, Brushes.Solid[0xDD555555]);
}
target.DrawTextLayout(new Vector2(mPosition.X + 10, mPosition.Y + 5), mIndexDraw, Brushes.White);
}
示例13: Render
public override void Render(RenderTarget renderTarget)
{
if (!IsVisible) return;
CurrentBorderBrush.Resource.Opacity = this.Opacity;
CurrentBackgroundBrush.Resource.Opacity = this.Opacity;
renderTarget.Transform = this.Transform;
//TODO: Check if we need a second rect for this...
renderTarget.PushAxisAlignedClip(this.ClippingRectangle, AntialiasMode.Aliased);
try {
if (DrawBackground) {
renderTarget.FillGeometry(_backgroundGeometry, CurrentBackgroundBrush.Resource);
//if (CurrentBitmap != null)
// renderTarget.DrawBitmap(CurrentBitmap.Resource, Opacity, BitmapInterpolationMode.Linear);
}
if (DrawBorder)
renderTarget.DrawGeometry(_backgroundGeometry, CurrentBorderBrush.Resource);
if (DrawText && !String.IsNullOrEmpty(_text))
renderTarget.DrawTextLayout(new DrawingPointF(TextIndent, 0f), RenderedText, CurrentFontBrush.Resource);
base.Render(renderTarget);
} finally {
renderTarget.PopAxisAlignedClip();
}
}
示例14: Render
public override void Render(RenderTarget pRender, float pPercent)
{
pRender.Transform = Matrix3x2.Identity;
pRender.DrawTextLayout(new Vector2(x + dx * (pPercent - 1), y + dy * (pPercent - 1)), textLayout, brush);
}
示例15: Draw
public void Draw(RenderTarget renderTarget)
{
renderTarget.FillRectangle(OutputRectangle, _backgroundColor.Resource);
renderTarget.DrawTextLayout(new DrawingPointF(OutputRectangle.X, OutputRectangle.Y), _currentLayout, _textColor.Resource);
if (_drawCursor)
renderTarget.DrawTextLayout(_cursorDrawingPoint, _cursor, _textColor.Resource);
}