From b724c67b8bcf1fee77edda9e6c491bc897f6cc23 Mon Sep 17 00:00:00 2001 From: tzim Date: Thu, 14 Nov 2013 16:16:09 +0000 Subject: [PATCH] Amelioration gestion d'evenements --- DMX-2.0/Conduite.cs | 8 +++ DMX-2.0/ContextMenuHelper.cs | 14 ++-- DMX-2.0/DMX-2.0.csproj | 1 + DMX-2.0/DriverBoitierV1.cs | 78 +++++++++++++++++++-- DMX-2.0/EventManager.cs | 38 ++++++++-- DMX-2.0/MainWindow.cs | 28 ++++++++ DMX-2.0/MidiEventProvider.cs | 3 +- DMX-2.0/SeqLinUI.cs | 71 +++++++++++++++---- DMX-2.0/SequenceurLineaire.cs | 115 ++++++++++++++++++++++++++++++- DMX-2.0/gtk-gui/DMX2.SeqLinUI.cs | 1 - DMX-2.0/gtk-gui/gui.stetic | 1 - DMX-2.0/style.gtkrc | 12 +++- 12 files changed, 332 insertions(+), 38 deletions(-) diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index c1e002f..122da8d 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -219,6 +219,14 @@ namespace DMX2 } + public void BindMaster (string eventId) + { + + //TODO + throw new NotImplementedException (); + } + + #region IDisposable implementation bool disposed=false; diff --git a/DMX-2.0/ContextMenuHelper.cs b/DMX-2.0/ContextMenuHelper.cs index 201d160..4f0463e 100644 --- a/DMX-2.0/ContextMenuHelper.cs +++ b/DMX-2.0/ContextMenuHelper.cs @@ -67,16 +67,16 @@ namespace DMX2 } } - private bool propagating = false; //Prevent reentry + //private bool propagating = false; //Prevent reentry private void RaiseContextMenuEvent (SignalArgs signalArgs, Widget widget, bool rightClick) { - if (!propagating) { + //if (!propagating) { //Propagate the event - Event evnt = Gtk.Global.CurrentEvent; - propagating = true; - Gtk.Global.PropagateEvent (widget, evnt); - propagating = false; + // Event evnt = Gtk.Global.CurrentEvent; + // propagating = true; + // Gtk.Global.PropagateEvent (widget, evnt); + // propagating = false; signalArgs.RetVal = true; //The widget already processed the event in the propagation //Raise the context menu event @@ -84,7 +84,7 @@ namespace DMX2 if (ContextMenu != null) { ContextMenu.Invoke (this, args); } - } + //} } } } \ No newline at end of file diff --git a/DMX-2.0/DMX-2.0.csproj b/DMX-2.0/DMX-2.0.csproj index a7761a1..4b86a90 100644 --- a/DMX-2.0/DMX-2.0.csproj +++ b/DMX-2.0/DMX-2.0.csproj @@ -44,6 +44,7 @@ glib-sharp-2.0 + diff --git a/DMX-2.0/DriverBoitierV1.cs b/DMX-2.0/DriverBoitierV1.cs index ad8103e..a4ae85c 100644 --- a/DMX-2.0/DriverBoitierV1.cs +++ b/DMX-2.0/DriverBoitierV1.cs @@ -6,6 +6,19 @@ namespace DMX2 { public class DriverBoitierV1 : DriverDMX, IEventProvider { + + struct buttonState { + public buttonState(byte _button, bool _pressed){ + button=_button; pressed=_pressed; + } + public byte button; + public bool pressed; + } + + bool[] buttons = new bool[8]; + bool[] watchButtons = new bool[8]; + + // tampons Entrée/Sortie byte[] inputbuffer = new byte[1]; byte[] outputbuffer = new byte[260]; @@ -107,6 +120,7 @@ namespace DMX2 serial.Read(inputbuffer,0,inputbuffer.Length); //Console.WriteLine(inputbuffer[0]); + ProcessInput(); } catch (TimeoutException ex) { serial.Close(); @@ -114,6 +128,21 @@ namespace DMX2 } + void ProcessInput () + { + byte b = 1; bool pressed; + for (byte i = 0; i<8; i++) { + if(!watchButtons[i]) continue; + pressed = (inputbuffer[0] & b) != 0; + if(buttons[i]^pressed) + { + eventsPending.Enqueue(new buttonState(i,pressed)); + buttons[i] = pressed; + } + b <<= 1; + } + } + #region implemented abstract members of DMX2.DriverDMX public override Gtk.Window GetDialog () { @@ -135,24 +164,65 @@ namespace DMX2 } #region IEventProvider implementation + + + static System.Text.RegularExpressions.Regex regexEventID = new System.Text.RegularExpressions.Regex( + @"BV1-B(?