using System;
using System.Collections.Generic;

namespace QC.QMine.QMineInterface;

public static class QMineGlobalInformation
{
	private delegate bool? ShowWindow();

	private static string serverName;

	private static string databaseName;

	private static string serverDescription = serverName;

	private static string databaseDescription = databaseName;

	private static HashSet<string> defaultLoopConditions = null;

	private static ProgressWindow progressWin = null;

	private static int qMineTempFolderCleanupDays = 5;

	public static string ServerName
	{
		get
		{
			return serverName;
		}
		set
		{
			serverName = value;
		}
	}

	public static string DatabaseName
	{
		get
		{
			return databaseName;
		}
		set
		{
			databaseName = value;
		}
	}

	public static string ServerDescription
	{
		get
		{
			return serverDescription;
		}
		set
		{
			serverDescription = value;
		}
	}

	public static string DatabaseDescription
	{
		get
		{
			return databaseDescription;
		}
		set
		{
			databaseDescription = value;
		}
	}

	public static HashSet<string> DefaultLoopConditions
	{
		get
		{
			if (defaultLoopConditions == null)
			{
				defaultLoopConditions = new HashSet<string>();
				string[] enumerable = new string[24]
				{
					"RF Mode", "Channel", "Temp", "Band", "RC", "Traffic Data Rate", "Cell Power", "Raw_DAC", "Ref Chan", "HdetPwrList",
					"AGC", "agc", "Tx Power", "Index", "Rx_Gain_Range", "LPM", "NVMode", "RxPM", "LNA", "LNARange",
					"RxPath", "PARange", "Technology", "Tx Power Expected"
				};
				enumerable.ForEach(delegate(string loopName)
				{
					defaultLoopConditions.Add(loopName);
				});
			}
			return defaultLoopConditions;
		}
		set
		{
			defaultLoopConditions = value;
		}
	}

	public static ProgressWindow GlobalProgressWindow
	{
		get
		{
			if (progressWin == null)
			{
				progressWin = new ProgressWindow();
			}
			return progressWin;
		}
	}

	public static int QMineTempFolderCleanupDays
	{
		get
		{
			return qMineTempFolderCleanupDays;
		}
		set
		{
			qMineTempFolderCleanupDays = value;
		}
	}

	public static void ShowProgressWindow(string progressText = "Generating Report...", bool isIndeterminate = true, Action cancelAction = null, bool hideRunDetails = false)
	{
		if (Constants.QMineMode != 0)
		{
			return;
		}
		Constants.MainWindowDispatcher.BeginInvoke((Action)delegate
		{
			GlobalProgressWindow.ProgressText = progressText;
			GlobalProgressWindow.ProgressBar1.IsIndeterminate = isIndeterminate;
			GlobalProgressWindow.CancelTextBlock.Text = "Cancel";
			GlobalProgressWindow.IsCancelEnabled = cancelAction != null;
			if (!isIndeterminate)
			{
				GlobalProgressWindow.ProgressBar1.Maximum = 100.0;
				GlobalProgressWindow.ProgressBar1.Minimum = 0.0;
			}
			if (cancelAction != null)
			{
				GlobalProgressWindow.CancelAction = cancelAction;
			}
			if (hideRunDetails)
			{
				GlobalProgressWindow.HideRunDetails();
			}
			GlobalProgressWindow.ShowDialog();
		}, null);
	}

	public static void UpdateProgressWindowText(string progressText)
	{
		if (Constants.QMineMode == QMineModes.GUI)
		{
			Constants.MainWindowDispatcher.BeginInvoke((Action)delegate
			{
				GlobalProgressWindow.ProgressText = progressText;
			}, null);
		}
	}

	public static void UpdateProgressWindowProgress(int progress)
	{
		if (Constants.QMineMode != 0)
		{
			return;
		}
		Constants.MainWindowDispatcher.BeginInvoke((Action)delegate
		{
			if (progress >= 0 && progress <= 100)
			{
				GlobalProgressWindow.ProgressBar1.Value = progress;
			}
		}, null);
	}

	public static void CloseProgessWindow()
	{
		if (Constants.QMineMode == QMineModes.GUI)
		{
			Constants.MainWindowDispatcher.Invoke(new Action(GlobalProgressWindow.HideWindow), null);
		}
	}
}
