diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index 6e7221f..ea10a40 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -33,10 +33,13 @@ namespace DMX2 } } - public void SupprimeCircuit (Circuit c) + public void SupprimeCircuits (IEnumerable lc) { lock (this) { - circuits.Remove (c); + foreach(var c in lc) + circuits.Remove (c); + foreach(var seq in Sequenceurs) + seq.MajCircuitsSupprimes(); } } @@ -104,10 +107,13 @@ namespace DMX2 static int maxid=1; string name; + public const int SNLen= 8; + public Circuit() { id=maxid++; Name = "Circuit n°" + id.ToString(); + ShortName = "Cir" + id.ToString(); } public string Name { @@ -119,6 +125,20 @@ namespace DMX2 } } + string shortName; + + public string ShortName { + get { + return shortName; + } + set { + if (value.Length > SNLen) + shortName = value.Substring(0,SNLen); + else + shortName = value; + } + } + int id; public int ID { diff --git a/DMX-2.0/DMX-2.0.csproj b/DMX-2.0/DMX-2.0.csproj index ce0ec42..fe8edc6 100644 --- a/DMX-2.0/DMX-2.0.csproj +++ b/DMX-2.0/DMX-2.0.csproj @@ -101,6 +101,8 @@ + + \ No newline at end of file diff --git a/DMX-2.0/GestionCircuits.cs b/DMX-2.0/GestionCircuits.cs index 3eb8117..1332aaa 100644 --- a/DMX-2.0/GestionCircuits.cs +++ b/DMX-2.0/GestionCircuits.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Gtk; namespace DMX2 { @@ -10,14 +11,26 @@ namespace DMX2 { this.Build (); - Gtk.TreeViewColumn nameCol = new Gtk.TreeViewColumn(); - Gtk.CellRendererText nameCell = new Gtk.CellRendererText(); + + var nameCol = new Gtk.TreeViewColumn(); + var nameCell = new Gtk.CellRendererText(); nameCol.Title = "Circuit"; nameCol.PackStart(nameCell,true); nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); nameCell.Editable =true; nameCell.Edited += OnNameCellEdited; this.listeCircuits.AppendColumn(nameCol); + + var snameCol = new Gtk.TreeViewColumn(); + var snameCell = new Gtk.CellRendererText(); + snameCol.Title = "Nom Court"; + snameCol.PackStart(snameCell,true); + snameCol.SetCellDataFunc(snameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitShortName) )); + snameCell.Editable =true; + snameCell.Edited += OnShortNameCellEdited; + this.listeCircuits.AppendColumn(snameCol); + + ls = new Gtk.ListStore(typeof (Circuit)); this.listeCircuits.Model = ls; UpdateListeCircuits(); @@ -30,10 +43,25 @@ namespace DMX2 ls.GetIter (out iter, new Gtk.TreePath (args.Path)); Circuit c = ls.GetValue(iter,0) as Circuit; c.Name = args.NewText; - + if(c.Name.Length <= Circuit.SNLen) + c.ShortName = c.Name; } - private void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { + void OnShortNameCellEdited (object o, EditedArgs args) + { + Gtk.TreeIter iter; + ls.GetIter (out iter, new Gtk.TreePath (args.Path)); + Circuit c = ls.GetValue(iter,0) as Circuit; + c.ShortName = args.NewText; + } + + void RenderCircuitShortName (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) + { + Circuit c = tree_model.GetValue (iter, 0) as Circuit; + (cell as Gtk.CellRendererText).Text = c.ShortName; + } + + void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { Circuit c = tree_model.GetValue (iter, 0) as Circuit; (cell as Gtk.CellRendererText).Text = c.Name; } @@ -69,8 +97,7 @@ namespace DMX2 } protected void OnRemoveActionActivated (object sender, EventArgs e) { - foreach (var c in GetSelection()) - Conduite.Courante.SupprimeCircuit (c); + Conduite.Courante.SupprimeCircuits (GetSelection()); UpdateListeCircuits(); } diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index 2c9c611..cbaae8b 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -87,7 +87,16 @@ namespace DMX2 protected void OnSeqLinActionActivated (object sender, EventArgs e) { - SequenceurLineaire s = new SequenceurLineaire(); + Sequenceur s = new SequenceurLineaire(); + Conduite.Courante.AjoutSequenceur(s); + AddSeqUI(s); } + + void AddSeqUI (Sequenceur s) + { + seqUiVbox.Add(s.GetUI()); + seqUiVbox.ShowAll(); + } + } } \ No newline at end of file diff --git a/DMX-2.0/SelSeqCircuits.cs b/DMX-2.0/SelSeqCircuits.cs new file mode 100644 index 0000000..f86fb5d --- /dev/null +++ b/DMX-2.0/SelSeqCircuits.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; + +namespace DMX2 +{ + public partial class SelSeqCircuits : Gtk.Dialog + { + + Gtk.ListStore lsAll=null; + Gtk.ListStore lsSel=null; + + List cursel; + + public List GetResultList () + { + return cursel; + } + + public SelSeqCircuits (IEnumerable selection ) + { + this.Build (); + + cursel = new List(selection); + + var allnameCol = new Gtk.TreeViewColumn(); + var allNameCell = new Gtk.CellRendererText(); + allnameCol.Title = "Circuits"; + allnameCol.PackStart(allNameCell,true); + allnameCol.SetCellDataFunc(allNameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); + this.listeToutCircuits.AppendColumn(allnameCol); + + lsAll = new Gtk.ListStore(typeof (Circuit)); + this.listeToutCircuits.Model = lsAll; + foreach(var c in Conduite.Courante.Circuits) + lsAll.AppendValues(c); + listeToutCircuits.Selection.Mode = Gtk.SelectionMode.Multiple; + + var selNameCol = new Gtk.TreeViewColumn(); + var selNameCell = new Gtk.CellRendererText(); + selNameCol.Title = "Circuits du Sequenceur"; + selNameCol.PackStart(selNameCell,true); + selNameCol.SetCellDataFunc(selNameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); + this.listeSelCircuits.AppendColumn(selNameCol); + + lsSel = new Gtk.ListStore(typeof (Circuit)); + this.listeSelCircuits.Model = lsSel; + foreach(var c in cursel) + lsSel.AppendValues(c); + listeSelCircuits.Selection.Mode = Gtk.SelectionMode.Multiple; + } + + void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { + Circuit c = tree_model.GetValue (iter, 0) as Circuit; + (cell as Gtk.CellRendererText).Text = c.Name; + } + + void UpdateCurSel () + { + lsSel.Clear (); + foreach(var c in cursel) + lsSel.AppendValues(c); + } + + protected List GetSelection(Gtk.TreeView liste, Gtk.ListStore ls ) + { + Gtk.TreeIter iter; List selection = new List(); + foreach(var row in liste.Selection.GetSelectedRows()) + { + ls.GetIter (out iter, row); + selection.Add( ls.GetValue(iter,0) as Circuit); + } + return selection; + } + + protected void OnAjtButClicked (object sender, EventArgs e) + { + foreach (var c in GetSelection(listeToutCircuits,lsAll)) { + if(!cursel.Contains(c)) + cursel.Add(c); + + } + UpdateCurSel(); + } + + protected void OnSupBtClicked (object sender, EventArgs e) + { + foreach (var c in GetSelection(listeSelCircuits,lsSel)) { + cursel.Remove(c); + } + UpdateCurSel(); + } + + + protected void OnSupToutButClicked (object sender, EventArgs e) + { + cursel.Clear(); + UpdateCurSel(); + } + + protected void OnMvHautBtClicked (object sender, EventArgs e) + { + + List selrow = GetSelection(listeSelCircuits,lsSel); + foreach (var c in selrow) { + int idx = cursel.IndexOf(c); + if(idx>0) + { + if(!selrow.Contains(cursel[idx-1])) + { + cursel.Remove(c); + cursel.Insert(idx-1,c); + } + } + } + lsSel.Clear(); + foreach (var item in cursel) { + var iter = lsSel.AppendValues (item); + if(selrow.Contains(item)) + listeSelCircuits.Selection.SelectIter(iter); + } + } + + protected void OnMvBasBtClicked (object sender, EventArgs e) + { + List selrow = GetSelection(listeSelCircuits,lsSel); + selrow.Reverse(); + foreach (var c in selrow) { + int idx = cursel.IndexOf(c); + if(idx circuitsSeq = new List(); + + public ReadOnlyCollection Circuits { + get { + return circuitsSeq.AsReadOnly(); + } + } + + public void ChangeCircuits (System.Collections.Generic.List list) + { + foreach (var c in circuitsSeq) { + if(!list.Contains(c)) + RetireCircuit(c); + } + foreach(var c in list) + if(!circuitsSeq.Contains(c)) + AjouteCircuit(c); + circuitsSeq = list; + } + + void AjouteCircuit (Circuit c) + { + valeurscourantes[c]=0; + valeursinitiales[c]=0; + } + + private void RetireCircuit(Circuit c) + { + foreach (var ef in effets) { + ef.RetireCircuit(c); + } + circuitsSeq.Remove(c); + valeurscourantes.Remove(c); + valeursinitiales.Remove(c); + } + + public override void MajCircuitsSupprimes () + { + foreach (var c in circuitsSeq.ToArray()) { + if(!Conduite.Courante.Circuits.Contains(c)) + RetireCircuit(c); + } + } + List effets = new List(); public ReadOnlyCollection Effets { @@ -135,11 +178,23 @@ namespace DMX2 throw new System.NotImplementedException (); } - + SeqLinUI ui=null; public override SequenceurUI GetUI () { - throw new System.NotImplementedException (); + + if (ui == null) { + ui = new SeqLinUI (this); + ui.Destroyed += UiDestroyed;; + } + + return ui; } + void UiDestroyed (object sender, EventArgs e) + { + ui=null; + } + + } } diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index 9952612..d94cb6f 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -189,7 +189,7 @@ None - + 6 @@ -448,7 +448,7 @@ - + Action @@ -500,6 +500,18 @@ gtk-go-down + + Action + + circuits + + + + Action + + gtk-close + + 270 @@ -526,16 +538,61 @@ 121 - 6 + 2 - + - 37 - label2 + False + + + + 45 + True + True + + + + 4 + + + + + + 45 + True + True + + + + 58 + + + + + + <small>Duree</small> + True + + + 9 + 28 + + + + + + <small>Transition</small> + True + + + 55 + 28 + + 0 - False + True False False @@ -575,7 +632,20 @@ - 6 + + + + 33 + <big>0.00</big> + True + + + 0 + True + False + False + + @@ -590,7 +660,7 @@ - 0 + 1 True False False @@ -609,7 +679,7 @@ - 1 + 2 True False False @@ -649,6 +719,8 @@ Icons SmallToolbar + + @@ -669,13 +741,84 @@ - + + 250 False + + + + 25 + 150 + True + True + 100 + 10 + 1 + 51 + True + 0 + Top + + + 15 + + + + + + 25 + 150 + True + True + 100 + 10 + 1 + 28 + True + 0 + Top + + + 45 + + + + + + 50 + 66 + 1 + 0 + <small>Ras. Rouge</small> + True + 65 + + + -20 + 150 + + + + + + 50 + 66 + 1 + 0 + <small>Face J</small> + True + 65 + + + 10 + 150 + + 1 - False + True @@ -695,4 +838,216 @@ + + + False + Selection des Circuits + Dialog + CenterOnParent + True + True + Static + 2 + False + + + + 2 + + + + 6 + + + + In + + + + True + True + + + + + 0 + True + + + + + + 6 + Start + + + + True + TextAndIcon + stock:gtk-go-forward Menu + Ajouter + True + + + + False + False + + + + + + True + TextAndIcon + stock:gtk-go-back Menu + Enlever + True + + + + 1 + False + False + + + + + + True + TextAndIcon + stock:gtk-go-back Menu + Tout Enlever + True + + + + 2 + False + False + + + + + + False + True + TextOnly + + True + None + + + 3 + False + False + + + + + + True + TextAndIcon + stock:gtk-go-up Menu + Monter + True + + + + 4 + False + False + + + + + + True + TextAndIcon + stock:gtk-go-down Menu + Descendre + True + + + + 5 + False + False + + + + + 1 + True + False + False + + + + + + In + + + + True + True + + + + + 2 + True + + + + + 0 + True + + + + + + + + 10 + 5 + 2 + End + + + + True + True + True + StockItem + gtk-cancel + -6 + gtk-cancel + + + False + False + + + + + + True + True + True + StockItem + gtk-ok + -5 + gtk-ok + + + 1 + False + False + + + + + \ No newline at end of file