using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace SDL2Demo.Forms
{

	internal class BlindscanProgressWindow : IRenderable
	{
		public BlindscanProgressWindow()
		{
			prevFram = DateTime.Now;
			currFram = DateTime.Now;
		}
		private DateTime prevFram, currFram;
		public int Start, End, Progress;


		public void Render()
		{
			if (ImGui.Begin("Blindscan Progress", ImGuiWindowFlags.AlwaysAutoResize))
			{
				prevFram = currFram;
				currFram = DateTime.Now;
				if (prevFram.Second != currFram.Second)
					Progress += 1000;

				int secsRemain = (End / 1000) - (Progress / 1000);
				TimeSpan remainTime = new TimeSpan(0, 0, secsRemain + 20);

				double frac = ((double)(Progress - Start) * 100.0) / (double)(End - Start);
				ImGui.Text("Progress: ");
				ImGui.SameLine();
				ImGui.SetNextItemWidth(100);
				float progressBarFrac = Convert.ToSingle(frac) / 100.0f;
				ImGui.ProgressBar(progressBarFrac, Vector2.Zero, String.Format("{0:0.##}%", frac));

				ImGui.Text(String.Format("Estimated Time Remaining: {0}", remainTime.ToString()));
				ImGui.Text(String.Format("Starting Frequency: {0} kHz", Start));
				ImGui.Text(String.Format("Scanning Frequency: {0} kHz", Progress));
				ImGui.Text(String.Format("Ending Frequency: {0} kHz", End));
				ImGui.End();
			}
		}
	}

}
