public DrawTextLayout ( RawVector2 origin, |
||
origin | RawVector2 | The point, described in device-independent pixels, at which the upper-left corner of the text described by textLayout is drawn. |
textLayout | The formatted text to draw. Any drawing effects that do not inherit from |
|
defaultForegroundBrush | Brush | The brush used to paint any text in textLayout that does not already have a brush associated with it as a drawing effect (specified by the |
return | void |
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); }
public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null) { try { if (brush == null) { brush = new SolidBrush(Color.FromRGB(0, 0, 0, 0)); } var layout = new DW.TextLayout(factories.DWFactory, text, WinUniversalPlatform.GetTextFormat(factories, font), (float)frame.Width, (float)frame.Height); var h = layout.Metrics.Height + layout.OverhangMetrics.Top; var point = (frame.TopLeft - h * Point.OneY).ToVector2(); if (pen == null) { renderTarget.DrawTextLayout(point, layout, GetBrush(frame, brush)); } else { using (var pentr = new TextRendererWithPen(factories.D2DFactory, renderTarget)) { pentr.PenBrush = GetBrush(pen); pentr.PenWidth = (float)pen.Width; pentr.PenStyle = GetStrokeStyle(pen); pentr.FontBrush = GetBrush(frame, brush); layout.Draw(pentr, point.X, point.Y); } } } catch { System.Diagnostics.Debug.WriteLine("drawtexterror"); } }
public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null) { var layout = new DW.TextLayout(factories.DWFactory, text, GetTextFormat(font), (float)frame.Width, (float)frame.Height); var h = layout.Metrics.Height; renderTarget.DrawTextLayout((frame.TopLeft - h * Point.OneY).ToVector2(), layout, GetBrush(frame, brush)); }
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(); }
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); }
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); }
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(); }
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; }
/// <summary> /// Draws a <see cref="TextLayout"/> object to a render target at X/Y Coordinates. /// </summary> /// <param name="renderTarget">The render target.</param> /// <param name="textLayout">The text to render.</param> /// <param name="brush">The foreground brush.</param> /// <param name="x">X position</param> /// <param name="y">Y Position</param> /// <param name="brushBackground">The background brush, null for no background.</param> /// <param name="centerX">Center the text on the X axis</param> /// <param name="centerY">Center the text on the y axis</param> public static void DrawTextAtPoint(this SharpDX.Direct2D1.RenderTarget renderTarget, TextLayout textLayout, Brush brush, float x, float y, Brush brushBackground = null, bool centerX = false, bool centerY = false, DrawTextOptions options = DrawTextOptions.None) { float width = textLayout.Metrics.Width; float height = textLayout.Metrics.Height; if (centerX) { x -= width / 2; } if (centerY) { y -= height / 2; } if (brushBackground != null) { renderTarget.FillRectangle(new RawRectangleF(x, y, x + width, y + height), brushBackground); } renderTarget.DrawTextLayout(new RawVector2 { X = x, Y = y }, textLayout, brush, options); }
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; }
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); }
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); }
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); }
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); }
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); }
public void Draw(SharpDX.Direct2D1.RenderTarget renderTarget, SolidColorBrush textColor) { renderTarget.DrawTextLayout(Position, TextLayout, textColor); }
public void Draw(D2D.RenderTarget render, float x, float y, D2D.Brush brush) { render.DrawTextLayout(new Vector2((float)x, (float)y), this.layout, brush); }
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; } }
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); }
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(); } }
public void Draw(SharpDX.Direct2D1.RenderTarget renderTarget) { renderTarget.DrawTextLayout(TextPosition, TextLayout, TextColor); }