Ajout d'options en ligne de commande : fullscreen et aguibtn. Quelques commentaires
Ouverture Midi des le demarrage de l'appli
This commit is contained in:
parent
97c247266c
commit
6628d7ca9b
9 changed files with 157 additions and 93 deletions
|
|
@ -8,48 +8,49 @@ using System.Xml;
|
|||
|
||||
namespace DMX2
|
||||
{
|
||||
public class Conduite : IComparer<Circuit>, 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<Circuit> circuits = new List<Circuit>();
|
||||
List<UniversDMX> univers = new List<UniversDMX>();
|
||||
|
||||
List<DriverDMX> drivers = new List<DriverDMX>();
|
||||
List<Sequenceur> sequenceurs= new List<Sequenceur>();
|
||||
|
||||
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<Circuit> 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<Circuit>.Compare (Circuit x, Circuit y)
|
||||
{
|
||||
return Conduite.Courante.circuits.IndexOf(x) -
|
||||
Conduite.Courante.circuits.IndexOf(y);
|
||||
}
|
||||
|
||||
List<Sequenceur> sequenceurs= new List<Sequenceur>();
|
||||
|
||||
public ReadOnlyCollection<Sequenceur> 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;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<Commandlineparameters>fullscreen aguibtn</Commandlineparameters>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>none</DebugType>
|
||||
|
|
|
|||
|
|
@ -7,25 +7,56 @@ 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 ();
|
||||
|
||||
// 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 ());
|
||||
|
||||
MainWindow win = new MainWindow ();
|
||||
// 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 ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,17 +562,26 @@ namespace DMX2
|
|||
|
||||
|
||||
bool isfullscreen=false;
|
||||
protected void OnFullscreenAction1Activated (object sender, EventArgs e)
|
||||
|
||||
public void ToggleFullscreen ()
|
||||
{
|
||||
if (!isfullscreen) {
|
||||
Fullscreen ();
|
||||
isfullscreen = true;
|
||||
} else {
|
||||
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
|
||||
|
||||
EditionUnivers uDlg = null;
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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<string,internalEvent> eventlist = new Dictionary<string, internalEvent>();
|
||||
IntPtr midi_seq_handle = IntPtr.Zero;
|
||||
|
||||
Dictionary<string,internalEvent> eventlist = new Dictionary<string, internalEvent>();
|
||||
|
||||
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<string> 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 ("<ui><toolbar name='toolbar8'><toolitem name='newAction' action='newAction'/><toolitem name='openAction' action='openAction'/><toolitem name='saveAction' action='saveAction'/><toolitem name='saveAsAction' action='saveAsAction'/><toolitem name='closeAction' action='closeAction'/><toolitem name='selectColorAction' action='selectColorAction'/><toolitem name='quitAction' action='quitAction'/></toolbar></ui>");
|
||||
this.UIManager.AddUiFromString ("<ui><toolbar name='toolbar8'><toolitem name='newAction' action='newAction'/><toolitem name='openAction' action='openAction'/><toolitem name='saveAction' action='saveAction'/><toolitem name='saveAsAction' action='saveAsAction'/><toolitem name='closeAction' action='closeAction'/><toolitem name='aguiAction' action='aguiAction'/><toolitem name='selectColorAction' action='selectColorAction'/><toolitem name='quitAction' action='quitAction'/></toolbar></ui>");
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -197,6 +197,17 @@
|
|||
<property name="Tooltip" translatable="yes">Recharger le theme</property>
|
||||
<signal name="Activated" handler="OnSelectColorActionActivated" />
|
||||
</action>
|
||||
<action id="aguiAction">
|
||||
<property name="Type">Action</property>
|
||||
<property name="Label" translatable="yes" />
|
||||
<property name="StockId">gtk-info</property>
|
||||
<property name="Tooltip" translatable="yes">Lance AConnectGui</property>
|
||||
<property name="Visible">False</property>
|
||||
<property name="VisibleHorizontal">False</property>
|
||||
<property name="VisibleVertical">False</property>
|
||||
<property name="VisibleOverflown">False</property>
|
||||
<signal name="Activated" handler="OnInfoActionActivated" />
|
||||
</action>
|
||||
</action-group>
|
||||
<property name="MemberName" />
|
||||
<property name="Title" translatable="yes">MainWindow</property>
|
||||
|
|
@ -531,6 +542,7 @@ celle selectionnée</property>
|
|||
<node type="Toolitem" action="saveAction" />
|
||||
<node type="Toolitem" action="saveAsAction" />
|
||||
<node type="Toolitem" action="closeAction" />
|
||||
<node type="Toolitem" action="aguiAction" />
|
||||
<node type="Toolitem" action="selectColorAction" />
|
||||
<node type="Toolitem" action="quitAction" />
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue