当前位置: 首页>>代码示例>>C#>>正文


C# RenderTarget.DrawTextLayout方法代码示例

本文整理汇总了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);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:28,代码来源:Checkbox.cs

示例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();
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:8,代码来源:Label.cs

示例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);
        }
开发者ID:jonathandlo,项目名称:deep-space-dive,代码行数:9,代码来源:Button.cs

示例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);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:12,代码来源:Button.cs

示例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();
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:14,代码来源:MapSelectQuad.cs

示例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;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:21,代码来源:EditBox.cs

示例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;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:24,代码来源:Frame.cs

示例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);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:34,代码来源:PerformanceControl.cs

示例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);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:39,代码来源:PerformanceControl.cs

示例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);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:44,代码来源:PerformanceControl.cs

示例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;
                }
            }
开发者ID:sleepless1,项目名称:GameSharp,代码行数:16,代码来源:CommandConsole.OutputView.cs

示例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);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:27,代码来源:WdlControl.cs

示例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();
            }
        }
开发者ID:sleepless1,项目名称:GameSharp,代码行数:30,代码来源:DrawableControlBase.cs

示例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);
        }
开发者ID:jonathandlo,项目名称:deep-space-dive,代码行数:6,代码来源:Title.cs

示例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);
 }
开发者ID:sleepless1,项目名称:GameSharp,代码行数:7,代码来源:CommandConsole.InputView.cs


注:本文中的SharpDX.Direct2D1.RenderTarget.DrawTextLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。