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 Telerik.WinControls.UI;

namespace TelerikTestSub
{
	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}

		private List<TestParItem> items = new List<TestParItem>();

		private void MainForm_Load(object sender, EventArgs e)
		{
			radGridView1.AutoGenerateColumns = false;
			gridViewSubTemplate.AutoGenerateColumns = false;

			var col = radGridView1.Columns["colTestType"] as GridViewComboBoxColumn;
			col.ValueMember = "Value";
			col.DisplayMember = "Display";
			col.DataSource = ((TestType[])Enum.GetValues(typeof(TestType))).Select(v => new { Value = v, Display = v.ToString() }).ToList();

			items.Add(new TestParItem() { PosIndex = 0, TestType = TestType.AbsPos, R = 5, Fi = 45, Min = 11, Max = 21, Comment = "test 1", Disabled = false });
			items.Add(new TestParItem() { PosIndex = 1, TestType = TestType.RelPos, R = 6, Fi = 46, Min = 12, Max = 22, Comment = "test 2", Disabled = false });
			items.Add(new TestParItem() { PosIndex = 2, TestType = TestType.AbsPos, R = 7, Fi = 47, Min = 13, Max = 23, Comment = "test 3", Disabled = true });
			var item = new TestParItem() { PosIndex = 3, TestType = TestType.TestSub, R = 8, Fi = 48, Min = 14, Max = 24, Comment = "test 4", Disabled = false };
			AddSubItems(item);
			items.Add(item);
			item = new TestParItem() { PosIndex = 4, TestType = TestType.TestSub, R = 9, Fi = 49, Min = 15, Max = 25, Comment = "test 5", Disabled = false };
			AddSubItems(item);
			items.Add(item);


			radGridView1.DataSource = items;
		}

		private void AddSubItems(TestParItem item)
		{
			item.SubItems.Add(new TestParSubItem() { PosIndex = 0, Name = "Diameter", Min = 3, Max = 4, Disabled = false });
			item.SubItems.Add(new TestParSubItem() { PosIndex = 1, Name = "Height", Min = 10, Max = 12, Disabled = false });
			item.SubItems.Add(new TestParSubItem() { PosIndex = 2, Name = "Angle", Min = -5, Max = 5, Disabled = false });
		}
	}
}
