using System;
using System.Collections.Generic;
using Gtk;
using System.IO;

namespace DMX2
{
	[System.ComponentModel.ToolboxItem(true)]
	public partial class DriverBoitierV2UI : Gtk.Bin
	{
		DriverBoitierV2 drv;
		public DriverBoitierV2UI (DriverBoitierV2 _drv)
		{
			drv = _drv;
			this.Build ();
			ConstruitCBUnivers();
		}

	ListStore lsCbUnivers1 = new ListStore(typeof(UniversDMX));	
	ListStore lsCbUnivers2 = new ListStore(typeof(UniversDMX));
	void ConstruitCBUnivers ()
		{
			cbUnivers1.Model = lsCbUnivers1;
			var cellCbUnivers1 = new CellRendererText();
			cbUnivers1.PackStart(cellCbUnivers1,false);
			cbUnivers1.SetCellDataFunc(cellCbUnivers1, new CellLayoutDataFunc(RenderUniversName1));


			foreach(UniversDMX u in Conduite.Courante.Patches)
				lsCbUnivers1.AppendValues(u);

			TreeIter iter;
			lsCbUnivers1.GetIterFirst(out iter);
			cbUnivers1.SetActiveIter(iter);

			cbUnivers2.Model = lsCbUnivers2;
			var cellCbUnivers2 = new CellRendererText();
			cbUnivers2.PackStart(cellCbUnivers2,false);
			cbUnivers2.SetCellDataFunc(cellCbUnivers2, new CellLayoutDataFunc(RenderUniversName2));


			foreach(UniversDMX u in Conduite.Courante.Patches)
				lsCbUnivers2.AppendValues(u);

			//TreeIter iter;
			lsCbUnivers2.GetIterFirst(out iter);
			cbUnivers2.SetActiveIter(iter);

		}

		void RenderUniversName1 (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
		{
			UniversDMX univers =  tree_model.GetValue (iter, 0) as UniversDMX;
			if(univers != null)
			(cell as Gtk.CellRendererText).Text = univers.Nom;
		}

		void RenderUniversName2 (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
		{
			UniversDMX univers =  tree_model.GetValue (iter, 0) as UniversDMX;
			if(univers != null)
			(cell as Gtk.CellRendererText).Text = univers.Nom;
		}

	}
}

