using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AR;

namespace Project.Dialog
{
	public partial class fSavePosition : Form
	{
		public fSavePosition(Queue<Tuple<DataSet1.MCModelRow, eAxis, string, double, double>> list)
		{
			InitializeComponent();

			listView1.Items.Clear();
			foreach (var item in list)
			{
				var lv = this.listView1.Items.Add(item.Item2.ToString());
				lv.SubItems.Add(item.Item3);
				lv.SubItems.Add(item.Item4.ToString());
				lv.SubItems.Add(item.Item5.ToString());
				lv.Tag = item;
				if (item.Item2.ToString().StartsWith("Z"))
				{
					lv.Checked = false;  //z축은 기본 해제
					lv.ForeColor = Color.DarkMagenta;
				}
				else if (item.Item4.ToString() == item.Item5.ToString())
				{
					lv.Checked = false; //값이 같으면 해제
				}
				else lv.Checked = true;
			}
		}

		private void button1_Click(object sender, EventArgs e)
		{
			var cnt = 0;
			foreach (ListViewItem item in listView1.CheckedItems)
			{
				var p = item.Tag as Tuple<DataSet1.MCModelRow, eAxis, string, double, double>;
				p.Item1.Position = p.Item5;
				p.Item1.EndEdit();
				cnt += 1;
			}
			if (cnt > 0)
				DialogResult = DialogResult.OK;
			else
				this.Close();
		}

		private void fSavePosition_Load(object sender, EventArgs e)
		{

		}
	}
}
