124 lines
3.4 KiB
C#
124 lines
3.4 KiB
C#
using System;
|
|
using Gtk;
|
|
namespace DMX2
|
|
{
|
|
public partial class EditionUnivers : Gtk.Dialog
|
|
{
|
|
UniversDMX universEdite;
|
|
public EditionUnivers (Window parent) : base ("Edition Univers",parent,DialogFlags.DestroyWithParent)
|
|
{
|
|
this.Build ();
|
|
ConstruitCBUnivers();
|
|
ConstruitCBCircuits();
|
|
ConstruitCBFT();
|
|
}
|
|
|
|
ListStore lsCbUnivers = new ListStore(typeof(UniversDMX));
|
|
|
|
void ConstruitCBUnivers ()
|
|
{
|
|
cbUnivers.Model = lsCbUnivers;
|
|
var cellCbUnivers = new CellRendererText();
|
|
cbUnivers.PackStart(cellCbUnivers,false);
|
|
cbUnivers.SetCellDataFunc(cellCbUnivers, new CellLayoutDataFunc(RenderUniversName));
|
|
|
|
|
|
foreach(UniversDMX u in Conduite.Courante.Patches)
|
|
lsCbUnivers.AppendValues(u);
|
|
|
|
TreeIter iter;
|
|
lsCbUnivers.GetIterFirst(out iter);
|
|
cbUnivers.SetActiveIter(iter);
|
|
|
|
}
|
|
|
|
void RenderFTName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
|
|
{
|
|
object o = tree_model.GetValue (iter, 0);
|
|
if(o!=null)
|
|
(cell as Gtk.CellRendererText).Text = ((UniversDMX.FTransfer)o).ToString();
|
|
|
|
}
|
|
void RenderUniversName (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;
|
|
}
|
|
|
|
ListStore lsCbCircuits = new ListStore(typeof(Circuit));
|
|
void ConstruitCBCircuits ()
|
|
{
|
|
cbCircuit.Model = lsCbCircuits;
|
|
var cellCbCircuit = new CellRendererText();
|
|
cbCircuit.PackStart(cellCbCircuit,true);
|
|
cbCircuit.SetCellDataFunc(cellCbCircuit,new CellLayoutDataFunc(RenderCircuitName));
|
|
|
|
lsCbCircuits.AppendValues("toto");
|
|
foreach (Circuit c in Conduite.Courante.Circuits)
|
|
lsCbCircuits.AppendValues(c);
|
|
|
|
}
|
|
|
|
void RenderCircuitName (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
|
|
{
|
|
Circuit c = tree_model.GetValue (iter, 0) as Circuit;
|
|
if(c != null)
|
|
(cell as Gtk.CellRendererText).Text = c.ID + "-" + c.Name;
|
|
else
|
|
(cell as Gtk.CellRendererText).Text = "--Aucun--";
|
|
|
|
}
|
|
|
|
int currDimm=0;
|
|
|
|
ListStore lsCbFT = new ListStore(typeof(string),typeof(UniversDMX.FTransfer));
|
|
void ConstruitCBFT ()
|
|
{
|
|
var values = Enum.GetValues(typeof(UniversDMX.FTransfer));
|
|
cbFT.Model = lsCbFT;
|
|
//var cellCbFt = new CellRendererText();
|
|
//cbFT.PackStart(cellCbFt,true);
|
|
//cbFT.SetCellDataFunc(cellCbFt,new CellLayoutDataFunc(RenderFTName));
|
|
|
|
foreach(var v in values)
|
|
lsCbFT.AppendValues(v.ToString(), (UniversDMX.FTransfer)v );
|
|
}
|
|
|
|
protected void OnCbUniversChanged (object sender, EventArgs e)
|
|
{
|
|
TreeIter iter;
|
|
if(cbUnivers.GetActiveIter(out iter))
|
|
{
|
|
universEdite = lsCbUnivers.GetValue(iter,0) as UniversDMX;
|
|
}
|
|
}
|
|
|
|
protected void OnBtAddClicked (object sender, EventArgs e)
|
|
{
|
|
var dlg = new Dialog ("Nom ?", this, DialogFlags.Modal);
|
|
var entry = new Entry ("Nouvel Univers");
|
|
dlg.AddButton (Stock.Ok, ResponseType.Ok).GrabDefault ();
|
|
dlg.AddButton (Stock.Cancel, ResponseType.Cancel);
|
|
dlg.VBox.Add (new Label ("Nom de la nouvelle Conduite :"));
|
|
dlg.VBox.Add (entry);
|
|
dlg.VBox.ShowAll ();
|
|
entry.ActivatesDefault = true;
|
|
|
|
if ((ResponseType)dlg.Run () == ResponseType.Ok) {
|
|
UniversDMX univ = new UniversDMX ();
|
|
|
|
univ.Nom = entry.Text;
|
|
lsCbUnivers.AppendValues (univ);
|
|
Conduite.Courante.Patches.Add (univ);
|
|
}
|
|
dlg.Destroy();
|
|
}
|
|
|
|
protected void OnButtonCancelClicked (object sender, EventArgs e)
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
}
|
|
}
|