private async void RenderOSD() { while (true) { osdGraphics.BeginScene(); osdGraphics.ClearScene(brushTransparent); if (cbEnableOSD.IsChecked.Value && navigationKeyDown || !cbHideOSD.IsChecked.Value || cbOSDPlaying.IsChecked.Value && outputDevice != null) { if (dgMemeFiles.SelectedIndex >= 0) { int counter = 0; osdGraphics.FillRoundedRectangle(brushBackground, 0f, 0f, (float)Math.Pow(osdFont.FontSize, 2), (osdFont.FontSize * Math.Min(rangeSize + 1, (dgMemeFiles.Items.Count - rangeStart)) + 5f), 3.0f); List <MemeSound> subList = memeList.ToList().GetRange(rangeStart, Math.Min(rangeSize + 1, (dgMemeFiles.Items.Count - rangeStart))); foreach (MemeSound memeSound in subList) { if (memeSound.isPlaying) { if (cbOSDProgress.IsChecked.GetValueOrDefault()) { float songPercentage = (float)((DateTime.Now - soundPlayStart).TotalSeconds * 100 / (soundPlayEnd - soundPlayStart).TotalSeconds); osdGraphics.DrawVerticalProgressBar(brushProgressOutline, brushProgressFill, 1, (counter * osdFont.FontSize), (float)Math.Pow(osdFont.FontSize, 2), (counter * osdFont.FontSize) + osdFont.FontSize + 5f, 2.0f, songPercentage); } osdGraphics.DrawTextWithLayout(osdFont, osdFont.FontSize, brushPlayingText, brushTransparent, 10, counter * osdFont.FontSize, new GameOverlay.Drawing.Rectangle(10, counter * osdFont.FontSize, (float)Math.Pow(osdFont.FontSize, 2), (counter * osdFont.FontSize) + osdFont.FontSize + 5f), memeSound.Name, 2); } else { osdGraphics.DrawTextWithLayout(osdFont, osdFont.FontSize, (memeSound.isSelected) ? brushSelectedText : brushNormalText, brushTransparent, 10, counter * osdFont.FontSize, new GameOverlay.Drawing.Rectangle(10, counter * osdFont.FontSize, (float)Math.Pow(osdFont.FontSize, 2), (counter * osdFont.FontSize) + osdFont.FontSize + 5f), memeSound.Name, 2); } counter++; } } } osdGraphics.EndScene(); await Task.Delay(10); } }