using skyscraper5.UI.Overrides;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper5.UI
{
	internal class PidListViewItem : ListViewItem
	{
		public PidListViewItem(int pid)
		{
			SubItems.Add(new ListViewSubItem());
			SubItems.Add(new ListViewSubItem());
			SubItems.Add(new ListViewSubItem());
			SubItems.Add(new ListViewSubItem());

			this.PID = pid;
		}

		private int _pid;
		public int PID
		{
			get
			{
				return _pid;
			}
			set
			{
				_pid = value;
				Text = String.Format("0x{0:X4}", value);
			}
		}

		public ulong PackagesInPid { get; private set; }
		public double Percentage { get; private set; }

		public string ProgramName
		{
			get
			{
				return SubItems[3].Text;
			}
			set
			{
				SubItems[3].Text = value;
			}
		}

		public string UsageLabel
		{
			get
			{
				return SubItems[4].Text;
			}
			set
			{
				SubItems[4].Text = value;
			}
		}

		public void SetPackageStats(ulong packagesInPid, ulong totalPackagesOverall)
		{
			SubItems[1].Text = packagesInPid.ToString();

			this.Percentage = (double)packagesInPid / (double)totalPackagesOverall;
			SubItems[2].Text = Math.Round(this.Percentage * 100.0, 2) + "%";

			this.PackagesInPid = packagesInPid;
		}

	}
}
