diff --git a/DMX-2.0.userprefs b/DMX-2.0.userprefs index 1a22cd2..1060ad9 100644 --- a/DMX-2.0.userprefs +++ b/DMX-2.0.userprefs @@ -1,11 +1,11 @@  - + - + - + diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index ea10a40..4ff1739 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Collections.ObjectModel; +using System.Threading; namespace DMX2 @@ -10,10 +11,13 @@ namespace DMX2 { public static Conduite Courante = null; - + + Timer timer = null; + public Conduite() { - + timer = new Timer(new TimerCallback(TimerTick),this, + 100,100); } List circuits = new List(); @@ -87,7 +91,26 @@ namespace DMX2 public void Dispose() { disposed=true; - // stop thread if running + if(timer!=null) + timer.Dispose(); + timer=null; + } + + static public void TimerTick (object state) + { + Conduite.Courante.Tick(); + } + + void Tick () + { + foreach (var c in Circuits) { + int val=0; + foreach (var seq in Sequenceurs) { + val = Math.Max(val, seq.ValeurCircuit(c)); + } + c.ValeurCourante=val; + } + MainWindow.Win.ScheduleUpdate(); } #region IDisposable implementation diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index 41d2418..e5607a7 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -7,8 +7,14 @@ namespace DMX2 { public partial class MainWindow: Gtk.Window { + static MainWindow win; + public static MainWindow Win { + get { return win; } + } + public MainWindow (): base (Gtk.WindowType.Toplevel) { + win=this; Build (); MajWidgets(); } @@ -26,6 +32,7 @@ namespace DMX2 } } + protected void MajCircuits () { // Ajoute une ProgressBar par circuit, met a jour le texte si necessaire @@ -99,5 +106,22 @@ namespace DMX2 seqUiVbox.ShowAll(); } + + bool updScheduled=false; + public void ScheduleUpdate () + { + if(updScheduled) return; + updScheduled=true; + Gtk.Application.Invoke(new EventHandler(Update)); + } + + void Update (object sender, EventArgs e) + { + foreach (var sequi in seqUiVbox.Children) { + (sequi as SequenceurUI).Update(); + } + MajCircuits(); + updScheduled=false; + } } } \ No newline at end of file diff --git a/DMX-2.0/SeqLinUI.cs b/DMX-2.0/SeqLinUI.cs index 9cbf747..e425fc7 100644 --- a/DMX-2.0/SeqLinUI.cs +++ b/DMX-2.0/SeqLinUI.cs @@ -113,7 +113,8 @@ namespace DMX2 xpos+=30; if(lastKnownWidth < xpos +30) { - xpos =10; ypos+= 215; + xpos = 10; + ypos += 215; } } @@ -124,12 +125,14 @@ namespace DMX2 { VScale t = sender as VScale; Circuit c = t.Data[circuitKey] as Circuit; - + sequenceur.ChangeValeur(c,(int)(t.Value)); } protected void UpdateValues() { - + foreach (Circuit c in tirettes.Keys) { + tirettes[c].Value = sequenceur.ValeurCircuit(c); + } } protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args) diff --git a/DMX-2.0/Sequenceur.cs b/DMX-2.0/Sequenceur.cs index 788854c..435861c 100644 --- a/DMX-2.0/Sequenceur.cs +++ b/DMX-2.0/Sequenceur.cs @@ -43,7 +43,7 @@ namespace DMX2 public abstract SequenceurUI GetUI(); - public abstract int EtatCircuit(Circuit c); + public abstract int ValeurCircuit(Circuit c); public abstract void Tick(TimeSpan time); public static Sequenceur Load(XmlElement el) { diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index 215af01..c684665 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -131,14 +131,14 @@ namespace DMX2 } } - public override int EtatCircuit (Circuit c) + public override int ValeurCircuit (Circuit c) { if (!circuitsSeq.Contains (c)) return 0; return valeurscourantes [c]; } - public void ChangeCircuit (Circuit c, int value) + public void ChangeValeur (Circuit c, int value) { valeurschangees [c] = true; valeurscourantes [c] = value;