Пример #1
0
        private float DrawPluginsBlock2(IEnumerable <IPlugin> plugins, float rowHeaderX, float x, float _y, float _w, float h, string format = "{0} ({1}):")
        {
            BackgroundBrush.DrawRectangle(rowHeaderX - rowHeaderSpacer, _y, rowHeaderSpacer + _w, h * plugins.Count());

            foreach (var plugin in plugins)
            {
                var layout = UsageLowFont.GetTextLayout(string.Format(format, plugin.GetType().Name.Replace("Plugin", ""), plugin.ToString().Split('.')[2]));
                //layout = UsageLowFont.GetTextLayout(string.Format("{0} :", plugin.ToString()));
                BackgroundBrush.DrawRectangle(rowHeaderX - rowHeaderSpacer - layout.Metrics.Width, _y, layout.Metrics.Width, layout.Metrics.Height);
                UsageLowFont.DrawText(layout, rowHeaderX - layout.Metrics.Width - rowHeaderSpacer, _y);

                var _x = x;
                foreach (var counter in Columns.Select(counterKey => plugin.PerformanceCounters.Where(c => c.Key == counterKey).Select(c => c.Value).FirstOrDefault()))
                {
                    if (counter != null && counter.LastValue > 0)
                    {
                        //var text = string.Format(CultureInfo.InvariantCulture, "{0:0.##}/{1:0.##}", counter.LastValue, counter.LastCount);
                        var text = counter.LastValue.ToString("0.##", CultureInfo.InvariantCulture);
                        (counter.LastValue <= HighUsageThreshold ? UsageLowFont : UsageHighFont).DrawText(text, _x, _y);
                    }

                    _x -= columnWidth;
                }

                _y += layout.Metrics.Height;
            }

            if (plugins.Any())
            {
                _y += h / 2;
            }

            return(_y);
        }
Пример #2
0
        public void PaintTopInGame(ClipState clipState)
        {
            if (clipState != ClipState.AfterClip)
            {
                return;
            }
            if (plugins == null)
            {
                return;
            }

            var layout = UsageLowFont.GetTextLayout("000.00__");

            columnWidth = layout.Metrics.Width;

            //var x = Hud.Window.Size.Width - Hud.Window.Size.Height * 0.31f - columnWidth;
            var x                 = Hud.Render.MinimapUiElement.Rectangle.Left - columnWidth;
            var currentY          = 0f;
            var rowHeaderX        = x - columnWidth * (Columns.Count() - 1);
            var columnsTotalWidth = columnWidth * Columns.Count();

            layout = UsageLowFont.GetTextLayout(string.Format("Plugins : {0}/{1}  ", plugins.Count(), Hud.AllPlugins.Count()));
            UsageLowFont.DrawText(layout, rowHeaderX - layout.Metrics.Width - rowHeaderSpacer, currentY);

            var _x  = x;
            var odd = false;

            foreach (var counterKey in Columns)
            {
                UsageLowFont.DrawText(counterKey, _x, currentY + (odd ? 0 : layout.Metrics.Height));
                _x -= columnWidth;
                odd = !odd;
            }

            currentY += layout.Metrics.Height * 2;

            currentY = DrawPluginsBlock(PluginsAlwaysDisplayed, rowHeaderX, x, currentY, columnsTotalWidth, layout.Metrics.Height);
            currentY = DrawPluginsBlock(plugins, rowHeaderX, x, currentY, columnsTotalWidth, layout.Metrics.Height);

            //currentY = DrawPluginsBlock(plugins.Where(p => !p.ToString().StartsWith("Turbo.Plugins.Default.")), rowHeaderX, x, currentY, columnsTotalWidth, layout.Metrics.Height);
            //currentY = DrawPluginsBlock(plugins.Where(p => p.ToString().StartsWith("Turbo.Plugins.Default.")), rowHeaderX, x, currentY, columnsTotalWidth, layout.Metrics.Height, "{0} :");
        }