From 92691d2bfae527bab40cf0a9e288dcfac086589d Mon Sep 17 00:00:00 2001 From: tzim Date: Mon, 22 Apr 2013 16:28:03 +0000 Subject: [PATCH] --- DMX-2.0/Conduite.cs | 23 +++--- DMX-2.0/SeqLinUI.cs | 70 ++++++++++++++-- DMX-2.0/SequenceurLineaire.cs | 45 +++++++++- DMX-2.0/gtk-gui/gui.stetic | 151 +++++++++++++++++++++++++++++++--- 4 files changed, 258 insertions(+), 31 deletions(-) diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index 35caf96..bd12192 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -13,14 +13,13 @@ namespace DMX2 public static Conduite Courante = null; Timer timer = null; - DateTime lastTick; - DateTime lastUpd; + DateTime dernierTick; + DateTime derniereMaj; public Conduite() { - timer = new Timer(new TimerCallback(TimerTick),this, - 10,10); - lastUpd = lastTick=DateTime.Now; + timer = new Timer(new TimerCallback(TimerTick),this, 1000,10); + derniereMaj = dernierTick=DateTime.Now; } List circuits = new List(); @@ -107,13 +106,13 @@ namespace DMX2 void Tick () { DateTime tickTime = DateTime.Now; - TimeSpan ts = tickTime - lastTick; - lastTick = tickTime; + TimeSpan deltaT = tickTime - dernierTick; + dernierTick = tickTime; lock (this) { // 'Actionne' les sequenceurs foreach (var seq in sequenceurs) { - seq.Tick (ts); + seq.Tick (deltaT); } // Mets a jour les valeurs circuits. @@ -127,14 +126,14 @@ namespace DMX2 } // Cette fonction retourne quasi immédiatement, même si il y'a beaucoup a faire sur l'affichage - if(tickTime - lastUpd > TimeSpan.FromMilliseconds(100)){ + if(tickTime - derniereMaj > TimeSpan.FromMilliseconds(50)){ MainWindow.Win.ScheduleUpdate(); - lastUpd = DateTime.Now; + derniereMaj = DateTime.Now; } - if( ts > TimeSpan.FromMilliseconds(15) ) - Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,ts); + if( deltaT > TimeSpan.FromMilliseconds(15) ) + Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,deltaT); } #region IDisposable implementation diff --git a/DMX-2.0/SeqLinUI.cs b/DMX-2.0/SeqLinUI.cs index 1ba114d..c5a5177 100644 --- a/DMX-2.0/SeqLinUI.cs +++ b/DMX-2.0/SeqLinUI.cs @@ -13,6 +13,12 @@ namespace DMX2 ListStore lsEffets=null; TreeViewColumn nomCol; + bool effetChange = false; + public void EffetChange () + { + effetChange = true; + } + public SeqLinUI (SequenceurLineaire s ) : base (s) { this.Build (); @@ -149,6 +155,15 @@ namespace DMX2 else pbTrans.Fraction = 0.0d; + if (effetChange) + SelectionneEffet(sequenceur.IndexEffetCourrant); + } + + void SelectionneEffet (int index) + { + if(index <0 ) return; + effetsListe.SetCursor( new TreePath( new int[1] {index }) ,null,false); + effetChange = false; } protected void OnCircuitsActionActivated (object sender, EventArgs e) @@ -271,21 +286,28 @@ namespace DMX2 } } + int IndexEffetSelectionne() + { + var sel = effetsListe.Selection.GetSelectedRows(); + if(sel.Length ==0) return -1; + return effetsListe.Selection.GetSelectedRows()[0].Indices[0]; + } protected void OnSaveActionActivated (object sender, EventArgs e) { - //int d,t; if(!int.TryParse(dureeEntry.Text,out d) || !int.TryParse(transEntry.Text,out t)) return; - TreeIter iter; int pos = sequenceur.SauveEffet("Nouvel Effet", TimeSpan.Zero,TimeSpan.FromSeconds(5)); UpdListeEffets(); - lsEffets.IterNthChild(out iter, pos); - effetsListe.SetCursor(lsEffets.GetPath(iter),nomCol,true); + effetsListe.SetCursor(new TreePath( new int[1] {pos}) ,nomCol,true); } protected void OnGoForwardActionActivated (object sender, EventArgs e) { - sequenceur.IndexEffetCourrant++; + if(sequenceur.IndexEffetCourrant == IndexEffetSelectionne()) + sequenceur.IndexEffetCourrant++; + else + sequenceur.IndexEffetCourrant = IndexEffetSelectionne(); + } protected void OnGoBackActionActivated (object sender, EventArgs e) @@ -303,6 +325,44 @@ namespace DMX2 sequenceur.FinDeTransition(); } + protected void OnApplyActionActivated (object sender, EventArgs e) + { + int pos = IndexEffetSelectionne(); + sequenceur.RemplaceEffet(pos); + UpdListeEffets(); + effetsListe.SetCursor(new TreePath( new int[1] {pos}) ,null,false); + } + + protected void OnSaveAfterActionActivated (object sender, EventArgs e) + { + int pos = sequenceur.InsereEffetApres(IndexEffetSelectionne(),"Nouvel Effet",TimeSpan.Zero,TimeSpan.FromSeconds(5)); + UpdListeEffets(); + effetsListe.SetCursor(new TreePath( new int[1] {pos}) ,nomCol,true); + } + + protected void OnDeleteActionActivated (object sender, EventArgs e) + { + sequenceur.SupprimeEffet(IndexEffetSelectionne()); + UpdListeEffets(); + } + + protected void OnMoveUpActionActivated (object sender, EventArgs e) + { + int pos = IndexEffetSelectionne(); + if(pos==-1) return; + pos = sequenceur.MonteEffet(pos); + UpdListeEffets(); + effetsListe.SetCursor(new TreePath( new int[1] {pos}) ,null,false); + } + + protected void OnMoveDownActionActivated (object sender, EventArgs e) + { + int pos = IndexEffetSelectionne(); + if(pos==-1) return; + pos = sequenceur.BaisseEffet(pos); + UpdListeEffets(); + effetsListe.SetCursor(new TreePath( new int[1] {pos}) ,null,false); + } } } diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index e8e6664..1ceecb7 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -232,16 +232,59 @@ namespace DMX2 valeursinitiales = new Dictionary (valeurscourantes); enTransition = true; timeStamp = TimeSpan.Zero; + if(ui!=null) ui.EffetChange(); } public int SauveEffet (string nom, TimeSpan duree, TimeSpan transition) { lock (this) { - effets.Add (new Effet (nom, valeurscourantes, duree, transition)); + effets.Add (effetcourrant = new Effet (nom, valeurscourantes, duree, transition)); return effets.Count-1; } } + public int InsereEffetApres (int index, string nom, TimeSpan duree, TimeSpan transition) + { + lock (this) { + int pos = index+1; + if (pos >= effets.Count) return SauveEffet(nom,duree,transition); + effets.Insert (pos,effetcourrant = new Effet (nom, valeurscourantes, duree, transition)); + return pos; + } + } + + public void RemplaceEffet (int index) + { + lock (this) { + Effet ef = effets[index]; + effets[index] = new Effet (ef.Nom, valeurscourantes, ef.Duree, ef.Transition); + effetcourrant = effets[index]; + } + } + + public void SupprimeEffet (int index) + { + effets.RemoveAt(index); + } + + public int MonteEffet (int index) + { + if(index>= effets.Count || index < 1 ) return index; + Effet ef = effets[index]; + effets.RemoveAt(index); + effets.Insert(index-1, ef); + return index -1; + } + + public int BaisseEffet (int index) + { + if(index> effets.Count-2 || index <0) return index; + Effet ef = effets[index]; + effets.RemoveAt(index); + effets.Insert(index+1, ef); + return index +1; + } + public override System.Xml.XmlElement Save () { throw new System.NotImplementedException (); diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index cbff1da..e4c7324 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -132,6 +132,21 @@ tirettes + + Action + + gtk-fullscreen + + + Action + + gtk-fullscreen + + + Action + ShowAll + ShowAll + MainWindow @@ -146,14 +161,113 @@ 6 - + - 50 - False + 6 + + + + True + TextAndIcon + stock:gtk-goto-last Dnd + + True + + + 0 + True + False + False + + + + + + True + TextAndIcon + stock:gtk-goto-first Dnd + + True + + + 1 + True + False + False + + + + + + True + TextAndIcon + stock:gtk-no Dnd + + True + + + 2 + True + False + False + + + + + + True + TextAndIcon + stock:gtk-media-pause Dnd + + True + + + 3 + True + False + False + + + + + + True + TextAndIcon + stock:gtk-justify-fill Dnd + + True + + + 4 + True + False + False + + + + + + 260 + True + 100 + 10 + 1 + 100 + True + 0 + Top + + + 5 + False + False + False + + 0 - False + True False False @@ -173,12 +287,12 @@ True - 753 + 727 True - 583 + 561 @@ -293,6 +407,9 @@ + + + @@ -465,6 +582,8 @@ Action gtk-apply + Ecrase l'effet selectionné. + Action @@ -482,28 +601,34 @@ Action gtk-save - Enregistre + Enregistre l'effet à la fin. - + Action gtk-save-as + Insère un effet sous celui selectionné. + Action gtk-delete + Supprime l'effet selectionné. + - + Action gtk-go-up + - + Action gtk-go-down + Action @@ -605,7 +730,7 @@ SmallToolbar - + @@ -653,8 +778,8 @@ - - + +