diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index ddc9a95..bdaa460 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -119,9 +119,15 @@ namespace DMX2 { lock (this) { sequenceurs.Add(seq); + seq.Renamed += SequenceurRenomme; } } + void SequenceurRenomme (object sender, Sequenceur.SeqRenamedEventArgs e) + { + MainWindow.Win.NextUpdateFull(); + } + public Sequenceur GetSeqByID (int i) { foreach(Sequenceur seq in sequenceurs) @@ -148,6 +154,9 @@ namespace DMX2 TimeSpan deltaT = tickTime - dernierTick; dernierTick = tickTime; + if( deltaT > TimeSpan.FromMilliseconds(15) ) + Console.WriteLine ("{0}", deltaT); + lock (this) { seqmaitre.Tick(deltaT); @@ -173,9 +182,6 @@ namespace DMX2 derniereMaj = DateTime.Now; } - - if( deltaT > TimeSpan.FromMilliseconds(15) ) - Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,deltaT); } #region IDisposable implementation @@ -260,8 +266,10 @@ namespace DMX2 foreach (var xs in root["Sequenceurs"].ChildNodes) { Sequenceur s = Sequenceur.Load (this, xs as XmlElement); - if (s != null) + if (s != null){ sequenceurs.Add (s); + s.Renamed += SequenceurRenomme; + } } univers.Clear(); diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index c5edefd..7ebe1e9 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -58,8 +58,6 @@ namespace DMX2 dureeCell.Edited += OnDureeCellEdited; this.MatriceUI.AppendColumn (dureeCol); - ConstruitMatriceSeqColumns(); - lsMatrice = new Gtk.ListStore(typeof (SequenceurMaitre.Ligne)); this.MatriceUI.Model = lsMatrice; FillMatrice(); @@ -194,7 +192,7 @@ namespace DMX2 int pos=IndexEffetSelectionne() + 1; Conduite.Courante.SequenceurMaitre.AjoutLigne(pos); FillMatrice(); - SelectionneEffet(pos); + MatriceUI.SetCursor( new TreePath( new int[1] {pos }) , MatriceUI.Columns[1] ,true); } protected void OnBtnRetireLigneClicked (object sender, EventArgs e) @@ -407,33 +405,22 @@ namespace DMX2 Sequenceur s = new SequenceurLineaire(); Conduite.Courante.AjoutSequenceur(s); AddSeqUI(s); - ConstruitMatriceSeqColumns(); + NextUpdateFull(); } void AddSeqUI (Sequenceur s) { - VBox newvbox = new VBox(); - newvbox.PackStart(s.GetUI(),false,false,0); - Widget label = new Gtk.Label(s.Name); - //onglets.Add (newvbox); - onglets.AppendPage(newvbox,label); + onglets.AppendPage(s.GetUI(),new Gtk.Label(s.Name)); onglets.ShowAll(); } protected void OnShowAllActionActivated (object sender, EventArgs e) { - foreach (var notebookvbox in onglets.Children) - notebookvbox.Destroy(); + foreach (var notebookchild in onglets.Children) + notebookchild.Destroy(); 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(); - }*/ - } #endregion @@ -462,15 +449,16 @@ namespace DMX2 void Update (object sender, EventArgs e) { - foreach (var notebookvbox in onglets.Children) { - foreach (var sequi in (notebookvbox as VBox).Children) { - (sequi as SequenceurUI).Update (fullUpdateFlag); - } + if(Conduite.Courante==null)return; + foreach (var notebookchild in onglets.Children) { + SequenceurUI sequi = notebookchild as SequenceurUI; + if(sequi != null) sequi.Update(fullUpdateFlag); } MajCircuits(fullUpdateFlag); + if(fullUpdateFlag) ConstruitMatriceSeqColumns(); + if( Conduite.Courante.SequenceurMaitre.EffetChange() )MatriceUI.QueueDraw(); fullUpdateFlag=false; updScheduled=false; - if( Conduite.Courante.SequenceurMaitre.EffetChange() )MatriceUI.QueueDraw(); } protected void MajWidgets () @@ -492,6 +480,10 @@ namespace DMX2 openAction.Sensitive = newAction.Sensitive = true; this.Title = "DMX 2.0"; DetruitMatrice(); + foreach (var widget in vboxCircuits.Children) + vboxCircuits.Remove (widget); + foreach (var notebookvbox in onglets.Children) + notebookvbox.Destroy(); } } diff --git a/DMX-2.0/SeqLinUI.cs b/DMX-2.0/SeqLinUI.cs index 2773dca..208d8a4 100644 --- a/DMX-2.0/SeqLinUI.cs +++ b/DMX-2.0/SeqLinUI.cs @@ -19,13 +19,46 @@ namespace DMX2 effetChange = true; } + void OnButtonPressedEvent (object o, ButtonPressEventArgs e) + { + if (e.Event.Button == 3) /* right click */ + { + Menu m = new Menu(); + MenuItem renameItem = new MenuItem("Renommer le Sequenceur"); + renameItem.ButtonPressEvent += new ButtonPressEventHandler(OnRenameItemButtonPressed); + m.Add(renameItem); + m.ShowAll(); + m.Popup(); + } + } + + void OnRenameItemButtonPressed (object o, ButtonPressEventArgs args) + { + var dlg = new Dialog ("Nouveau Nom ?", GetAncestor(Gtk.Window.GType) as Gtk.Window , DialogFlags.Modal); var entry = new Entry (sequenceur.Name); + dlg.AddButton (Stock.Ok, ResponseType.Ok).GrabDefault(); dlg.AddButton (Stock.Cancel, ResponseType.Cancel); + dlg.VBox.Add (entry); dlg.VBox.ShowAll (); + entry.ActivatesDefault=true; + + + + if ((ResponseType)dlg.Run () == ResponseType.Ok) { + sequenceur.Name = entry.Text; + titreLabel.Text = sequenceur.Name; + } + dlg.Destroy(); + } + public SeqLinUI (SequenceurLineaire s ) : base (s) { this.Build (); titreLabel.Text = s.Name; sequenceur = s; + frame1.ButtonPressEvent += OnButtonPressedEvent; + + #region Construction listeEffets + // Construction de la liste d'effets var numCol = new TreeViewColumn(); nomCol = new TreeViewColumn(); @@ -80,6 +113,7 @@ namespace DMX2 } + void EditNom (object o, EditedArgs args) { Gtk.TreeIter iter; @@ -185,7 +219,7 @@ namespace DMX2 protected void OnCloseActionActivated (object sender, EventArgs e) { - this.Parent.Destroy(); + this.Destroy(); } @@ -385,7 +419,10 @@ namespace DMX2 { if (fullUpdFlag)return; sequenceur.Master = (int)(seqMasterScale.Value); - } + + + } + } } diff --git a/DMX-2.0/Sequenceur.cs b/DMX-2.0/Sequenceur.cs index ac48865..214cd0f 100644 --- a/DMX-2.0/Sequenceur.cs +++ b/DMX-2.0/Sequenceur.cs @@ -42,9 +42,22 @@ namespace DMX2 } set { name = value; + if(Renamed!=null) Renamed(this, new SeqRenamedEventArgs(value)); } } + + public sealed class SeqRenamedEventArgs : EventArgs + { + public SeqRenamedEventArgs (string name) + { + NewName = name; + } + public string NewName {get;private set;} + } + + public event EventHandler Renamed; + public abstract SequenceurUI GetUI(); public abstract int ValeurCircuit(Circuit c); diff --git a/DMX-2.0/SequenceurLineaire.cs b/DMX-2.0/SequenceurLineaire.cs index d69ab89..cf704ca 100644 --- a/DMX-2.0/SequenceurLineaire.cs +++ b/DMX-2.0/SequenceurLineaire.cs @@ -11,7 +11,6 @@ namespace DMX2 string _nom; - public Effet (string nom, Dictionary valeurs, TimeSpan duree, TimeSpan transition) { _nom = nom; @@ -302,6 +301,7 @@ namespace DMX2 int pos = index+1; if (pos >= effets.Count) return SauveEffet(nom,duree,transition); effets.Insert (pos,effetcourrant = new Effet (nom, valeurscourantes, duree, transition)); + CommandAdd(index); return pos; } } @@ -317,25 +317,36 @@ namespace DMX2 public void SupprimeEffet (int index) { - effets.RemoveAt(index); + lock (this) { + effets.RemoveAt (index); + CommandRemove(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; + lock (this) { + if (index >= effets.Count || index < 1) + return index; + Effet ef = effets [index]; + effets.RemoveAt (index); + effets.Insert (index - 1, ef); + CommandSwap (index - 1); + 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; + lock (this) { + if (index > effets.Count - 2 || index < 0) + return index; + Effet ef = effets [index]; + effets.RemoveAt (index); + effets.Insert (index + 1, ef); + CommandSwap(index); + return index + 1; + } } public override void Save (System.Xml.XmlElement parent) @@ -400,10 +411,18 @@ namespace DMX2 effets.Add(Effet.Load(conduite,xe as System.Xml.XmlElement)); } + static System.Text.RegularExpressions.Regex regexCommand1 = new System.Text.RegularExpressions.Regex( + @"(?\d+)(t(?\d+))?", + System.Text.RegularExpressions.RegexOptions.Compiled); + + static System.Text.RegularExpressions.Regex regexCommand2 = new System.Text.RegularExpressions.Regex( + @"(?\d+)(?(t\d+)?)?", + System.Text.RegularExpressions.RegexOptions.Compiled); + public override void Command (string command) { lock (this) { - var cmd = System.Text.RegularExpressions.Regex.Match (command, @"(?\d+)(t(?\d+))?"); + var cmd = regexCommand1.Match(command); if (cmd.Success) { if (cmd.Groups ["effet"].Success) { @@ -419,5 +438,69 @@ namespace DMX2 } } } + + void CommandAdd (int index) + { + lock (Conduite.Courante.SequenceurMaitre) { + string[] commands = Conduite.Courante.SequenceurMaitre.GetCommands (this); + + for (int i = 0; i < commands.Length; i++) { + var cmd = regexCommand2.Match(commands[i]); + if(cmd.Success){ + int ef = int.Parse(cmd.Groups["effet"].Value); + if (ef-1>index) { + ef++; + commands[i] = ef.ToString() + cmd.Groups["params"].Value; + } + } + } + Conduite.Courante.SequenceurMaitre.SetCommands(this,commands); + } + } + + void CommandRemove (int index) + { + lock (Conduite.Courante.SequenceurMaitre) { + string[] commands = Conduite.Courante.SequenceurMaitre.GetCommands (this); + + for (int i = 0; i < commands.Length; i++) { + var cmd = regexCommand2.Match(commands[i]); + if(cmd.Success){ + int ef = int.Parse(cmd.Groups["effet"].Value); + if (ef-1 == index) + commands[i] = string.Empty; + else if (ef-1>index) { + ef--; + commands[i] = ef.ToString() + cmd.Groups["params"].Value; + } + } + } + Conduite.Courante.SequenceurMaitre.SetCommands(this,commands); + } + } + + void CommandSwap (int index) + { + lock (Conduite.Courante.SequenceurMaitre) { + string[] commands = Conduite.Courante.SequenceurMaitre.GetCommands (this); + + // numeros a swapper + int a = index+1; + int b = index+2; + + for (int i = 0; i < commands.Length; i++) { + var cmd = regexCommand2.Match(commands[i]); + if(cmd.Success){ + int ef = int.Parse(cmd.Groups["effet"].Value); + if (ef == a) + commands[i] = b.ToString() + cmd.Groups["params"].Value; + if (ef == b) + commands[i] = a.ToString() + cmd.Groups["params"].Value; + } + } + Conduite.Courante.SequenceurMaitre.SetCommands(this,commands); + } + } + } } diff --git a/DMX-2.0/SequenceurMaitre.cs b/DMX-2.0/SequenceurMaitre.cs index ae26dd7..9fcb28d 100644 --- a/DMX-2.0/SequenceurMaitre.cs +++ b/DMX-2.0/SequenceurMaitre.cs @@ -147,6 +147,26 @@ namespace DMX2 } } + public string[] GetCommands(Sequenceur s) + { + string[] res = new string[lignes.Count]; + for (int i = 0; i < lignes.Count; i++) { + res[i] = lignes[i][s]; + } + return res; + } + + public void SetCommands (Sequenceur s, string[] commands) + { + lock (this) { + for (int i = 0; i < Math.Max(lignes.Count,commands.Length); i++) { + lignes [i] [s] = commands [i]; + } + change= true; + + } + } + public ReadOnlyCollection Lignes { get { diff --git a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs index e3c237b..e8f07c7 100644 --- a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs +++ b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs @@ -288,7 +288,7 @@ namespace DMX2 w64.Fill = false; // Container child vbox2.Gtk.Box+BoxChild this.masterScale = new global::Gtk.VScale (null); - this.masterScale.HeightRequest = 260; + this.masterScale.HeightRequest = 150; this.masterScale.Name = "masterScale"; this.masterScale.Inverted = true; this.masterScale.Adjustment.Upper = 100; diff --git a/DMX-2.0/gtk-gui/DMX2.SeqLinUI.cs b/DMX-2.0/gtk-gui/DMX2.SeqLinUI.cs index 2c87051..cb6593c 100644 --- a/DMX-2.0/gtk-gui/DMX2.SeqLinUI.cs +++ b/DMX-2.0/gtk-gui/DMX2.SeqLinUI.cs @@ -33,6 +33,7 @@ namespace DMX2 private global::Gtk.ScrolledWindow GtkScrolledWindow; private global::Gtk.TreeView effetsListe; private global::Gtk.Toolbar toolbar3; + private global::Gtk.ScrolledWindow GtkScrolledWindow1; private global::Gtk.Fixed zoneWid; private global::Gtk.Label titreLabel; @@ -217,15 +218,21 @@ namespace DMX2 w15.Expand = false; w15.Fill = false; // Container child vbox2.Gtk.Box+BoxChild + this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow (); + this.GtkScrolledWindow1.Name = "GtkScrolledWindow1"; + // Container child GtkScrolledWindow1.Gtk.Container+ContainerChild + global::Gtk.Viewport w16 = new global::Gtk.Viewport (); + w16.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child GtkViewport.Gtk.Container+ContainerChild this.zoneWid = new global::Gtk.Fixed (); this.zoneWid.HeightRequest = 0; this.zoneWid.Name = "zoneWid"; this.zoneWid.HasWindow = false; - this.vbox2.Add (this.zoneWid); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.zoneWid])); - w16.Position = 1; - w16.Expand = false; - w16.Fill = false; + w16.Add (this.zoneWid); + this.GtkScrolledWindow1.Add (w16); + this.vbox2.Add (this.GtkScrolledWindow1); + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.GtkScrolledWindow1])); + w19.Position = 1; this.GtkAlignment.Add (this.vbox2); this.frame1.Add (this.GtkAlignment); this.titreLabel = new global::Gtk.Label (); diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index 424a86a..77a9e1c 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -307,7 +307,7 @@ - 260 + 150 True 100 10 @@ -893,17 +893,27 @@ - + - 0 - False - + + + + None + + + + 0 + True + False + + + + + 1 True - False - False