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


C# Font.DrawText方法代码示例

本文整理汇总了C#中SharpDX.Direct3D9.Font.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# Font.DrawText方法的具体用法?C# Font.DrawText怎么用?C# Font.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpDX.Direct3D9.Font的用法示例。


在下文中一共展示了Font.DrawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawText

		public static void DrawText(Font font, string text, int posX, int posY, Color color)
		{
			Rectangle rec = font.MeasureText(null, text, FontDrawFlags.Center);
			font.DrawText(null, text, posX + 1 + rec.X, posY + 1, Color.Black);
			font.DrawText(null, text, posX + rec.X, posY + 1, Color.Black);
			font.DrawText(null, text, posX - 1 + rec.X, posY - 1, Color.Black);
			font.DrawText(null, text, posX + rec.X, posY - 1, Color.Black);
			font.DrawText(null, text, posX + rec.X, posY, color);
		}
开发者ID:MeteTR,项目名称:LeagueSharp2,代码行数:9,代码来源:Helper.cs

示例2: DrawText

 public static void DrawText(Font vFont, String vText, float vPosX, float vPosY, SharpDX.ColorBGRA vColor)
 {
     vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor);
 }
开发者ID:09samed09,项目名称:LeagueSharp2,代码行数:4,代码来源:AssassinManager.cs

示例3: DrawFontTextMap

 public static void DrawFontTextMap(Font vFont, string vText, Vector3 Pos, ColorBGRA vColor)
 {
     var wts = Drawing.WorldToScreen(Pos);
     vFont.DrawText(null, vText, (int)wts[0] , (int)wts[1], vColor);
 }
开发者ID:julianu37,项目名称:LeagueRepo,代码行数:5,代码来源:OKTWdraws.cs

示例4: DrawFontTextScreen

 public static void DrawFontTextScreen(Font vFont, string vText, float vPosX, float vPosY, ColorBGRA vColor)
 {
     vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor);
 }
开发者ID:julianu37,项目名称:LeagueRepo,代码行数:4,代码来源:OKTWdraws.cs

示例5: DrawText

 public static void DrawText(Font aFont, String aText, int aPosX, int aPosY, SharpDX.Color aColor)
 {
     aFont.DrawText(null, aText, aPosX + 2, aPosY + 2, aColor != SharpDX.Color.Black ? SharpDX.Color.Black : SharpDX.Color.White);
     aFont.DrawText(null, aText, aPosX, aPosY, aColor);
 }
开发者ID:yashine59fr,项目名称:PortAIO,代码行数:5,代码来源:ModeDraw.cs

示例6: Main


