123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745 |
- using BsWidget.BeatSaberHttpStatus;
- using BsWidget.BsYurHttpStatus;
- using BsWidgetShareCodes;
- using OpenHardwareMonitor.Hardware;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Linq;
- using System.Net.Http;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using BsWidget.BSDataPuller;
- namespace BsWidget;
- internal class MainForm : BaseForm
- {
- private const float RecordPixel = 2.5f;
- private const string FontName = "BIZ UDGothic Bold";
- private Timer _updateTimer;
- private Timer _pcTimer;
- private BlockingCollection<UpdateFlags> _queue;
- private BsYurHttpStatusClient _yurClient;
- //private BeatSaberHttpStatusClient _client;
- private BsDataPullerClient _client;
- private Computer _computer;
- private Font _smallFont = new Font(FontName, 12, FontStyle.Regular, GraphicsUnit.Pixel);
- private Font _mediumFont = new Font(FontName, 20, FontStyle.Regular, GraphicsUnit.Pixel);
- [Flags]
- private enum UpdateFlags
- {
- BeatMap = 1 << 0,
- Performance = 1 << 1,
- NoteFullyCut = 1 << 2,
- ClearAll = 1 << 3,
- RefreshAll = 1 << 4,
- CpuAndGpu = 1 << 5,
- }
- public Image SongIcon { get; set; } = Properties.Resources.sample_cover;
- public string SongName { get; set; } = "Song Name";
- public string SongSubName { get; set; } = "Song Sub Name";
- public string SongArtist { get; set; } = "Song Artist";
- public string BeatMapper { get; set; } = "Mapper";
- public string Difficulty { get; set; } = "Difficulty";
- public double SongBpm { get; set; } = 123;
- public double SongNjs { get; set; } = 23;
- public int CurrentScore { get; set; } = 12345;
- public int CurrentCombo { get; set; } = 120;
- public string CurrentRank { get; set; } = "XX";
- public double CurrentAcc { get; set; } = 0.0;
- public int CurrentHitsPerSecond { get; set; }
- public int CurrentMissed { get; set; }
- public float? CurrentCpuUsage { get; set; } = 12.3f;
- public float? CurrentCpuGhz { get; set; } = 2.333f;
- public float? CurrentGpuUsage { get; set; } = 45.6f;
- public YurStatus CurrentYurStatus { get; set; } = new YurStatus { HeartRate = 0, KcalPerMin = 0 };
- public int? MaxHitsPerSecond { get; set; }
- public float? MaxHeartRate { get; set; }
- /// <summary> FinalScore,CurrentCombo </summary>
- public List<HistoryModel> CutHistory { get; set; }
- public class HistoryModel
- {
- public DateTime Time { get; set; }
- public int HitScore { get; set; }
- public int CurrentCombo { get; set; }
- public float Acc { get; set; }
- public int HitsPerSecond { get; set; }
- public float HeartRate { get; set; }
- public float KcalPerMin { get; set; }
- public int ComboDelta { get; set; }
- }
- public MainForm()
- {
- KeyPreview = true;
- FormBorderStyle = FormBorderStyle.None;
- //_client = new BeatSaberHttpStatusClient();
- _client = new BsDataPullerClient();
- //_client.Event += BeatSaber_Event;
- _client.Event += BsDataPuller_Event;
- _yurClient = new BsYurHttpStatusClient();
- _yurClient.Event += Yur_Event;
- if (Program.NoPerf)
- {
- }
- else
- {
- _computer = new Computer();
- _computer.CPUEnabled = true;
- _computer.GPUEnabled = true;
- _computer.FanControllerEnabled = false;
- _computer.HDDEnabled = false;
- _computer.MainboardEnabled = false;
- _computer.RAMEnabled = false;
- _computer.Open();
- _pcTimer = new Timer { Interval = 750 };
- _pcTimer.Tick += PcTimer_Tick;
- }
- _queue = new BlockingCollection<UpdateFlags>();
- CutHistory = new List<HistoryModel>();
- _updateTimer = new Timer { Interval = 25 };
- _updateTimer.Tick += UpdateTimer_Tick;
- }
- protected override void OnLoad(EventArgs e)
- {
- Text = "Beat Saber Status Widget";
- base.OnLoad(e);
- Font = new Font(FontName, 30, FontStyle.Bold, GraphicsUnit.Pixel);
- TopMost = false;
- WindowState = FormWindowState.Normal;
- _updateTimer.Start();
- _client.Start();
- _yurClient.Start();
- _pcTimer?.Start();
- #if DEBUG
- Task.Run(Debugging);
- #endif
- }
- private async void Debugging()
- {
- lock (CutHistory)
- {
- CutHistory.Add(new HistoryModel { HeartRate = 30, KcalPerMin = 30 });
- CutHistory.Add(new HistoryModel { HeartRate = 1, KcalPerMin = 1 });
- }
- var rng = new Random();
- while (Visible)
- {
- lock (CutHistory)
- {
- if (CutHistory.Count > (Width / RecordPixel) * 2) CutHistory.RemoveRange(0, CutHistory.Count / 2);
- var historyModel = new HistoryModel
- {
- HitsPerSecond = rng.Next(15),
- HeartRate = 15 + rng.Next(2),
- KcalPerMin = 15 + rng.Next(2),
- };
- CutHistory.Add(historyModel);
- CutHistory.Add(historyModel);
- //CutHistory.Add(historyModel);
- }
- _queue.Add(UpdateFlags.NoteFullyCut);
- await Task.Delay(1000 / 15);
- }
- }
- protected override void OnMouseDoubleClick(MouseEventArgs e)
- {
- base.OnMouseDoubleClick(e);
- #if DEBUG
- _queue.Add(UpdateFlags.RefreshAll);
- #else
- _queue.Add(UpdateFlags.ClearAll);
- #endif
- }
- protected override void OnShown(EventArgs e)
- {
- WindowState = FormWindowState.Normal;
- Location = Screen.PrimaryScreen.Bounds.Location;
- ClientSize = Screen.PrimaryScreen.Bounds.Size;
- TopMost = true;
- base.OnShown(e);
- if (_queue.Count == 0)
- {
- _queue.Add(UpdateFlags.RefreshAll);
- }
- }
- protected override void OnFormClosing(FormClosingEventArgs e)
- {
- _updateTimer.Stop();
- _pcTimer?.Stop();
- base.OnFormClosing(e);
- }
- protected override void OnFormClosed(FormClosedEventArgs e)
- {
- _client.Stop();
- _yurClient.Stop();
- _computer?.Close();
- base.OnFormClosed(e);
- }
- protected override void OnKeyDown(KeyEventArgs e)
- {
- base.OnKeyDown(e);
- if (e.KeyCode == Keys.Escape) Application.Exit();
- }
- private void BeatSaber_Event(object sender, BeatSaberStatusEventArgs e)
- {
- var flags = (UpdateFlags)0;
- if (e.Event == "menu" && CutHistory.Count > 0)
- {
- lock (CutHistory)
- {
- CutHistory.Clear();
- }
- flags |= UpdateFlags.ClearAll;
- CurrentMissed = 0;
- }
- if (null != e.Status.Beatmap)
- {
- CurrentMissed = 0;
- var bytes = Convert.FromBase64String(e.Status.Beatmap.SongCover);
- using var stream = new MemoryStream(bytes);
- var newImg = Image.FromStream(stream);
- var old = SongIcon;
- SongIcon = newImg;
- old?.Dispose();
- SongName = e.Status.Beatmap.SongName;
- SongSubName = e.Status.Beatmap.SongSubName;
- SongArtist = e.Status.Beatmap.SongAuthorName;
- BeatMapper = e.Status.Beatmap.LevelAuthorName;
- if (string.IsNullOrEmpty(BeatMapper)) BeatMapper = "Unknown Mapper";
- Difficulty = e.Status.Beatmap.Difficulty.ToUpper();
- if (Difficulty == "EXPERTPLUS") Difficulty = "EXPERT+";
- SongBpm = e.Status.Beatmap.SongBPM;
- SongNjs = e.Status.Beatmap.NoteJumpSpeed;
- flags |= UpdateFlags.BeatMap;
- }
- if (null != e.Status.Performance)
- {
- CurrentScore = e.Status.Performance.Score;
- CurrentCombo = e.Status.Performance.Combo;
- CurrentRank = e.Status.Performance.Rank;
- //CurrentMaxScore = e.Status.Performance.CurrentMaxScore;
- flags |= UpdateFlags.Performance;
- }
- if (e.Event == "noteMissed")
- {
- ++CurrentMissed;
- flags |= UpdateFlags.Performance;
- }
- if (e.Event == "noteFullyCut" && null != e.NoteCut?.FinalScore)
- {
- lock (CutHistory)
- {
- var now = DateTime.Now;
- var preNow = now.AddSeconds(-1);
- CurrentHitsPerSecond = CutHistory.Count(p => p.Time > preNow);
- CutHistory.Add(new HistoryModel
- {
- Time = now,
- HitScore = e.NoteCut.FinalScore.Value,
- CurrentCombo = CurrentCombo,
- //Percent = CurrentMaxScore == 0 ? 0 : ((float)CurrentScore / CurrentMaxScore),
- HitsPerSecond = CurrentHitsPerSecond,
- HeartRate = CurrentYurStatus.HeartRate,
- KcalPerMin = CurrentYurStatus.KcalPerMin,
- });
- }
- flags |= UpdateFlags.NoteFullyCut;
- }
- if (flags == 0)
- {
- }
- else
- {
- _queue.Add(flags);
- }
- }
- private void BsDataPuller_Event(object sender, BsDataPullerEventArgs e)
- {
- if (e.Type == BsDataPullerEventArgsType.LiveData)
- {
- if (e.LiveData.Score == 0) //new game start
- {
- CurrentHitsPerSecond = 0;
- lock (CutHistory) CutHistory.Clear();
- MaxHitsPerSecond = null;
- MaxHeartRate = null;
- }
- var comboDelta = e.LiveData.Combo - CurrentCombo;
- if (comboDelta < 0) comboDelta = 0;
- CurrentScore = e.LiveData.Score;
- CurrentCombo = e.LiveData.Combo;
- CurrentRank = e.LiveData.Rank;
- CurrentAcc = e.LiveData.Accuracy;
- CurrentMissed = e.LiveData.Misses;
- lock (CutHistory)
- {
- var now = DateTime.Now;
- var preNow = now.AddSeconds(-1);
- CurrentHitsPerSecond = CutHistory.Where(p => p.Time > preNow).Sum(p => p.ComboDelta);
- if (CurrentHitsPerSecond > MaxHitsPerSecond || MaxHitsPerSecond.HasValue == false) MaxHitsPerSecond = CurrentHitsPerSecond;
- CutHistory.Add(new HistoryModel
- {
- Time = now,
- HitScore = e.LiveData.BlockHitScore.Total,
- CurrentCombo = CurrentCombo,
- ComboDelta = comboDelta,
- Acc = (float)CurrentAcc,
- HitsPerSecond = CurrentHitsPerSecond,
- HeartRate = CurrentYurStatus.HeartRate,
- KcalPerMin = CurrentYurStatus.KcalPerMin,
- });
- }
- _queue.Add(UpdateFlags.Performance | UpdateFlags.NoteFullyCut);
- }
- if (e.Type == BsDataPullerEventArgsType.MapData)
- {
- SongName = e.MapData.SongName;
- SongSubName = e.MapData.SongSubName;
- SongArtist = e.MapData.SongAuthor;
- BeatMapper = e.MapData.Mapper;
- if (string.IsNullOrEmpty(BeatMapper)) BeatMapper = "Unknown Mapper";
- Difficulty = e.MapData.Difficulty.ToUpper();
- if (Difficulty == "EXPERTPLUS") Difficulty = "EXPERT+";
- if (Difficulty.Length == 0) Difficulty = "???";
- SongBpm = e.MapData.BPM;
- SongNjs = e.MapData.NJS;
- if (e.MapData.CoverImage != null)
- {
- using var hc = new HttpClient();
- var bytes = hc.GetAsync(e.MapData.CoverImage).Result.Content.ReadAsByteArrayAsync().Result;
- using var stream = new MemoryStream(bytes);
- var newImg = Image.FromStream(stream);
- var old = SongIcon;
- SongIcon = newImg;
- old?.Dispose();
- }
- else SongIcon = Properties.Resources.sample_cover;
- _queue.Add(UpdateFlags.ClearAll | UpdateFlags.RefreshAll);
- }
- }
- private void Yur_Event(object sender, YurStatus e)
- {
- CurrentYurStatus = e;
- if (e.HeartRate > MaxHeartRate || MaxHeartRate.HasValue == false) MaxHeartRate = e.HeartRate;
- _queue.Add(UpdateFlags.Performance);
- }
- private void PcTimer_Tick(object sender, EventArgs e)
- {
- try
- {
- foreach (var hardware in _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU || p.HardwareType == HardwareType.GpuNvidia || p.HardwareType == HardwareType.GpuAti))
- {
- hardware.Update();
- }
- }
- catch (Exception)
- {
- return;
- }
- try
- {
- var mhz = _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU).SelectMany(p => p.Sensors)
- .Where(p => p.SensorType == SensorType.Clock).Select(p => p.Value).Max();
- if (mhz.HasValue)
- {
- CurrentCpuGhz = mhz / 1000f;
- }
- else
- {
- CurrentCpuGhz = null;
- }
- }
- catch
- {
- CurrentCpuGhz = null;
- }
- try
- {
- CurrentCpuUsage = _computer.Hardware.Where(p => p.HardwareType == HardwareType.CPU).SelectMany(p => p.Sensors)
- .Where(p => p.SensorType == SensorType.Load && p.Name == "CPU Total").Select(p => p.Value).Max();
- }
- catch
- {
- CurrentCpuUsage = null;
- }
- try
- {
- CurrentGpuUsage = _computer.Hardware.Where(p => p.HardwareType == HardwareType.GpuNvidia || p.HardwareType == HardwareType.GpuAti).SelectMany(p => p.Sensors)
- .Where(p => p.SensorType == SensorType.Load && p.Name == "GPU Core").Select(p => p.Value).Max();
- }
- catch
- {
- CurrentGpuUsage = null;
- }
- _queue.Add(UpdateFlags.CpuAndGpu);
- }
- private void UpdateTimer_Tick(object sender, EventArgs e)
- {
- if (_queue.Count == 0) return;
- UpdateGraphic();
- }
- protected override void RenderGraphic(Graphics g)
- {
- const int margin = 10;
- const int chHeight = 64;
- var chWidth = ViewSize.Width - margin * 2;
- if ((_queue?.Count ?? 0) == 0) return;
- var flags = _queue.Take();
- if (flags.HasFlag(UpdateFlags.ClearAll)) g.Clear(Color.Transparent);
- g.SetHighQuality();
- if (flags.HasFlag(UpdateFlags.NoteFullyCut) || flags.HasFlag(UpdateFlags.RefreshAll))
- {
- const int chLeft = margin;
- const int chTop = margin;
- var chBottom = chTop + chHeight;
- var LineWidth = 1.5f;
- var displayCount = (int)(chWidth / RecordPixel);
- using var scorePen = new Pen(Color.FromArgb(200, 255, 0, 0), LineWidth) { LineJoin = LineJoin.Round };
- using var comboPen = new Pen(Color.FromArgb(200, 0, 0, 255), LineWidth) { LineJoin = LineJoin.Round };
- using var accPen = new Pen(Color.FromArgb(200, Color.Purple), LineWidth) { LineJoin = LineJoin.Round };
- using var cpsPen = new Pen(Color.Yellow, LineWidth) { LineJoin = LineJoin.Round };
- using var calPen = new Pen(Color.FromArgb(200, Color.Lime), LineWidth) { LineJoin = LineJoin.Round, };
- using var heartPen = new Pen(Color.White, LineWidth) { LineJoin = LineJoin.Round, DashStyle = DashStyle.Dot };
- using var dashPen = new Pen(Color.DarkOrange);
- dashPen.DashStyle = DashStyle.Dash;
- dashPen.Width = LineWidth * 2;
- dashPen.DashOffset = LineWidth * 2;
- using var dashPen2 = new Pen(Color.DarkGray);
- dashPen2.DashStyle = DashStyle.Dash;
- dashPen2.Width = LineWidth * 2;
- dashPen2.DashOffset = LineWidth * 2;
- //clear region 0,210 Wx200
- g.ClearRect(Color.Transparent, 0, chTop - 3, ViewSize.Width, chHeight + 6 + margin * 2);
- //draw chart
- using var bgBrush = new SolidBrush(Color.FromArgb(90, 255, 255, 255));
- g.FillRectangle(bgBrush, chLeft, chTop, chWidth, chHeight);
- g.DrawRectangle(Pens.White, chLeft - 1, chTop - 1, chWidth + 2, chHeight + 2);
- if (CutHistory.Count > 1)
- {
- HistoryModel[] items;
- lock (CutHistory)
- {
- var skip = CutHistory.Count > displayCount ? CutHistory.Count - displayCount : 0;
- items = CutHistory.Skip(skip).ToArray();
- }
- if (items.Length > 1)
- {
- var minScore = items.Select(p => p.HitScore).Min();
- var maxScore = items.Select(p => p.HitScore).Max();
- var rngScore = maxScore - minScore;
- if (rngScore < 1) rngScore = 1;
- var minCombo = items.Select(p => p.CurrentCombo).Min();
- var maxCombo = items.Select(p => p.CurrentCombo).Max();
- var rngCombo = maxCombo - minCombo;
- if (rngCombo < 1) rngCombo = 1;
- var minHea = items.Select(p => p.HeartRate).Min();
- var maxHea = items.Select(p => p.HeartRate).Max();
- var rngHea = maxHea - minHea;
- if (rngHea < 1) rngHea = 1;
- var minCal = items.Select(p => p.KcalPerMin).Min();
- var maxCal = items.Select(p => p.KcalPerMin).Max();
- var rngCal = maxCal - minCal;
- if (rngCal < 1) rngCal = 1;
- var minCps = items.Select(p => p.HitsPerSecond).Min();
- var maxCps = items.Select(p => p.HitsPerSecond).Max();
- var rngCps = maxCps - minCps;
- if (rngCps < 1) rngCps = 1;
- var baseX = chWidth - items.Length * RecordPixel + chLeft + 1;
- var scorePts = new List<PointF>();
- var comboPts = new List<PointF>();
- var accPts = new List<PointF>();
- var heaPts = new List<PointF>();
- var calPts = new List<PointF>();
- var cpsPts = new List<PointF>();
- var peaks = new List<Tuple<int, float>>();
- var skipFirst = true;
- for (var i = 0; i < items.Length; i++)
- {
- var item = items[i];
- var pointX = baseX + RecordPixel * i;
- scorePts.Add(new PointF(pointX, (chBottom - 1) - (chHeight - 2) * ((float)(item.HitScore - minScore) / rngScore)));
- comboPts.Add(new PointF(pointX, (chBottom - 1) - (chHeight - 2) * ((float)(item.CurrentCombo - minCombo) / rngCombo)));
- accPts.Add(new PointF(pointX, (chBottom - 1) - (chHeight - 2) * item.Acc / 100));
- cpsPts.Add(new PointF(pointX, (chBottom - 1) - (chHeight - 2) * ((float)(item.HitsPerSecond - minCps) / rngCps)));
- heaPts.Add(new PointF(pointX, (chBottom - 1) - (chHeight - 2) * ((item.HeartRate - minHea) / rngHea)));
- calPts.Add(new PointF(pointX, (chBottom - 1) - (chHeight - 2) * ((item.KcalPerMin - minCal) / rngCal)));
- if (peaks.Count > 0)
- {
- var maxVal = peaks.OrderByDescending(p => p.Item1).First();
- var topX = peaks.Where(p => p.Item1 == maxVal.Item1).OrderBy(p => p.Item2).Select(p => p.Item2).First();
- if (pointX - topX > margin * 2)
- {
- peaks.Clear();
- if (skipFirst)
- {
- skipFirst = false;
- }
- else
- {
- g.DrawLine(dashPen, topX, chTop, topX, chBottom);
- g.DrawStringWithRoundedRect(maxVal.Item1 + "", _smallFont, topX - 4, chBottom, Brushes.Black, Brushes.Yellow, margin / 2.0f);
- }
- }
- }
- if (i > 0 && i < items.Length - 1)
- {
- var prevItem = items[i - 1];
- var nextItem = items[i + 1];
- if (prevItem.HitsPerSecond <= item.HitsPerSecond && item.HitsPerSecond > nextItem.HitsPerSecond)
- {
- //peak detected
- if (peaks.Count > 0)
- {
- if (peaks.Max(p => p.Item1) < item.HitsPerSecond)
- {
- peaks.Add(new Tuple<int, float>(item.HitsPerSecond, pointX));
- //g.DrawLine(dashPen2, pointX, chTop, pointX, chBottom);
- }
- }
- else
- {
- peaks.Add(new Tuple<int, float>(item.HitsPerSecond, pointX));
- //g.DrawLine(dashPen2, pointX, chTop, pointX, chBottom);
- }
- }
- }
- }
- g.DrawLines(scorePen, scorePts.ToArray());
- g.DrawLines(comboPen, comboPts.ToArray());
- g.DrawLines(accPen, accPts.ToArray());
- g.DrawLines(cpsPen, cpsPts.ToArray());
- g.DrawLines(calPen, calPts.ToArray());
- g.DrawLines(heartPen, heaPts.ToArray());
- }
- }
- }
- if (flags.HasFlag(UpdateFlags.Performance) || flags.HasFlag(UpdateFlags.RefreshAll))
- {
- float x = margin;
- float y = chHeight + margin * 3;
- //clear region 0,180 Wx180
- g.ClearRect(Color.Transparent, 0, y, ViewSize.Width, 150);
- //draw text
- var sz = g.DrawStringWithOutline($"{CurrentScore:N0}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRectPerf("POINT", _smallFont, x, y + margin * 1.5f, Brushes.White, Brushes.Red,
- 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{CurrentCombo}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRectPerf("COMBO", _smallFont, x, y + margin * 1.5f, Brushes.White, Brushes.Blue,
- 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{CurrentRank} / {CurrentAcc:N}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRectPerf("RANK / ACC", _smallFont, x, y + margin * 1.5f, Brushes.White,
- Brushes.Purple, 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{CurrentHitsPerSecond}", Font, x, y, Color.Black, Color.White);
- g.DrawStringWithOutline($"{(MaxHitsPerSecond.HasValue ? $"{MaxHitsPerSecond:N0}" : "-")} max", Font, x, y + Font.Height, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRectPerf("HIT / SEC", _smallFont, x, y + margin * 1.5f, Brushes.Black,
- Brushes.Yellow, 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{CurrentYurStatus.KcalPerMin:N1}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRectPerf("KCAL / MIN", _smallFont, x, y + margin * 1.5f, Brushes.Black,
- Brushes.Lime, 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{CurrentYurStatus.HeartRate:N1}", Font, x, y, Color.Black, Color.White);
- g.DrawStringWithOutline($"{(MaxHeartRate.HasValue ? $"{MaxHeartRate:N1}" : "-")} max", Font, x, y + Font.Height, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRectPerf("HEART", _smallFont, x, y + margin * 1.5f, Brushes.Black, Brushes.White, 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{CurrentMissed}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- // ReSharper disable once RedundantAssignment
- sz = g.DrawStringWithRoundedRectPerf("MISS", _smallFont, x, y + margin * 1.5f, Brushes.White,
- Brushes.DarkSlateGray, 2.5f);
- }
- if (flags.HasFlag(UpdateFlags.BeatMap) || flags.HasFlag(UpdateFlags.RefreshAll))
- {
- TopMost = false;
- Application.DoEvents();
- TopMost = true;
- Application.DoEvents();
- BringToFront();
- Application.DoEvents();
- const int coverSize = 130;
- g.ClearRect(Color.Transparent, 0, ViewSize.Height - (coverSize + 100), ViewSize.Width, coverSize + 100);
- var coverLeft = margin;
- var coverTop = ViewSize.Height - coverSize - margin;
- g.DrawImage(SongIcon, coverLeft, coverTop, coverSize, coverSize);
- g.DrawRectangle(Pens.White, coverLeft, coverTop, coverSize, coverSize);
- g.DrawStringWithRoundedRect(Difficulty, Font, coverLeft, coverTop - 100, Brushes.Black, Brushes.White);
- {
- float x = margin;
- var y = coverTop - 50;
- var sz = g.DrawStringWithOutline($"{SongBpm}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithRoundedRect("BPM", _smallFont, x, y + margin * 1.5f, Brushes.Black, Brushes.White, 2.5f);
- x += sz.Width + margin * 2;
- sz = g.DrawStringWithOutline($"{SongNjs}", Font, x, y, Color.Black, Color.White);
- x += sz.Width + margin * 2;
- // ReSharper disable once RedundantAssignment
- sz = g.DrawStringWithRoundedRect("NJS", _smallFont, x, y + margin * 1.5f, Brushes.Black, Brushes.White, 2.5f);
- }
- {
- var bootom = ViewSize.Height - margin;
- var left = coverSize + margin * 2;
- var fontDeltaH = 1.3f;
- var sz = g.MeasureString(SongName, _mediumFont);
- g.DrawStringWithOutline(SongName, _mediumFont, left, bootom - sz.Height * fontDeltaH, Color.Black, Color.White);
- sz = g.MeasureString(SongSubName, _mediumFont);
- g.DrawStringWithOutline(SongSubName, _mediumFont, left, bootom - (sz.Height * fontDeltaH) * 2, Color.Black, Color.White);
- sz = g.MeasureString(SongArtist, _mediumFont);
- g.DrawStringWithOutline(SongArtist, _mediumFont, left, bootom - (sz.Height * fontDeltaH) * 3, Color.Black, Color.White);
- sz = g.MeasureString(BeatMapper, _mediumFont);
- g.DrawStringWithOutline(BeatMapper, _mediumFont, left, bootom - (sz.Height * fontDeltaH) * 4, Color.Black, Color.White);
- }
- }
- if (Program.NoPerf == false && (flags.HasFlag(UpdateFlags.CpuAndGpu) || flags.HasFlag(UpdateFlags.RefreshAll)))
- {
- var width = 800;
- var height = 50;
- var field = 400;
- var left = ViewSize.Width - width;
- var top = ViewSize.Height - height;
- g.ClearRect(Color.Transparent, left, top, width, height);
- g.DrawStringWithOutline($"CPU: {CurrentCpuGhz:N1}GHz {CurrentCpuUsage:N1}%", Font, left, top, Color.Black, Color.White);
- g.DrawStringWithOutline($"GPU: {CurrentGpuUsage:N0}%", Font, left + field, top, Color.Black, Color.White);
- }
- }
- }
|