From a7d6aa210fac43f62b1ae6eef41f67bc8bc3963d Mon Sep 17 00:00:00 2001 From: tzim Date: Sat, 12 Oct 2013 20:09:32 +0000 Subject: [PATCH] Ajout et prise en compte des commandes dans le sequenceur maitre --- DMX-2.0/AssemblyInfo.cs | 4 +-- DMX-2.0/MainWindow.cs | 57 +++++++++++++++++++++++------------ DMX-2.0/Sequenceur.cs | 2 +- DMX-2.0/SequenceurLineaire.cs | 29 ++++++++++++++++-- DMX-2.0/SequenceurMaitre.cs | 31 ++++++++++++++++--- 5 files changed, 94 insertions(+), 29 deletions(-) diff --git a/DMX-2.0/AssemblyInfo.cs b/DMX-2.0/AssemblyInfo.cs index 766e439..9c46a62 100644 --- a/DMX-2.0/AssemblyInfo.cs +++ b/DMX-2.0/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.CompilerServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("arnaud")] +[assembly: AssemblyCopyright("Emmanuel Langlois et Arnaud Houdelette")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -17,7 +17,7 @@ using System.Runtime.CompilerServices; // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2.0.*")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index 70f56f3..c5edefd 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -30,6 +30,8 @@ namespace DMX2 protected void ConstruitMatrice () { + + var idCol = new Gtk.TreeViewColumn (); var idCell = new Gtk.CellRendererText (); idCol.Title = "Num"; @@ -63,12 +65,20 @@ namespace DMX2 FillMatrice(); } + void DetruitMatrice () + { + this.MatriceUI.Model = null; + if (lsMatrice != null) lsMatrice.Dispose(); + foreach (var col in MatriceUI.Columns) + MatriceUI.RemoveColumn (col); + + } + static object seqkey = new object(); void ConstruitMatriceSeqColumns () { - foreach(var c in MatriceUI.Columns) if(c.CellRenderers[0].Data.ContainsKey(seqkey)) MatriceUI.RemoveColumn(c); @@ -93,7 +103,7 @@ namespace DMX2 void RenderMatriceNum (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { - + if (Conduite.Courante==null) return; string num=string.Empty; SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne; if( Conduite.Courante.SequenceurMaitre.IndexLigneEnCours == Conduite.Courante.SequenceurMaitre.Lignes.IndexOf(l) ) @@ -105,12 +115,14 @@ namespace DMX2 void RenderMatriceNom (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { + if (Conduite.Courante==null) return; SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne; (cell as Gtk.CellRendererText).Text = l.Nom; } void RenderMatriceDuree (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { + if (Conduite.Courante==null) return; SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne; if (l.Duree== TimeSpan.Zero) (cell as Gtk.CellRendererText).Text = string.Empty; else (cell as Gtk.CellRendererText).Text = (l.Duree.TotalMilliseconds /100).ToString(); @@ -118,6 +130,7 @@ namespace DMX2 void RenderMatriceSeqVal (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { + if (Conduite.Courante==null) return; SequenceurMaitre.Ligne l = tree_model.GetValue (iter, 0) as SequenceurMaitre.Ligne; Sequenceur seq = cell.Data[seqkey] as Sequenceur; (cell as Gtk.CellRendererText).Text = l[seq]; @@ -183,16 +196,11 @@ namespace DMX2 FillMatrice(); SelectionneEffet(pos); } - void OnMatriceNumColClicked (object sender, EventArgs e) - { - throw new NotImplementedException (); - } - - protected void OnBtnRetireLigneClicked (object sender, EventArgs e) { - throw new System.NotImplementedException (); + Conduite.Courante.SequenceurMaitre.RetireLigne(IndexEffetSelectionne()); + FillMatrice(); } protected void OnBtnGoBackClicked (object sender, EventArgs e) @@ -209,6 +217,7 @@ namespace DMX2 protected void OnMatriceUICursorChanged (object sender, EventArgs e) { + if (Conduite.Courante==null) return; TreeViewColumn col; TreePath path; MatriceUI.GetCursor (out path, out col); @@ -369,12 +378,9 @@ namespace DMX2 } catch (IOException) { } - foreach (Sequenceur s in Conduite.Courante.Sequenceurs) { - VBox newvbox = new VBox(); - newvbox.PackStart(s.GetUI(),false,false,0); - onglets.Add (newvbox); - onglets.ShowAll(); - } + foreach (Sequenceur s in Conduite.Courante.Sequenceurs) + AddSeqUI (s); + MajWidgets(); NextUpdateFull(); } @@ -408,7 +414,9 @@ namespace DMX2 { VBox newvbox = new VBox(); newvbox.PackStart(s.GetUI(),false,false,0); - onglets.Add (newvbox); + Widget label = new Gtk.Label(s.Name); + //onglets.Add (newvbox); + onglets.AppendPage(newvbox,label); onglets.ShowAll(); } @@ -417,12 +425,14 @@ namespace DMX2 foreach (var notebookvbox in onglets.Children) notebookvbox.Destroy(); - foreach (Sequenceur s in Conduite.Courante.Sequenceurs) { + foreach (Sequenceur s in Conduite.Courante.Sequenceurs) + AddSeqUI(s); + /*{ VBox newvbox = new VBox(); newvbox.PackStart(s.GetUI(),false,false,0); onglets.Add (newvbox); onglets.ShowAll(); - } + }*/ } @@ -467,14 +477,21 @@ namespace DMX2 { if (Conduite.Courante != null) { //Activation / Désactivation des boutons en fonction de l'état de la counduite courante - showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = true; + btnAjoutLigne.Sensitive = btnRetireLigne.Sensitive = btnGo.Sensitive = btnGoBack.Sensitive = + showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = + seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = + saveAsAction.Sensitive = closeAction.Sensitive = true; openAction.Sensitive = newAction.Sensitive = false; this.Title = "DMX 2.0 - " + Conduite.Courante.Name; ConstruitMatrice(); } else { - showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = false; + btnAjoutLigne.Sensitive = btnRetireLigne.Sensitive = btnGo.Sensitive = btnGoBack.Sensitive = + showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = + seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = + saveAsAction.Sensitive = closeAction.Sensitive = false; openAction.Sensitive = newAction.Sensitive = true; this.Title = "DMX 2.0"; + DetruitMatrice(); } } diff --git a/DMX-2.0/Sequenceur.cs b/DMX-2.0/Sequenceur.cs index 6c54ee2..ac48865 100644 --- a/DMX-2.0/Sequenceur.cs +++ b/DMX-2.0/Sequenceur.cs @@ -64,7 +64,7 @@ namespace DMX2 public abstract void Save (XmlElement parent); - + public abstract void Command (string command); } diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index a35478b..d69ab89 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -39,6 +39,11 @@ namespace DMX2 } } + public Dictionary Valeurs { + get { + return _valeurs; + } + } public void RetireCircuit (Circuit c) { _valeurs.Remove (c); @@ -371,7 +376,7 @@ namespace DMX2 ui = null; } - public static SequenceurLineaire Load (Conduite conduite, System.Xml.XmlElement el) + public static new SequenceurLineaire Load (Conduite conduite, System.Xml.XmlElement el) { SequenceurLineaire seq = new SequenceurLineaire(); seq.LoadSeq(conduite,el); @@ -392,7 +397,27 @@ namespace DMX2 } foreach (var xe in el.GetElementsByTagName("Effet")) - effets.Add(Effet.Load(conduite,xe as System.Xml.XmlElement)); + effets.Add(Effet.Load(conduite,xe as System.Xml.XmlElement)); + } + + public override void Command (string command) + { + lock (this) { + var cmd = System.Text.RegularExpressions.Regex.Match (command, @"(?\d+)(t(?\d+))?"); + + if (cmd.Success) { + if (cmd.Groups ["effet"].Success) { + int effet = int.Parse (cmd.Groups ["effet"].Value) - 1; + if (effet < effets.Count) + ChangeEffetCourrant (effet); + } + + if (cmd.Groups ["transition"].Success) { + int transition = int.Parse (cmd.Groups ["transition"].Value); + effetcourrant = new Effet ("", effetcourrant.Valeurs, effetcourrant.Duree, TimeSpan.FromMilliseconds (transition * 100)); + } + } + } } } } diff --git a/DMX-2.0/SequenceurMaitre.cs b/DMX-2.0/SequenceurMaitre.cs index 417d02a..ae26dd7 100644 --- a/DMX-2.0/SequenceurMaitre.cs +++ b/DMX-2.0/SequenceurMaitre.cs @@ -75,8 +75,6 @@ namespace DMX2 } return l; } - - } List lignes = new List(); @@ -90,8 +88,8 @@ namespace DMX2 public int IndexLigneEnCours { get { - if (enCours == null) return -1; - return lignes.IndexOf(enCours); + if (enCours == null) return -1; + return lignes.IndexOf(enCours); } } @@ -123,6 +121,7 @@ namespace DMX2 aSuivre = null; timeStamp = TimeSpan.Zero; change = true; + LanceSequenceurs(); } } @@ -136,9 +135,19 @@ namespace DMX2 aSuivre = null; timeStamp = TimeSpan.Zero; change = true; + LanceSequenceurs(); } } + void LanceSequenceurs () + { + foreach (Sequenceur s in Conduite.Courante.Sequenceurs) { + if(enCours[s].Length > 0) + s.Command(enCours[s]); + } + } + + public ReadOnlyCollection Lignes { get { return lignes.AsReadOnly(); @@ -158,6 +167,20 @@ namespace DMX2 } } + public void RetireLigne (int pos) + { + lock (this) { + if(lignes[pos]== enCours) + { + enCours=null; + if(pos+1 < lignes.Count) + aSuivre = lignes[pos+1]; + } + if(lignes[pos] == aSuivre) + aSuivre=null; + lignes.RemoveAt(pos); + } + } public void Tick (TimeSpan deltaT) { timeStamp += deltaT;