diff --git a/DMX-2.0.userprefs b/DMX-2.0.userprefs index f8e724d..1a22cd2 100644 --- a/DMX-2.0.userprefs +++ b/DMX-2.0.userprefs @@ -1,20 +1,12 @@  - + - - - + + + + - - - - - - - - - diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index e4dc8c0..215af01 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -6,25 +6,19 @@ namespace DMX2 { public class SequenceurLineaire : Sequenceur { - - TimeSpan timeStamp = TimeSpan.Zero; - - public TimeSpan TimeStamp { - get { - return timeStamp; - } - } - - public class Effet { + public class Effet + { string _nom; - public Effet(string nom, Dictionary valeurs, TimeSpan duree, TimeSpan transition) + + public Effet (string nom, Dictionary valeurs, TimeSpan duree, TimeSpan transition) { - _nom=nom; - _valeurs = new Dictionary(valeurs); - _duree=duree; - _transition=transition; + _nom = nom; + _valeurs = new Dictionary (valeurs); + _duree = duree; + _transition = transition; } + public string Nom { get { return _nom; @@ -32,23 +26,29 @@ namespace DMX2 } Dictionary _valeurs; + public int this [Circuit index] { get { - if(!_valeurs.ContainsKey(index)) - _valeurs.Add(index,0); - return _valeurs[index]; + if (!_valeurs.ContainsKey (index)) + _valeurs.Add (index, 0); + return _valeurs [index]; } } - public void RetireCircuit(Circuit c){ - _valeurs.Remove(c); + + public void RetireCircuit (Circuit c) + { + _valeurs.Remove (c); } - TimeSpan _duree =TimeSpan.Zero ; + + TimeSpan _duree = TimeSpan.Zero ; TimeSpan _transition = TimeSpan.Zero; + public TimeSpan Duree { get { return _duree; } - } + } + public TimeSpan Transition { get { return _transition; @@ -58,64 +58,15 @@ namespace DMX2 } - List circuitsSeq = new List(); - - public ReadOnlyCollection Circuits { - get { - return circuitsSeq.AsReadOnly(); - } - } - - public void ChangeCircuits (System.Collections.Generic.List list) - { - 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; - } - - 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 { - get { - return effets.AsReadOnly() ; - } - } - Effet effetcourrant=null; - - bool enTransition=false; - - Dictionary valeurscourantes = new Dictionary(); - Dictionary valeursinitiales = new Dictionary(); - Dictionary valeurschangees = new Dictionary(); + TimeSpan timeStamp = TimeSpan.Zero; + List circuitsSeq = new List (); + List effets = new List (); + Effet effetcourrant = null; + bool enTransition = false; + Dictionary valeurscourantes = new Dictionary (); + Dictionary valeursinitiales = new Dictionary (); + Dictionary valeurschangees = new Dictionary (); + SeqLinUI ui = null; public SequenceurLineaire () { @@ -126,22 +77,76 @@ namespace DMX2 } + public TimeSpan TimeStamp { + get { + return timeStamp; + } + } + + public ReadOnlyCollection Circuits { + get { + return circuitsSeq.AsReadOnly (); + } + } + + public ReadOnlyCollection Effets { + get { + return effets.AsReadOnly (); + } + } + + public void ChangeCircuits (System.Collections.Generic.List list) + { + 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; + } + + 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); + } + } + public override int EtatCircuit (Circuit c) { if (!circuitsSeq.Contains (c)) return 0; - return valeurscourantes[c]; + return valeurscourantes [c]; } public void ChangeCircuit (Circuit c, int value) { - valeurschangees[c]=true; - valeurscourantes[c]= value; + valeurschangees [c] = true; + valeurscourantes [c] = value; } public bool EstChange (Circuit c) { - return valeurschangees.ContainsKey(c); + return valeurschangees.ContainsKey (c); } public override void Tick (TimeSpan time) @@ -150,7 +155,7 @@ namespace DMX2 if (enTransition) { if (timeStamp < effetcourrant.Transition) { foreach (Circuit c in circuitsSeq) { - if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey(c)) { + if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) { valeurscourantes [c] = (effetcourrant [c] - valeursinitiales [c]) * effetcourrant.Duree.Milliseconds / time.Milliseconds + valeursinitiales [c]; } } @@ -159,45 +164,45 @@ namespace DMX2 } } if (timeStamp >= effetcourrant.Duree) { - int index = effets.IndexOf(effetcourrant) +1; - if (index < effets.Count) ChangeEffet(index); + int index = effets.IndexOf (effetcourrant) + 1; + if (index < effets.Count) + ChangeEffet (index); } } void FinDeTransition () { enTransition = false; - foreach( Circuit c in circuitsSeq) - valeurscourantes[c]=effetcourrant[c]; + foreach (Circuit c in circuitsSeq) + valeurscourantes [c] = effetcourrant [c]; } - - public void ChangeEffet(int index) + public void ChangeEffet (int index) { - effetcourrant = effets[index]; - valeurschangees.Clear(); - valeursinitiales = new Dictionary(valeurscourantes); + effetcourrant = effets [index]; + valeurschangees.Clear (); + valeursinitiales = new Dictionary (valeurscourantes); enTransition = true; timeStamp = TimeSpan.Zero; } public void SauveEffet (string nom, TimeSpan duree, TimeSpan transition) { - effets.Add(new Effet(nom, valeurscourantes,duree,transition)); + effets.Add (new Effet (nom, valeurscourantes, duree, transition)); } public override System.Xml.XmlElement Save () { throw new System.NotImplementedException (); - } + } + - SeqLinUI ui=null; public override SequenceurUI GetUI () { if (ui == null) { ui = new SeqLinUI (this); - ui.Destroyed += UiDestroyed;; + ui.Destroyed += UiDestroyed; } return ui; @@ -205,7 +210,7 @@ namespace DMX2 void UiDestroyed (object sender, EventArgs e) { - ui=null; + ui = null; }