diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index 2de2aa8..f6d593d 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -8,48 +8,49 @@ using System.Xml; namespace DMX2 { - public class Conduite : IComparer, IDisposable + public class Conduite : IDisposable { + // Conduite courante static Conduite courante = null; - public static Conduite Courante { get { return courante; } } - Timer timer = null; - DateTime dernierTick; - DateTime derniereMaj; - string _name; + + Timer timer = null; // Timer de Mise a jour en arriere plan + DateTime dernierTick; // Derniere execution du timer + DateTime derniereMaj; // Derniere MAJ de l'affichage + string _name; // Nom de la conduite int master=100; List circuits = new List(); List univers = new List(); - List drivers = new List(); + List sequenceurs= new List(); SequenceurMaitre seqmaitre = new SequenceurMaitre(); + EventManager eventManager = new EventManager(); // Gestion des fournisseurs d'evenements MidiEventProvider midip=null; - - actionEventTarget masterEventTarget; + actionEventTarget masterEventTarget; // Recepteur d'evenements pour le master public Conduite() { - + // Conduite courante => la derniere instanciee if(courante!= null) courante.Dispose(); courante = this; - timer = new Timer(new TimerCallback(TimerTick),this, 1000,10); - derniereMaj = dernierTick=DateTime.Now; + // Les ID reprennent à 1 + Circuit.maxid = 1; + Sequenceur.maxid = 1; + UniversDMX.maxid = 1; // Crée l'univers par défaut var u = new UniversDMX(); Patches.Add(u); u.Nom = "Univers par Défaut"; - Pause = false; - - + // La conduite peux recevoir des evenements midi midip = new MidiEventProvider(eventManager); masterEventTarget = new actionEventTarget( @@ -57,9 +58,11 @@ namespace DMX2 Master = 100 * data.value /255; return true; }); - } - EventManager eventManager = new EventManager(); + // Démarrage du timer + timer = new Timer(new TimerCallback(TimerTick),this, 1000,10); + derniereMaj = dernierTick=DateTime.Now; + } public EventManager EventManager { get { @@ -86,16 +89,6 @@ namespace DMX2 } } -/* public void SupprimeCircuits (IEnumerable lc) - { - lock (this) { - foreach(var c in lc) - circuits.Remove (c); - foreach(var seq in Sequenceurs) - seq.MajCircuitsSupprimes(); - } - }*/ - public Circuit GetCircuitByID (int i) { foreach(Circuit c in circuits) @@ -137,14 +130,6 @@ namespace DMX2 } } - int IComparer.Compare (Circuit x, Circuit y) - { - return Conduite.Courante.circuits.IndexOf(x) - - Conduite.Courante.circuits.IndexOf(y); - } - - List sequenceurs= new List(); - public ReadOnlyCollection Sequenceurs { get { return sequenceurs.AsReadOnly(); @@ -181,7 +166,8 @@ namespace DMX2 static public void TimerTick (object state) { - Conduite.Courante.Tick(); + Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; + (state as Conduite).Tick(); } void Tick () @@ -250,23 +236,17 @@ namespace DMX2 public void Dispose() { + if(disposed) return; if(courante==this) courante = null; - disposed=true; if(timer!=null) timer.Dispose(); - if(midip!=null) - midip.Dispose(); foreach(var driver in Drivers) driver.Dispose(); timer=null; + disposed=true; } - void IDisposable.Dispose () - { - if(!disposed) - Dispose(); - } #endregion #region Sauvegarde @@ -315,11 +295,10 @@ namespace DMX2 public static Conduite Load (XmlDocument doc) { + //TODO : Gestion d'erreurs Conduite cond = new Conduite (); cond.LoadDoc (doc); return cond; -// cond.Dispose(); -// return null; } private void LoadDoc (XmlDocument doc) @@ -369,7 +348,7 @@ namespace DMX2 public class Circuit { - static int maxid=1; + public static int maxid=1; string name; public const int SNLen= 8; diff --git a/DMX-2.0/DMX-2.0.csproj b/DMX-2.0/DMX-2.0.csproj index cd5e7be..b599606 100644 --- a/DMX-2.0/DMX-2.0.csproj +++ b/DMX-2.0/DMX-2.0.csproj @@ -19,6 +19,8 @@ prompt 4 false + true + fullscreen aguibtn none diff --git a/DMX-2.0/Main.cs b/DMX-2.0/Main.cs index a205b01..54644b2 100644 --- a/DMX-2.0/Main.cs +++ b/DMX-2.0/Main.cs @@ -7,27 +7,58 @@ namespace DMX2 { public static void Main (string[] args) { + bool fullscreen = false, aguibtn = false; + // Traitement des options en ligne de commande : + + foreach (string arg in args) { + switch (arg) { + case "fullscreen": + case "fs": + fullscreen = true; + break; + case "aguibtn": + aguibtn=true; + break; + default: + break; + } + } + + // Initialisation GTK# Application.Init (); - System.IO.Directory.SetCurrentDirectory ( - (new System.IO.FileInfo( - System.Reflection.Assembly.GetExecutingAssembly().Location - )).DirectoryName + // Repertoire courrant est celui de l'executable + System.IO.Directory.SetCurrentDirectory ( + (new System.IO.FileInfo ( + System.Reflection.Assembly.GetExecutingAssembly ().Location + )).DirectoryName ); - if(System.IO.File.Exists("style.gtkrc")) Gtk.Rc.Parse("style.gtkrc"); + // Chargement du style GTK + if (System.IO.File.Exists ("style.gtkrc")) + Gtk.Rc.Parse ("style.gtkrc"); else using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("style.gtkrc")) - using (System.IO.TextReader reader = new System.IO.StreamReader(stream)) - Gtk.Rc.ParseString (reader.ReadToEnd()); + using (System.IO.TextReader reader = new System.IO.StreamReader(stream)) + Gtk.Rc.ParseString (reader.ReadToEnd ()); + // Force l'instanciation du handle midi. + IntPtr ptr = MidiEventProvider.MidiSeqHandle.Handle; + + // Creation de la fenetre principale MainWindow win = new MainWindow (); + // application des options + if(fullscreen) win.ToggleFullscreen(); + if(aguibtn) win.AfficheBoutonACGUI(); + // Lancement win.Show (); Application.Run (); + + // Nettoyage if (Conduite.Courante != null) { - Conduite.Courante.Dispose(); + Conduite.Courante.Dispose (); } } } diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index cf555db..98d0511 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -371,7 +371,7 @@ namespace DMX2 fcd.Filter = new FileFilter (); fcd.Filter.AddPattern ("*.dmx2"); - if ((ResponseType)fcd.Run () == ResponseType.Cancel) { + if ((ResponseType)fcd.Run () == ResponseType.Cancel || fcd.Filename==null) { fcd.Destroy (); return; } @@ -562,15 +562,24 @@ namespace DMX2 bool isfullscreen=false; - protected void OnFullscreenAction1Activated (object sender, EventArgs e) + + public void ToggleFullscreen () { if (!isfullscreen) { Fullscreen (); isfullscreen = true; - } else { - Unfullscreen(); - isfullscreen = false; + fullscreenAction1.StockId = "gtk-leave-fullscreen"; } + else { + Unfullscreen (); + isfullscreen = false; + fullscreenAction1.StockId = "gtk-fullscreen"; + } + } + + protected void OnFullscreenAction1Activated (object sender, EventArgs e) + { + ToggleFullscreen (); } #region Boite dialogue Univers @@ -649,5 +658,22 @@ namespace DMX2 this.ResetRcStyles(); } + + public void AfficheBoutonACGUI () + { + aguiAction.VisibleHorizontal = true; + } + + Process aguiprocess= null; + + protected void OnInfoActionActivated (object sender, EventArgs e) + { + if(aguiprocess!=null) + if(!aguiprocess.HasExited) + return; + + aguiprocess= Process.Start("aconnectgui"); + } + } } \ No newline at end of file diff --git a/DMX-2.0/MidiEventProvider.cs b/DMX-2.0/MidiEventProvider.cs index a3f3a83..bb3a110 100644 --- a/DMX-2.0/MidiEventProvider.cs +++ b/DMX-2.0/MidiEventProvider.cs @@ -5,8 +5,37 @@ using System.Linq; namespace DMX2 { - public partial class MidiEventProvider : IEventProvider, IDisposable + public partial class MidiEventProvider : IEventProvider { + public class MidiSeqHandle : IDisposable + { + static MidiSeqHandle singleton = new MidiSeqHandle(); + IntPtr midi_seq_handle = IntPtr.Zero; + + public static IntPtr Handle { + get { + return singleton.midi_seq_handle; + } + } + + public MidiSeqHandle(){ + snd_seq_open(out midi_seq_handle, "default",SND_SEQ_OPEN_DUPLEX,0); + snd_seq_set_client_name(midi_seq_handle,"DMX2"); + snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl", + SND_SEQ_PORT_CAP_WRITE + SND_SEQ_PORT_CAP_SUBS_WRITE, + SND_SEQ_PORT_TYPE_APPLICATION); + } + + #region IDisposable implementation + public void Dispose () + { + if(midi_seq_handle != IntPtr.Zero) + snd_seq_close(midi_seq_handle); + midi_seq_handle = IntPtr.Zero; + } + #endregion + + } class internalEvent { public string internalName; @@ -18,30 +47,14 @@ namespace DMX2 } } - Dictionary eventlist = new Dictionary(); - IntPtr midi_seq_handle = IntPtr.Zero; + Dictionary eventlist = new Dictionary(); public MidiEventProvider (EventManager manager) { - snd_seq_open(out midi_seq_handle, "default",SND_SEQ_OPEN_DUPLEX,0); - snd_seq_set_client_name(midi_seq_handle,"DMX2"); - snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl", - SND_SEQ_PORT_CAP_WRITE + SND_SEQ_PORT_CAP_SUBS_WRITE, - SND_SEQ_PORT_TYPE_APPLICATION); - manager.RegisterProvider(this); } - - #region IDisposable implementation - public void Dispose () - { - snd_seq_close(midi_seq_handle); - } - #endregion - - #region IEventProvider implementation /*ICollection IEventProvider.GetEventList () { @@ -101,8 +114,8 @@ namespace DMX2 void IEventProvider.ProcessEvents (EventManagerCallback callback) { IntPtr evPtr; - while ((snd_seq_event_input_pending(midi_seq_handle,1))>0) { - snd_seq_event_input(midi_seq_handle, out evPtr); + while ((snd_seq_event_input_pending(MidiSeqHandle.Handle,1))>0) { + snd_seq_event_input(MidiSeqHandle.Handle, out evPtr); snd_seq_event_t evS =(snd_seq_event_t) Marshal.PtrToStructure(evPtr,typeof(snd_seq_event_t)); snd_seq_free_event(evPtr); diff --git a/DMX-2.0/Sequenceur.cs b/DMX-2.0/Sequenceur.cs index f7dc4e2..ef8334c 100644 --- a/DMX-2.0/Sequenceur.cs +++ b/DMX-2.0/Sequenceur.cs @@ -7,18 +7,11 @@ namespace DMX2 public abstract class Sequenceur { - static int idmax=0; - - public Sequenceur (int id) - { - this.id = id; - idmax = Math.Max(id,idmax); - Name = "Seq " + id.ToString(); - } + public static int maxid=1; public Sequenceur () { - id = ++idmax; + id = maxid++; Name = "Seq " + id.ToString(); } @@ -30,7 +23,7 @@ namespace DMX2 } protected set { id=value; - idmax = Math.Max(id+1,idmax); + maxid = Math.Max(id+1,maxid); } } diff --git a/DMX-2.0/UniversDMX.cs b/DMX-2.0/UniversDMX.cs index 4b1d50d..6f85421 100644 --- a/DMX-2.0/UniversDMX.cs +++ b/DMX-2.0/UniversDMX.cs @@ -8,12 +8,12 @@ namespace DMX2 public class UniversDMX { - static int nb=1; + public static int maxid=1; public UniversDMX () { - Nom = "Univers DMX n°" + nb++.ToString (); + Nom = "Univers DMX n°" + maxid++.ToString (); for (int i = 0; i<_dimmers.Length; i++) { diff --git a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs index 10af0be..adefca8 100644 --- a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs +++ b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs @@ -23,6 +23,7 @@ namespace DMX2 private global::Gtk.Action connectAction; private global::Gtk.Action seqMacroAction; private global::Gtk.Action selectColorAction; + private global::Gtk.Action aguiAction; private global::Gtk.VBox vbox1; private global::Gtk.HBox hbox1; private global::Gtk.VBox vbox2; @@ -110,6 +111,12 @@ namespace DMX2 w1.Add (this.seqMacroAction, null); this.selectColorAction = new global::Gtk.Action ("selectColorAction", null, "Recharger le theme", "gtk-select-color"); w1.Add (this.selectColorAction, null); + this.aguiAction = new global::Gtk.Action ("aguiAction", null, "Lance AConnectGui", "gtk-info"); + this.aguiAction.Visible = false; + this.aguiAction.VisibleHorizontal = false; + this.aguiAction.VisibleVertical = false; + this.aguiAction.VisibleOverflown = false; + w1.Add (this.aguiAction, null); this.UIManager.InsertActionGroup (w1, 0); this.AddAccelGroup (this.UIManager.AccelGroup); this.Name = "DMX2.MainWindow"; @@ -413,7 +420,7 @@ namespace DMX2 global::Gtk.Box.BoxChild w74 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.evInfo])); w74.Position = 1; // Container child hbox4.Gtk.Box+BoxChild - this.UIManager.AddUiFromString (""); + this.UIManager.AddUiFromString (""); this.toolbar8 = ((global::Gtk.Toolbar)(this.UIManager.GetWidget ("/toolbar8"))); this.toolbar8.Name = "toolbar8"; this.toolbar8.ShowArrow = false; @@ -450,6 +457,7 @@ namespace DMX2 this.connectAction.Activated += new global::System.EventHandler (this.OnConnectActionActivated); this.seqMacroAction.Activated += new global::System.EventHandler (this.OnSeqMacroActionActivated); this.selectColorAction.Activated += new global::System.EventHandler (this.OnSelectColorActionActivated); + this.aguiAction.Activated += new global::System.EventHandler (this.OnInfoActionActivated); this.btnGo.Clicked += new global::System.EventHandler (this.OnBtnGoClicked); this.btnGoBack.Clicked += new global::System.EventHandler (this.OnBtnGoBackClicked); this.btnAjoutLigne.Clicked += new global::System.EventHandler (this.OnBtnAjoutLigneClicked); diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index 1a655ec..9822b55 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -197,6 +197,17 @@ Recharger le theme + + Action + + gtk-info + Lance AConnectGui + False + False + False + False + + MainWindow @@ -531,6 +542,7 @@ celle selectionnée +