Exemple #1
0
        private void _window_DrawGraphics(object sender, DrawGraphicsEventArgs e)
        {
            try
            {
                Graphics gfx = e.Graphics;
                if (_window.X != config.Overlay_x || _window.Y != config.Overlay_y || _window.Width != config.Overlay_width || _window.Height != config.Overlay_height)
                {
                    _window.X      = config.Overlay_x;
                    _window.Y      = config.Overlay_y;
                    _window.Width  = config.Overlay_width;
                    _window.Height = config.Overlay_height;
                    _window.Recreate();
                }

                if (_fonts["consolas"].FontSize != config.Overlay_FontSize)
                {
                    SetOverlayFonts();
                }

                var infoText = new StringBuilder().ToString();
                foreach (string s in LastLines)
                {
                    string newLine = $"{s}\r\n";
                    Point  p       = gfx.MeasureString(_fonts["consolas"], config.Overlay_FontSize, newLine);

                    if (p.X > _window.Width)
                    {
                        string newLines = "";
                        newLine = s;

                        float ratio     = _window.Width / p.X;
                        float part      = p.X / _window.Width;
                        float lenString = ratio * newLine.Length;

                        for (int i = 1; i < part + 1; i++)
                        {
                            float lenNewLines = (newLine.Length < lenString ? newLine.Length - 1 : (int)lenString);;
                            newLines += $"{newLine.Substring(0, (int)lenNewLines)}\r\n";
                            newLine   = newLine[(int)lenNewLines..];
 public void ReCreate()
 {
     _window.Recreate();
 }