//.........这里部分代码省略.........
                            Height   = worldSize.Height
                        }, 30f);
                emitters[i].Modifiers.Add(new MoveModifier(), 60f);
            };

            var renderer = new PointSpriteRenderer(device, budget)
            {
            //                EnableFastFade = true
            };

            var texture = Texture.FromFile(device, "Pixel.dds");

            var fontDescription = new FontDescription
            {
                Height         = 16,
                FaceName       = "Consolas",
                PitchAndFamily = FontPitchAndFamily.Mono,
                Quality        = FontQuality.Draft
            };

            var font = new Font(device, fontDescription);

            var totalTimer = Stopwatch.StartNew();
            var updateTimer = new Stopwatch();
            var renderTimer = new Stopwatch();

            var totalTime = 0f;

            foreach (var emitter in emitters)
            {
                emitter.Trigger(Coordinate.Origin);
            }

            float updateTime = 0f;

            RenderLoop.Run(form, () =>
                {
                    // ReSharper disable AccessToDisposedClosure
                    var frameTime = ((float)totalTimer.Elapsed.TotalSeconds) - totalTime;
                    totalTime = (float)totalTimer.Elapsed.TotalSeconds;

                    var mousePosition = form.PointToClient(RenderForm.MousePosition);

                    Task.WaitAll(
                        Task.Factory.StartNew(() =>
                        {
                            var mouseVector = new Vector3(mousePosition.X, mousePosition.Y, 0f);
                            var unprojected = Vector3.Unproject(mouseVector, 0, 0, renderSize.Width, renderSize.Height, 0f, 1f, wvp);

                            Parallel.ForEach(emitters, emitter => ((VortexModifier)emitter.Modifiers.ElementAt(1)).Position = new Coordinate(unprojected.X, unprojected.Y));

                            updateTimer.Restart();
                            Parallel.ForEach(emitters, emitter => emitter.Update(frameTime));
                            updateTimer.Stop();
                            updateTime = (float)updateTimer.Elapsed.TotalSeconds;
                            _updateTimes.Add(updateTime);
                        }),
                        Task.Factory.StartNew(() =>
                        {
                            device.Clear(ClearFlags.Target, Color.Black, 1f, 0);
                            device.BeginScene();

                            renderTimer.Restart();
                            for (int i = 0; i < numEmitters; i++)
                            {
                                renderer.Render(emitters[i], wvp, texture);
                            }
                            renderTimer.Stop();
                            var renderTime = (float)renderTimer.Elapsed.TotalSeconds;

                            var totalUpdateTime = 0f;
            //	                        foreach (var time in _updateTimes)
            //	                        {
            //		                        totalUpdateTime += time;
            //	                        }
            //	                        totalUpdateTime /= _updateTimes.Count;
            //
            //							if(_updateTimes.Count > 100)
            //								_updateTimes.RemoveAt(0);

                            font.DrawText(null, String.Format("Time:        {0}", totalTimer.Elapsed), 0, 0, Color.White);
                            font.DrawText(null, String.Format("Particles:   {0:n0}", emitters[0].ActiveParticles * numEmitters), 0, 16, Color.White);
                            font.DrawText(null, String.Format("Update:      {0:n4} ({1,8:P2})", updateTime, updateTime / 0.01666666f), 0, 32, Color.White);
                            font.DrawText(null, String.Format("Render:      {0:n4} ({1,8:P2})", renderTime, renderTime / 0.01666666f), 0, 48, Color.White);

                            device.EndScene();
                            device.Present();
                        })
                    );

                    if (Keyboard.IsKeyDown(Key.Escape))
                        Environment.Exit(0);
            // ReSharper restore AccessToDisposedClosure
                });

            form.Dispose();
            font.Dispose();
            device.Dispose();
            direct3d.Dispose();
        }
开发者ID:BraveSirAndrew,项目名称:mercury-particle-engine,代码行数:101,代码来源:Program.cs

示例7: DrawText

 private void DrawText(Font font, Vector2 pos, string text, ColorBGRA color)
 {
     font.DrawText(null, text, new Rectangle((int) pos.X, (int) pos.Y, 0, 0),
         SharpDX.Direct3D9.FontDrawFlags.NoClip, color);
 }
开发者ID:nefarius,项目名称:Direct3DHook,代码行数:5,代码来源:DXHookD3D9.cs

示例8: DrawShadowText

 public static void DrawShadowText(string stext, int x, int y, Color color, Font f)
 {
     f.DrawText(null, stext, x + 1, y + 1, Color.Black);
     f.DrawText(null, stext, x, y, color);
 }
开发者ID:NEWDITTO,项目名称:EnsageSharp,代码行数:5,代码来源:Program.cs

示例9: DrawText

 public static void DrawText(Font vFont, string vText, float vPosX, float vPosY, ColorBGRA vColor, bool shadow = false)
 {
     if (shadow)
     {
         vFont.DrawText(null, vText, (int)vPosX + 2, (int)vPosY + 2, SharpDX.Color.Black);
     }
     vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor);
 }
开发者ID:Esk0r,项目名称:LeagueSharp,代码行数:8,代码来源:CommonGeometry.cs

