コード例 #1
0
ファイル: DXSprite.cs プロジェクト: nefarius/Direct3DHook
        public void DrawString(int X, int Y, string text, Color color, DXFont F)
        {
            var    blendFactor = new Color4(1.0f);
            Color4 backupBlendFactor;
            int    backupMask;

            using (
                var backupBlendState = _deviceContext.OutputMerger.GetBlendState(out backupBlendFactor, out backupMask))
            {
                _deviceContext.OutputMerger.SetBlendState(_transparentBS, blendFactor);

                BeginBatch(F.GetFontSheetSRV());


                var length = text.Length;

                var posX = X;
                var posY = Y;

                var color4 = ToColor4(color);

                for (var i = 0; i < length; ++i)
                {
                    var character = text[i];

                    if (character == ' ')
                    {
                        posX += F.GetSpaceWidth();
                    }
                    else if (character == '\n')
                    {
                        posX  = X;
                        posY += F.GetCharHeight();
                    }
                    else
                    {
                        var charRect = F.GetCharRect(character);

                        var width  = charRect.Right - charRect.Left;
                        var height = charRect.Bottom - charRect.Top;

                        Draw(new Rectangle(posX, posY, width, height), charRect, color4);

                        posX += width + 1;
                    }
                }

                EndBatch();
                _deviceContext.OutputMerger.SetBlendState(backupBlendState, backupBlendFactor, backupMask);
            }
        }
コード例 #2
0
        private DXFont GetFontForTextElement(TextElement element)
        {
            DXFont result = null;

            var fontKey = string.Format("{0}{1}{2}", element.Font.Name, element.Font.Size, element.Font.Style,
                                        element.AntiAliased);

            if (!_fontCache.TryGetValue(fontKey, out result))
            {
                result = ToDispose(new DXFont(_device, _deviceContext));
                result.Initialize(element.Font.Name, element.Font.Size, element.Font.Style, element.AntiAliased);
                _fontCache[fontKey] = result;
            }
            return(result);
        }
コード例 #3
0
ファイル: DXSprite.cs プロジェクト: nefarius/Direct3DHook
        public void DrawString(int X, int Y, string text, Color color, DXFont F)
        {
            var blendFactor = new Color4(1.0f);
            Color4 backupBlendFactor;
            int backupMask;
            using (
                var backupBlendState = _deviceContext.OutputMerger.GetBlendState(out backupBlendFactor, out backupMask))
            {
                _deviceContext.OutputMerger.SetBlendState(_transparentBS, blendFactor);

                BeginBatch(F.GetFontSheetSRV());

                var length = text.Length;

                var posX = X;
                var posY = Y;

                var color4 = ToColor4(color);

                for (var i = 0; i < length; ++i)
                {
                    var character = text[i];

                    if (character == ' ')
                        posX += F.GetSpaceWidth();
                    else if (character == '\n')
                    {
                        posX = X;
                        posY += F.GetCharHeight();
                    }
                    else
                    {
                        var charRect = F.GetCharRect(character);

                        var width = charRect.Right - charRect.Left;
                        var height = charRect.Bottom - charRect.Top;

                        Draw(new Rectangle(posX, posY, width, height), charRect, color4);

                        posX += width + 1;
                    }
                }

                EndBatch();
                _deviceContext.OutputMerger.SetBlendState(backupBlendState, backupBlendFactor, backupMask);
            }
        }