diff --git a/DMX-2.0.userprefs b/DMX-2.0.userprefs index 130e36c..3d2249f 100644 --- a/DMX-2.0.userprefs +++ b/DMX-2.0.userprefs @@ -1,13 +1,12 @@  - + - - - - - - + + + + + diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index be7828b..1da7e08 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -106,28 +106,29 @@ namespace DMX2 void Tick () { DateTime tickTime = DateTime.Now; - TimeSpan ts = tickTime-lastTick; + TimeSpan ts = tickTime - lastTick; lastTick = tickTime; - // 'Actionne' les sequenceurs - foreach (var seq in sequenceurs) { - seq.Tick(ts); - } - - // Mets a jour les valeurs circuits. - foreach (var c in circuits) { - int val=0; - foreach (var seq in Sequenceurs) { - val = Math.Max(val, seq.ValeurCircuit(c)); + lock (this) { + // 'Actionne' les sequenceurs + foreach (var seq in sequenceurs) { + seq.Tick (ts); } - c.ValeurCourante=val; - } + // Mets a jour les valeurs circuits. + foreach (var c in circuits) { + int val = 0; + foreach (var seq in Sequenceurs) { + val = Math.Max (val, seq.ValeurCircuit (c)); + } + c.ValeurCourante = val; + } + } // Cette fonction retourne quasi immédiatement, même si il y'a beaucoup a faire sur l'affichage MainWindow.Win.ScheduleUpdate(); - /*if( DateTime.Now - tickTime > TimeSpan.FromMilliseconds(1) ) + /*if( ts > TimeSpan.FromMilliseconds(12) ) Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,ts);*/ } diff --git a/DMX-2.0/GestionCircuits.cs b/DMX-2.0/GestionCircuits.cs index 1332aaa..b57a139 100644 --- a/DMX-2.0/GestionCircuits.cs +++ b/DMX-2.0/GestionCircuits.cs @@ -16,7 +16,7 @@ namespace DMX2 var nameCell = new Gtk.CellRendererText(); nameCol.Title = "Circuit"; nameCol.PackStart(nameCell,true); - nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); + nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( RenderCircuitName) ); nameCell.Editable =true; nameCell.Edited += OnNameCellEdited; this.listeCircuits.AppendColumn(nameCol); @@ -25,7 +25,7 @@ namespace DMX2 var snameCell = new Gtk.CellRendererText(); snameCol.Title = "Nom Court"; snameCol.PackStart(snameCell,true); - snameCol.SetCellDataFunc(snameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitShortName) )); + snameCol.SetCellDataFunc(snameCell, new Gtk.TreeCellDataFunc(RenderCircuitShortName) ); snameCell.Editable =true; snameCell.Edited += OnShortNameCellEdited; this.listeCircuits.AppendColumn(snameCol); diff --git a/DMX-2.0/SelSeqCircuits.cs b/DMX-2.0/SelSeqCircuits.cs index f86fb5d..202ab0f 100644 --- a/DMX-2.0/SelSeqCircuits.cs +++ b/DMX-2.0/SelSeqCircuits.cs @@ -26,7 +26,7 @@ namespace DMX2 var allNameCell = new Gtk.CellRendererText(); allnameCol.Title = "Circuits"; allnameCol.PackStart(allNameCell,true); - allnameCol.SetCellDataFunc(allNameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); + allnameCol.SetCellDataFunc(allNameCell, new Gtk.TreeCellDataFunc( RenderCircuitName) ); this.listeToutCircuits.AppendColumn(allnameCol); lsAll = new Gtk.ListStore(typeof (Circuit)); @@ -39,7 +39,7 @@ namespace DMX2 var selNameCell = new Gtk.CellRendererText(); selNameCol.Title = "Circuits du Sequenceur"; selNameCol.PackStart(selNameCell,true); - selNameCol.SetCellDataFunc(selNameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); + selNameCol.SetCellDataFunc(selNameCell, new Gtk.TreeCellDataFunc( RenderCircuitName) ); this.listeSelCircuits.AppendColumn(selNameCol); lsSel = new Gtk.ListStore(typeof (Circuit)); @@ -49,7 +49,7 @@ namespace DMX2 listeSelCircuits.Selection.Mode = Gtk.SelectionMode.Multiple; } - void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { + 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; } diff --git a/DMX-2.0/SeqLinUI.cs b/DMX-2.0/SeqLinUI.cs index 7184c78..93b87aa 100644 --- a/DMX-2.0/SeqLinUI.cs +++ b/DMX-2.0/SeqLinUI.cs @@ -10,6 +10,7 @@ namespace DMX2 bool fullUpdFlag = true; SequenceurLineaire sequenceur; + ListStore lsEffets=null; public SeqLinUI (SequenceurLineaire s ) : base (s) { @@ -17,20 +18,91 @@ namespace DMX2 titreLabel.Text = s.Name; sequenceur = s; Update(true); + +#region Construction listeEffets + // Construction de la liste d'effets + var numCol = new TreeViewColumn(); + var nomCol = new TreeViewColumn(); + var dureeCol = new TreeViewColumn(); + var transCol = new TreeViewColumn(); + + var numCell = new CellRendererText(); + var nomCell = new CellRendererText(); + var dureeCell = new CellRendererText(); + var transCell = new CellRendererText(); + + numCol.Title = "N°"; + nomCol.Title = "Effet"; + dureeCol.Title = "Duree"; + transCol.Title = "Transition"; + + numCol.PackEnd(numCell,true); + nomCol.PackStart(nomCell,true); + dureeCol.PackEnd(dureeCell,true); + transCol.PackEnd(transCell,true); + + numCol.SetCellDataFunc(numCell, new TreeCellDataFunc(RenderNum)); + nomCol.SetCellDataFunc(nomCell, new TreeCellDataFunc(RenderNom)); + dureeCol.SetCellDataFunc(dureeCell, new TreeCellDataFunc(RenderDuree)); + transCol.SetCellDataFunc(transCell, new TreeCellDataFunc(RenderTrans)); + + effetsListe.AppendColumn(numCol); + effetsListe.AppendColumn(nomCol); + effetsListe.AppendColumn(dureeCol); + effetsListe.AppendColumn(transCol); + + lsEffets = new ListStore(typeof(SequenceurLineaire.Effet)); + effetsListe.Model = lsEffets; +#endregion } +#region Affichage Liste d'Effets + void RenderNum (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) + { + SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet; + (cell as Gtk.CellRendererText).Text = ""; + } + + void RenderNom (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) + { + SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet; + (cell as Gtk.CellRendererText).Text = e.Nom; + } + + void RenderDuree (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) + { + SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet; + (cell as Gtk.CellRendererText).Text = (e.Duree.TotalMilliseconds/100).ToString(); + } + + void RenderTrans (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) + { + SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet; + (cell as Gtk.CellRendererText).Text = (e.Transition.TotalMilliseconds/100).ToString(); + } + + void UpdListeEffets () + { + lsEffets.Clear(); + foreach (var effet in sequenceur.Effets) { + lsEffets.AppendValues(effet); + } + } +#endregion + public override void Update (bool full) { if(fullUpdFlag || full) FullUpdate(); UpdateValues(); - timeLabel.LabelProp = sequenceur.TimeStamp.ToString(); + timeLabel.LabelProp = string.Format(@"{0:0\.0}", sequenceur.TimeStamp.TotalMilliseconds/100); + } protected void OnCircuitsActionActivated (object sender, EventArgs e) { var dlg = new SelSeqCircuits (sequenceur.Circuits); if ((ResponseType)dlg.Run () == ResponseType.Ok) { - sequenceur.ChangeCircuits(dlg.GetResultList()); + sequenceur.ChangeCircuits(dlg.GetResultList()); } dlg.Destroy(); fullUpdFlag = true; @@ -120,8 +192,10 @@ namespace DMX2 fullUpdFlag=false; } + bool updating=false; void TiretteActionee (object sender, EventArgs e) { + if (updating)return; VScale t = sender as VScale; Circuit c = t.Data[circuitKey] as Circuit; sequenceur.ChangeValeur(c,(int)(t.Value)); @@ -129,9 +203,11 @@ namespace DMX2 protected void UpdateValues() { + updating = true; foreach (Circuit c in tirettes.Keys) { tirettes[c].Value = sequenceur.ValeurCircuit(c); } + updating=false; } protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args) @@ -140,9 +216,23 @@ namespace DMX2 if(lastKnownWidth != args.Allocation.Width) FullUpdate (); } + } + + + protected void OnSaveActionActivated (object sender, EventArgs e) + { + int d,t; + if(!int.TryParse(dureeEntry.Text,out d) || !int.TryParse(transEntry.Text,out t)) return; + sequenceur.SauveEffet("Nom", TimeSpan.FromMilliseconds(100*d),TimeSpan.FromMilliseconds(t*100)); + UpdListeEffets(); } + protected void OnGoForwardActionActivated (object sender, EventArgs e) + { + sequenceur.IndexEffetCourrant++; + } + } } diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index 670fded..bd7c093 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -98,14 +98,16 @@ namespace DMX2 public void ChangeCircuits (System.Collections.Generic.List list) { - foreach (var c in circuitsSeq.ToArray()) { - if (!list.Contains (c)) - RetireCircuit (c); + lock (this) { + foreach (var c in circuitsSeq.ToArray()) { + if (!list.Contains (c)) + RetireCircuit (c); + } + foreach (var c in list) + if (!circuitsSeq.Contains (c)) + AjouteCircuit (c); + circuitsSeq = list; } - foreach (var c in list) - if (!circuitsSeq.Contains (c)) - AjouteCircuit (c); - circuitsSeq = list; } void AjouteCircuit (Circuit c) @@ -126,9 +128,11 @@ namespace DMX2 public override void MajCircuitsSupprimes () { - foreach (var c in circuitsSeq.ToArray()) { - if (!Conduite.Courante.Circuits.Contains (c)) - RetireCircuit (c); + lock (this) { + foreach (var c in circuitsSeq.ToArray()) { + if (!Conduite.Courante.Circuits.Contains (c)) + RetireCircuit (c); + } } } @@ -153,11 +157,13 @@ namespace DMX2 public override void Tick (TimeSpan time) { timeStamp += time; + if (enTransition) { if (timeStamp < effetcourrant.Transition) { + double progression = timeStamp.TotalMilliseconds / effetcourrant.Transition.TotalMilliseconds; foreach (Circuit c in circuitsSeq) { if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) { - valeurscourantes [c] = (effetcourrant [c] - valeursinitiales [c]) * effetcourrant.Duree.Milliseconds / time.Milliseconds + valeursinitiales [c]; + valeurscourantes [c] = (int)(progression * (effetcourrant [c] - valeursinitiales [c]) + valeursinitiales [c]); } } } else { @@ -167,7 +173,7 @@ namespace DMX2 if (effetcourrant.Duree != TimeSpan.Zero && timeStamp >= effetcourrant.Duree) { int index = effets.IndexOf (effetcourrant) + 1; if (index < effets.Count) - ChangeEffet (index); + ChangeEffetCourrant (index); } } @@ -178,7 +184,17 @@ namespace DMX2 valeurscourantes [c] = effetcourrant [c]; } - public void ChangeEffet (int index) + public int IndexEffetCourrant { + get { + return effets.IndexOf(effetcourrant); + } + set { + if(value>=0 && value < effets.Count) + ChangeEffetCourrant(value); + } + } + + void ChangeEffetCourrant (int index) { effetcourrant = effets [index]; valeurschangees.Clear (); @@ -189,9 +205,13 @@ namespace DMX2 public void SauveEffet (string nom, TimeSpan duree, TimeSpan transition) { - effets.Add (new Effet (nom, valeurscourantes, duree, transition)); + lock (this) { + effets.Add (new Effet (nom, valeurscourantes, duree, transition)); + } } + + public override System.Xml.XmlElement Save () { throw new System.NotImplementedException (); @@ -213,7 +233,5 @@ namespace DMX2 { ui = null; } - - } } diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index 0078bfe..2a30491 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -447,7 +447,7 @@ - + Action @@ -458,6 +458,7 @@ Action gtk-go-forward + Action @@ -478,6 +479,7 @@ Action gtk-save + Action @@ -541,7 +543,7 @@ False - + 45 True @@ -553,7 +555,7 @@ - + 45 True @@ -696,7 +698,7 @@ Never In - + True True