示例10: DrawText

 public static void DrawText(Font vFont, String vText, int vPosX, int vPosY, Color vColor)
 {
     vFont.DrawText(null, vText, vPosX + 2, vPosY + 2, vColor != Color.Black ? Color.Black : Color.White);
     vFont.DrawText(null, vText, vPosX, vPosY, vColor);
 }
开发者ID:Jackie-Tian,项目名称:ll,代码行数:5,代码来源:Utils.cs

示例11: DrawFont

 public static void DrawFont(Font vFont, string vText, float jx, float jy, ColorBGRA jc)
 {
     vFont.DrawText(null, vText, (int)jx, (int)jy, jc);
 }
开发者ID:FireBuddy,项目名称:olaf,代码行数:4,代码来源:Program.cs

示例12: DoCaptureRenderTarget

        /// <summary>
        /// Implementation of capturing from the render target of the Direct3D9 Device (or DeviceEx)
        /// </summary>
        /// <param name="device"></param>
        void DoCaptureRenderTarget(Device device, string hook)
        {
            this.Frame();

            try
            {
                    #region Screenshot Request
                // Single frame capture request
                if (this.Request != null)
                {
                    DateTime start = DateTime.Now;
                    try
                    {

                        using (Surface renderTargetTemp = device.GetRenderTarget(0))
                        {
                            int width, height;

                            // TODO: If resizing the captured image is required it can be adjusted here
                            //if (renderTargetTemp.Description.Width > 1280)
                            //{
                            //    width = 1280;
                            //    height = (int)Math.Round((renderTargetTemp.Description.Height * (1280.0 / renderTargetTemp.Description.Width)));
                            //}
                            //else
                            {
                                width = renderTargetTemp.Description.Width;
                                height = renderTargetTemp.Description.Height;
                            }

                            // First ensure we have a Surface to the render target data into
                            if (_renderTarget == null)
                            {
                                // Create offscreen surface to use as copy of render target data
                                using (SwapChain sc = device.GetSwapChain(0))
                                {
                                    _renderTarget = Surface.CreateOffscreenPlain(device, width, height, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory);
                                }
                            }

                            // Create our resolved surface (resizing if necessary and to resolve any multi-sampling)
                            using (Surface resolvedSurface = Surface.CreateRenderTarget(device, width, height, renderTargetTemp.Description.Format, MultisampleType.None, 0, false))
                            {
                                // Resize from Render Surface to resolvedSurface
                                device.StretchRectangle(renderTargetTemp, resolvedSurface, TextureFilter.None);

                                // Get Render Data
                                device.GetRenderTargetData(resolvedSurface, _renderTarget);
                            }
                        }

                        if (Request != null)
                            ProcessRequest();
                    }
                    finally
                    {
                        // We have completed the request - mark it as null so we do not continue to try to capture the same request
                        // Note: If you are after high frame rates, consider implementing buffers here to capture more frequently
                        //         and send back to the host application as needed. The IPC overhead significantly slows down 
                        //         the whole process if sending frame by frame.
                        Request = null;
                    }
                    DateTime end = DateTime.Now;
                    this.DebugMessage(hook + ": Capture time: " + (end - start).ToString());
                }

                #endregion

                if (this.Config.ShowOverlay)
                {
                    #region Draw frame rate

                    // TODO: font needs to be created and then reused, not created each frame!
                    using (SharpDX.Direct3D9.Font font = new SharpDX.Direct3D9.Font(device, new FontDescription()
                                    {
                                        Height = 16,
                                        FaceName = "Arial",
                                        Italic = false,
                                        Width = 0,
                                        MipLevels = 1,
                                        CharacterSet = FontCharacterSet.Default,
                                        OutputPrecision = FontPrecision.Default,
                                        Quality = FontQuality.Antialiased,
                                        PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare,
                                        Weight = FontWeight.Bold
                                    }))
                    {

                        if (this.FPS.GetFPS() >= 1)
                        {
                            font.DrawText(null, String.Format("{0:N0} fps", this.FPS.GetFPS()), 5, 5, SharpDX.Color.Red);
                        }

                        if (this.TextDisplay != null && this.TextDisplay.Display)
                        {
                            font.DrawText(null, this.TextDisplay.Text, 5, 25, new SharpDX.ColorBGRA(255, 0, 0, (byte)Math.Round((Math.Abs(1.0f - TextDisplay.Remaining) * 255f))));
//.........这里部分代码省略.........
开发者ID:Csharper1972,项目名称:Direct3DHook,代码行数:101,代码来源:DXHookD3D9.cs

示例13: Main

        static void Main()
        {
            var form = new RenderForm("SharpDX - Direct3D9 Font Sample");
            int width = form.ClientSize.Width;
            int height = form.ClientSize.Height;
            var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(width, height) { PresentationInterval = PresentInterval.One });

            // Initialize the Font
            FontDescription fontDescription = new FontDescription()
            {
                Height = 72,
                Italic = false,
                CharacterSet = FontCharacterSet.Ansi,
                FaceName = "Arial",
                MipLevels = 0,
                OutputPrecision = FontPrecision.TrueType,
                PitchAndFamily = FontPitchAndFamily.Default,
                Quality = FontQuality.ClearType,
                Weight = FontWeight.Bold
            };



            var font = new Font(device, fontDescription);

            var displayText = "Direct3D9 Text!";

            // Measure the text to display
            var fontDimension = font.MeasureText(null, displayText, new Rectangle(0, 0, width, height), FontDrawFlags.Center | FontDrawFlags.VerticalCenter);

            int xDir = 1;
            int yDir = 1;

            RenderLoop.Run(form, () =>
            {
                device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
                device.BeginScene();

                // Make the text boucing on the screen limits
                if ((fontDimension.Right + xDir) > width)
                    xDir = -1;
                else if ((fontDimension.Left + xDir) <= 0)
                    xDir = 1;

                if ((fontDimension.Bottom + yDir) > height)
                    yDir = -1;
                else if ((fontDimension.Top + yDir) <= 0)
                    yDir = 1;

                fontDimension.Left += (int)xDir;
                fontDimension.Top += (int)yDir;
                fontDimension.Bottom += (int)yDir;
                fontDimension.Right += (int)xDir;

                // Draw the text
                font.DrawText(null, displayText, fontDimension, FontDrawFlags.Center | FontDrawFlags.VerticalCenter, Color.White);

                device.EndScene();
                device.Present();
            });
        }
开发者ID:MaybeMars,项目名称:SharpDX-Samples,代码行数:61,代码来源:Program.cs

示例14: DrawText

 public static void DrawText(Font font, String text, int posX, int posY, Color color)
 {
     if (font == null || font.IsDisposed)
     {
         throw new SharpDXException("");
         return;
     }
     Rectangle rec = font.MeasureText(null, text, FontDrawFlags.Center);
     font.DrawText(null, text, posX + 1 + rec.X, posY, Color.Black);
     font.DrawText(null, text, posX + 1 + rec.X, posY + 1, Color.Black);
     font.DrawText(null, text, posX + rec.X, posY + 1, Color.Black);
     font.DrawText(null, text, posX - 1 + rec.X, posY, Color.Black);
     font.DrawText(null, text, posX - 1 + rec.X, posY - 1, Color.Black);
     font.DrawText(null, text, posX + rec.X, posY - 1, Color.Black);
     font.DrawText(null, text, posX + rec.X, posY, color);
 }
开发者ID:hhhmmm2,项目名称:SAwareness,代码行数:16,代码来源:Utils.cs

示例15: DrawText

 public static void DrawText(Font font, String text, int posX, int posY, Color color)
 {
     Rectangle rec = font.MeasureText(null, text, FontDrawFlags.Center);
     font.DrawText(null, text, posX + 1 + rec.X, posY + 1, SharpColor.White);
 }
开发者ID:Sthephanfelix,项目名称:LeagueSharp-4,代码行数:5,代码来源:Program.cs


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