Ajout d'un début de gestion de la matrice SeqMaitre

This commit is contained in:
tzim 2013-09-30 12:57:39 +00:00
parent 25cd22ee7d
commit 453b8ddd1a
2 changed files with 100 additions and 28 deletions

View file

@ -10,7 +10,7 @@ namespace DMX2
{ {
static MainWindow win; static MainWindow win;
static object circuitKey = new object(); static object circuitKey = new object();
ListStore ls; ListStore lsMatrice;
public static MainWindow Win { public static MainWindow Win {
get { return win; } get { return win; }
@ -88,34 +88,105 @@ namespace DMX2
dureeCell.Edited += OnDureeCellEdited; dureeCell.Edited += OnDureeCellEdited;
this.MatriceUI.AppendColumn (dureeCol); this.MatriceUI.AppendColumn (dureeCol);
ls = new Gtk.ListStore(typeof (SequenceurMaitre.Ligne)); ConstruitMatriceSeqColumns();
this.MatriceUI.Model = ls;
lsMatrice = new Gtk.ListStore(typeof (SequenceurMaitre.Ligne));
this.MatriceUI.Model = lsMatrice;
FillMatrice();
} }
static object seqkey = new object();
void ConstruitMatriceSeqColumns ()
{
foreach(var c in MatriceUI.Columns)
if(c.CellRenderers[0].Data.ContainsKey(seqkey))
MatriceUI.RemoveColumn(c);
Gtk.TreeViewColumn seqCol;
Gtk.CellRendererText seqCell;
foreach (Sequenceur seq in Conduite.Courante.Sequenceurs) {
seqCol = new TreeViewColumn();
seqCell = new CellRendererText();
seqCol.Title = seq.Name;
seqCol.PackStart(seqCell, true);
seqCol.SetCellDataFunc ( seqCell, new Gtk.TreeCellDataFunc(RenderMatriceSeqVal));
seqCell.Editable = true;
seqCell.Edited += OnSeqValCellEdited;
seqCell.Data[seqkey] = seq;
this.MatriceUI.AppendColumn(seqCol);
}
}
void RenderMatriceNum (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) void RenderMatriceNum (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{ {
throw new NotImplementedException (); SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne;
(cell as Gtk.CellRendererText).Text = (Conduite.Courante.SequenceurMaitre.Lignes.IndexOf(l)+1).ToString();
} }
void RenderMatriceNom (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) void RenderMatriceNom (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{ {
throw new NotImplementedException (); SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne;
(cell as Gtk.CellRendererText).Text = l.Nom;
} }
void RenderMatriceDuree (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) void RenderMatriceDuree (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{ {
throw new NotImplementedException (); SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne;
if (l.Duree==-1) (cell as Gtk.CellRendererText).Text = string.Empty;
else (cell as Gtk.CellRendererText).Text = l.Duree.ToString();
} }
void RenderMatriceSeqVal (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne;
Sequenceur seq = cell.Data[seqkey] as Sequenceur;
(cell as Gtk.CellRendererText).Text = l[seq];
}
void FillMatrice ()
{
lsMatrice.Clear ();
foreach (SequenceurMaitre.Ligne l in Conduite.Courante.SequenceurMaitre.Lignes) {
lsMatrice.AppendValues(l);
}
}
void OnNomCellEdited (object o, EditedArgs args) void OnNomCellEdited (object o, EditedArgs args)
{ {
throw new NotImplementedException (); Gtk.TreeIter iter;
lsMatrice.GetIter (out iter, new Gtk.TreePath (args.Path));
SequenceurMaitre.Ligne l = lsMatrice.GetValue(iter,0) as SequenceurMaitre.Ligne;
l.Nom = args.NewText;
} }
void OnDureeCellEdited (object o, EditedArgs args) void OnDureeCellEdited (object o, EditedArgs args)
{ {
throw new NotImplementedException (); Gtk.TreeIter iter;
lsMatrice.GetIter (out iter, new Gtk.TreePath (args.Path));
SequenceurMaitre.Ligne l = lsMatrice.GetValue (iter, 0) as SequenceurMaitre.Ligne;
if (args.NewText.Length == 0)
l.Duree = -1;
else {
int val;
if(int.TryParse(args.NewText, out val))
l.Duree=val;
}
} }
void OnSeqValCellEdited (object o, EditedArgs args)
{
Gtk.CellRendererText cell = o as CellRendererText;
Sequenceur seq = cell.Data[seqkey] as Sequenceur;
Gtk.TreeIter iter;
lsMatrice.GetIter (out iter, new Gtk.TreePath (args.Path));
SequenceurMaitre.Ligne l = lsMatrice.GetValue(iter,0) as SequenceurMaitre.Ligne;
l[seq] = args.NewText;
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a) protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{ {
Application.Quit (); Application.Quit ();
@ -165,6 +236,7 @@ namespace DMX2
Sequenceur s = new SequenceurLineaire(); Sequenceur s = new SequenceurLineaire();
Conduite.Courante.AjoutSequenceur(s); Conduite.Courante.AjoutSequenceur(s);
AddSeqUI(s); AddSeqUI(s);
ConstruitMatriceSeqColumns();
} }
void AddSeqUI (Sequenceur s) void AddSeqUI (Sequenceur s)

View file

@ -53,7 +53,7 @@ namespace DMX2
public SequenceurMaitre () public SequenceurMaitre ()
{ {
lignes.Add(new Ligne());
} }
} }
} }