Amelioration gestion d'evenements
This commit is contained in:
parent
4c1cf28f31
commit
b724c67b8b
12 changed files with 332 additions and 38 deletions
|
|
@ -219,6 +219,14 @@ namespace DMX2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BindMaster (string eventId)
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
throw new NotImplementedException ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region IDisposable implementation
|
#region IDisposable implementation
|
||||||
bool disposed=false;
|
bool disposed=false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
private void RaiseContextMenuEvent (SignalArgs signalArgs, Widget widget, bool rightClick)
|
||||||
{
|
{
|
||||||
if (!propagating) {
|
//if (!propagating) {
|
||||||
//Propagate the event
|
//Propagate the event
|
||||||
Event evnt = Gtk.Global.CurrentEvent;
|
// Event evnt = Gtk.Global.CurrentEvent;
|
||||||
propagating = true;
|
// propagating = true;
|
||||||
Gtk.Global.PropagateEvent (widget, evnt);
|
// Gtk.Global.PropagateEvent (widget, evnt);
|
||||||
propagating = false;
|
// propagating = false;
|
||||||
signalArgs.RetVal = true; //The widget already processed the event in the propagation
|
signalArgs.RetVal = true; //The widget already processed the event in the propagation
|
||||||
|
|
||||||
//Raise the context menu event
|
//Raise the context menu event
|
||||||
|
|
@ -84,7 +84,7 @@ namespace DMX2
|
||||||
if (ContextMenu != null) {
|
if (ContextMenu != null) {
|
||||||
ContextMenu.Invoke (this, args);
|
ContextMenu.Invoke (this, args);
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
<Package>glib-sharp-2.0</Package>
|
<Package>glib-sharp-2.0</Package>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="gtk-gui\gui.stetic">
|
<EmbeddedResource Include="gtk-gui\gui.stetic">
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,19 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
public class DriverBoitierV1 : DriverDMX, IEventProvider
|
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
|
// tampons Entrée/Sortie
|
||||||
byte[] inputbuffer = new byte[1];
|
byte[] inputbuffer = new byte[1];
|
||||||
byte[] outputbuffer = new byte[260];
|
byte[] outputbuffer = new byte[260];
|
||||||
|
|
@ -107,6 +120,7 @@ namespace DMX2
|
||||||
|
|
||||||
serial.Read(inputbuffer,0,inputbuffer.Length);
|
serial.Read(inputbuffer,0,inputbuffer.Length);
|
||||||
//Console.WriteLine(inputbuffer[0]);
|
//Console.WriteLine(inputbuffer[0]);
|
||||||
|
ProcessInput();
|
||||||
|
|
||||||
} catch (TimeoutException ex) {
|
} catch (TimeoutException ex) {
|
||||||
serial.Close();
|
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
|
#region implemented abstract members of DMX2.DriverDMX
|
||||||
public override Gtk.Window GetDialog ()
|
public override Gtk.Window GetDialog ()
|
||||||
{
|
{
|
||||||
|
|
@ -135,24 +164,65 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IEventProvider implementation
|
#region IEventProvider implementation
|
||||||
|
|
||||||
|
|
||||||
|
static System.Text.RegularExpressions.Regex regexEventID = new System.Text.RegularExpressions.Regex(
|
||||||
|
@"BV1-B(?<button>\d+)?",
|
||||||
|
System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||||
|
|
||||||
|
System.Collections.Concurrent.ConcurrentQueue<buttonState> eventsPending =
|
||||||
|
new System.Collections.Concurrent.ConcurrentQueue<buttonState>();
|
||||||
|
|
||||||
bool IEventProvider.Bind (string eventId)
|
bool IEventProvider.Bind (string eventId)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException ();
|
var res = regexEventID.Match (eventId);
|
||||||
|
if (res.Success) {
|
||||||
|
int bt = int.Parse (res.Groups ["button"].Value);
|
||||||
|
if(bt<0||bt>7) return false;
|
||||||
|
watchButtons[bt] = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IEventProvider.Unbind (string eventId)
|
void IEventProvider.Unbind (string eventId)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException ();
|
var res = regexEventID.Match (eventId);
|
||||||
|
if (res.Success) {
|
||||||
|
int bt = int.Parse (res.Groups ["button"].Value);
|
||||||
|
if(bt<0||bt>7) return ;
|
||||||
|
watchButtons[bt] = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.Menu IEventProvider.GetProviderSubMenu (EventManager.EventMenuData state, Gtk.ButtonPressEventHandler handler)
|
Gtk.Menu IEventProvider.GetProviderSubMenu (EventManager.EventMenuData state, Gtk.ButtonPressEventHandler handler)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException ();
|
Gtk.Menu retmenu = new Gtk.Menu ();
|
||||||
|
|
||||||
|
Gtk.MenuItem evmenuitem = new Gtk.MenuItem ("Boutons");
|
||||||
|
retmenu.Add (evmenuitem);
|
||||||
|
Gtk.Menu evmenu = new Gtk.Menu ();
|
||||||
|
evmenuitem.Submenu = evmenu;
|
||||||
|
|
||||||
|
for (int i= 0; i<8;i++ ) {
|
||||||
|
Gtk.MenuItem item = new Gtk.MenuItem(string.Format("Bouton {0}",i+1));
|
||||||
|
item.Data[EventManager.EventIdKey] = string.Format("BV1-B{0}",i);
|
||||||
|
item.Data[EventManager.StateKey] = state;
|
||||||
|
item.ButtonPressEvent += handler;
|
||||||
|
evmenu.Add (item);
|
||||||
|
}
|
||||||
|
return retmenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IEventProvider.ProcessEvents (EventManagerCallback callback)
|
void IEventProvider.ProcessEvents (EventManagerCallback callback)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException ();
|
buttonState bt; string id; EventData evd;
|
||||||
|
while (eventsPending.TryDequeue(out bt)) {
|
||||||
|
evd.id= string.Format("BV1-B{0}",bt.button );
|
||||||
|
evd.value = bt.pressed?(byte)0xFF:(byte)0x00;
|
||||||
|
callback(evd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string IEventProvider.MenuName {
|
string IEventProvider.MenuName {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -10,6 +11,7 @@ namespace DMX2
|
||||||
public byte value;
|
public byte value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface IEventProvider
|
public interface IEventProvider
|
||||||
{
|
{
|
||||||
string MenuName{ get; }
|
string MenuName{ get; }
|
||||||
|
|
@ -28,6 +30,21 @@ namespace DMX2
|
||||||
public delegate void EventManagerCallback(EventData data);
|
public delegate void EventManagerCallback(EventData data);
|
||||||
public delegate void EventManagerMenuCallBack(object state, string eventId);
|
public delegate void EventManagerMenuCallBack(object state, string eventId);
|
||||||
|
|
||||||
|
public class actionEventTarget : IEventTarget {
|
||||||
|
public delegate bool EventAction (EventData data);
|
||||||
|
EventAction action;
|
||||||
|
public actionEventTarget(EventAction _action)
|
||||||
|
{
|
||||||
|
action=_action;
|
||||||
|
}
|
||||||
|
#region IEventTarget implementation
|
||||||
|
bool IEventTarget.FireEvent (EventData data)
|
||||||
|
{
|
||||||
|
return action(data);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class EventManager
|
public class EventManager
|
||||||
{
|
{
|
||||||
|
|
@ -88,6 +105,12 @@ namespace DMX2
|
||||||
menu.Add(provitem);
|
menu.Add(provitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gtk.MenuItem itemNone = new Gtk.MenuItem("Aucun");
|
||||||
|
itemNone.Data[StateKey] = evd;
|
||||||
|
itemNone.Data[EventIdKey] = "";
|
||||||
|
itemNone.ButtonPressEvent += handler;
|
||||||
|
menu.Add(itemNone);
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -123,11 +146,17 @@ namespace DMX2
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Unbind (IEventTarget target)
|
||||||
|
{
|
||||||
|
var q = from bind in bindings where bind.Value.Targets.Contains(target) select bind.Key;
|
||||||
|
foreach(string id in q.ToArray())
|
||||||
|
Unbind(id,target);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Unbind (string eventId, IEventTarget target)
|
public void Unbind (string eventId, IEventTarget target)
|
||||||
{
|
{
|
||||||
if (!bindings.ContainsKey (eventId))
|
if (!bindings.ContainsKey (eventId)) return;
|
||||||
return;
|
|
||||||
bindings [eventId].RemoveTarget (target);
|
bindings [eventId].RemoveTarget (target);
|
||||||
if (bindings [eventId].Targets.Count == 0) {
|
if (bindings [eventId].Targets.Count == 0) {
|
||||||
bindings.Remove(eventId);
|
bindings.Remove(eventId);
|
||||||
|
|
@ -137,7 +166,6 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void EventCallBack (EventData data)
|
public void EventCallBack (EventData data)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Event {0} => {1}",data.id,data.value);
|
Console.WriteLine("Event {0} => {1}",data.id,data.value);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,34 @@ namespace DMX2
|
||||||
win=this;
|
win=this;
|
||||||
Build ();
|
Build ();
|
||||||
MajWidgets();
|
MajWidgets();
|
||||||
|
|
||||||
|
ContextMenuHelper ctxHelper = new ContextMenuHelper();
|
||||||
|
ctxHelper.ContextMenu += EventPopup;
|
||||||
|
ctxHelper.AttachToWidget(btnGo);
|
||||||
|
ctxHelper.AttachToWidget(btnGoBack);
|
||||||
|
ctxHelper.AttachToWidget(masterScale);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventPopup (object sender, ContextMenuEventArgs e)
|
||||||
|
{
|
||||||
|
Menu m = Conduite.Courante.EventManager.GetMenu(e.Widget.Name,
|
||||||
|
delegate(object o,string eventId){
|
||||||
|
switch(o as string){
|
||||||
|
case "btnGo":
|
||||||
|
Conduite.Courante.SequenceurMaitre.BindEffetSuivant(eventId);
|
||||||
|
break;
|
||||||
|
case "btnGoBack":
|
||||||
|
Conduite.Courante.SequenceurMaitre.BindEffetPrecedent(eventId);
|
||||||
|
break;
|
||||||
|
case "masterScale":
|
||||||
|
Conduite.Courante.BindMaster(eventId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
m.ShowAll();
|
||||||
|
m.Popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +79,7 @@ namespace DMX2
|
||||||
Gtk.Menu evmenu = new Gtk.Menu ();
|
Gtk.Menu evmenu = new Gtk.Menu ();
|
||||||
evmenuitem.Submenu = evmenu;
|
evmenuitem.Submenu = evmenu;
|
||||||
|
|
||||||
List<string> sortedKeys = new List<string>(eventlist.Keys);
|
List<string> sortedKeys = eventlist.Keys.ToList();
|
||||||
sortedKeys.Sort();
|
sortedKeys.Sort();
|
||||||
|
|
||||||
foreach ( string key in sortedKeys ) {
|
foreach ( string key in sortedKeys ) {
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,7 @@ namespace DMX2
|
||||||
effetChange = true;
|
effetChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnButtonPressedEvent (object o, ButtonPressEventArgs e)
|
void RenamePopup (object sender, ContextMenuEventArgs e)
|
||||||
{
|
|
||||||
if (e.Event.Button == 3) /* right click */
|
|
||||||
{
|
{
|
||||||
Menu m = new Menu();
|
Menu m = new Menu();
|
||||||
MenuItem renameItem = new MenuItem("Renommer le Sequenceur");
|
MenuItem renameItem = new MenuItem("Renommer le Sequenceur");
|
||||||
|
|
@ -30,9 +28,6 @@ namespace DMX2
|
||||||
m.ShowAll();
|
m.ShowAll();
|
||||||
m.Popup();
|
m.Popup();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void OnRenameItemButtonPressed (object o, ButtonPressEventArgs args)
|
void OnRenameItemButtonPressed (object o, ButtonPressEventArgs args)
|
||||||
{
|
{
|
||||||
|
|
@ -56,8 +51,12 @@ namespace DMX2
|
||||||
titreLabel.Text = s.Name;
|
titreLabel.Text = s.Name;
|
||||||
sequenceur = s;
|
sequenceur = s;
|
||||||
|
|
||||||
frame1.ButtonPressEvent += OnButtonPressedEvent;
|
tirettesContextHelper.ContextMenu += TirettePopup;
|
||||||
|
|
||||||
|
new ContextMenuHelper(seqMasterScale,MasterPopup);
|
||||||
|
|
||||||
|
new ContextMenuHelper(evBBox,CompteurPopup);
|
||||||
|
new ContextMenuHelper(frame1,RenamePopup);
|
||||||
|
|
||||||
#region Construction listeEffets
|
#region Construction listeEffets
|
||||||
|
|
||||||
|
|
@ -246,7 +245,7 @@ namespace DMX2
|
||||||
void TirettePopup (object sender, ContextMenuEventArgs e)
|
void TirettePopup (object sender, ContextMenuEventArgs e)
|
||||||
{
|
{
|
||||||
Circuit c = e.Widget.Data[circuitKey] as Circuit;
|
Circuit c = e.Widget.Data[circuitKey] as Circuit;
|
||||||
Menu m = Conduite.Courante.EventManager.GetMenu(c,new EventManagerMenuCallBack(TirettePopupEnd));
|
Menu m = Conduite.Courante.EventManager.GetMenu(c,TirettePopupEnd);
|
||||||
m.ShowAll();
|
m.ShowAll();
|
||||||
m.Popup();
|
m.Popup();
|
||||||
}
|
}
|
||||||
|
|
@ -254,10 +253,47 @@ namespace DMX2
|
||||||
void TirettePopupEnd (object state, string eventId)
|
void TirettePopupEnd (object state, string eventId)
|
||||||
{
|
{
|
||||||
Circuit c = state as Circuit;
|
Circuit c = state as Circuit;
|
||||||
sequenceur.BindEvent(c,eventId);
|
sequenceur.BindCircuitEvent(c,eventId);
|
||||||
Console.WriteLine("{0} bound to {1}", c, eventId );
|
Console.WriteLine("{0} bound to {1}", c, eventId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MasterPopup (object sender, ContextMenuEventArgs e)
|
||||||
|
{
|
||||||
|
Menu m = Conduite.Courante.EventManager.GetMenu(null,
|
||||||
|
delegate(object o,string eventId){
|
||||||
|
sequenceur.BindMasterEvent(eventId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
m.ShowAll();
|
||||||
|
m.Popup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompteurPopup (object sender, ContextMenuEventArgs e)
|
||||||
|
{
|
||||||
|
Menu m = new Menu();
|
||||||
|
|
||||||
|
MenuItem item = new MenuItem("Effet Suivant");
|
||||||
|
m.Add(item);
|
||||||
|
item.Submenu = Conduite.Courante.EventManager.GetMenu(null,
|
||||||
|
delegate(object o,string eventId){
|
||||||
|
sequenceur.BindEffetSuivantEvent(eventId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
item = new MenuItem("Effet Precedent");
|
||||||
|
m.Add(item);
|
||||||
|
item.Submenu = Conduite.Courante.EventManager.GetMenu(null,
|
||||||
|
delegate(object o,string eventId){
|
||||||
|
sequenceur.BindEffetPrecedentEvent(eventId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
m.ShowAll();
|
||||||
|
m.Popup();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Label NouveauLabel ()
|
static Label NouveauLabel ()
|
||||||
{
|
{
|
||||||
Label l = new Label();
|
Label l = new Label();
|
||||||
|
|
@ -275,6 +311,8 @@ namespace DMX2
|
||||||
int lastKnownWidth =0;
|
int lastKnownWidth =0;
|
||||||
object circuitKey = new object();
|
object circuitKey = new object();
|
||||||
|
|
||||||
|
ContextMenuHelper tirettesContextHelper = new ContextMenuHelper();
|
||||||
|
|
||||||
protected void FullUpdate ()
|
protected void FullUpdate ()
|
||||||
{
|
{
|
||||||
fullUpdFlag = true;
|
fullUpdFlag = true;
|
||||||
|
|
@ -303,7 +341,7 @@ namespace DMX2
|
||||||
tirette.Show();
|
tirette.Show();
|
||||||
tirette.ValueChanged += TiretteActionee;
|
tirette.ValueChanged += TiretteActionee;
|
||||||
tirette.Data.Add(circuitKey,c);
|
tirette.Data.Add(circuitKey,c);
|
||||||
new ContextMenuHelper(tirette, new EventHandler<ContextMenuEventArgs>(TirettePopup));
|
tirettesContextHelper.AttachToWidget(tirette);
|
||||||
tirette.TooltipText = c.Name;
|
tirette.TooltipText = c.Name;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -323,8 +361,6 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seqMasterScale.Value = sequenceur.Master;
|
|
||||||
|
|
||||||
posLabel.Text = string.Format("n°{0}",sequenceur.IndexEffetCourrant +1);
|
posLabel.Text = string.Format("n°{0}",sequenceur.IndexEffetCourrant +1);
|
||||||
|
|
||||||
fullUpdFlag=false;
|
fullUpdFlag=false;
|
||||||
|
|
@ -345,14 +381,19 @@ namespace DMX2
|
||||||
foreach (Circuit c in tirettes.Keys) {
|
foreach (Circuit c in tirettes.Keys) {
|
||||||
tirettes[c].Value = sequenceur.ValeurBruteCircuit(c);
|
tirettes[c].Value = sequenceur.ValeurBruteCircuit(c);
|
||||||
string tname;
|
string tname;
|
||||||
if(sequenceur.EstChange(c))
|
if(sequenceur.EstChange(c)){
|
||||||
|
if (sequenceur.EstCapture(c))
|
||||||
|
tname="sclTiretteM";
|
||||||
|
else
|
||||||
tname="sclTiretteC";
|
tname="sclTiretteC";
|
||||||
|
}
|
||||||
else if (sequenceur.EnTransition(c))
|
else if (sequenceur.EnTransition(c))
|
||||||
tname="sclTiretteT";
|
tname="sclTiretteT";
|
||||||
else
|
else
|
||||||
tname="sclTirette";
|
tname="sclTirette";
|
||||||
if (tirettes[c].Name != tname) tirettes[c].Name = tname;
|
if (tirettes[c].Name != tname) tirettes[c].Name = tname;
|
||||||
}
|
}
|
||||||
|
seqMasterScale.Value = sequenceur.Master;
|
||||||
updating=false;
|
updating=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,7 +491,7 @@ namespace DMX2
|
||||||
|
|
||||||
protected void OnSeqMasterScaleValueChanged (object sender, EventArgs e)
|
protected void OnSeqMasterScaleValueChanged (object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (fullUpdFlag)return;
|
if (updating)return;
|
||||||
sequenceur.Master = (int)(seqMasterScale.Value);
|
sequenceur.Master = (int)(seqMasterScale.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
|
|
@ -101,6 +102,39 @@ namespace DMX2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region EventTargets
|
||||||
|
class circuitEventTarget : IEventTarget {
|
||||||
|
Circuit circuit;
|
||||||
|
Dictionary<string,int> valeursrecues= new Dictionary<string, int>();
|
||||||
|
SequenceurLineaire seq;
|
||||||
|
int max=0, signe=-2;
|
||||||
|
|
||||||
|
public bool Attache{ get; set; }
|
||||||
|
|
||||||
|
public circuitEventTarget(SequenceurLineaire _seq, Circuit _c){
|
||||||
|
seq=_seq;
|
||||||
|
circuit=_c;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IEventTarget.FireEvent (EventData data)
|
||||||
|
{
|
||||||
|
valeursrecues[data.id]=data.value;
|
||||||
|
max = valeursrecues.Values.Max();
|
||||||
|
if (!Attache) {
|
||||||
|
int val = seq.ValeurBruteCircuit (circuit);
|
||||||
|
int cs = Math.Sign (val - max);
|
||||||
|
if (signe == -2) signe=cs;
|
||||||
|
if (cs==0 || cs!=signe) Attache=true;
|
||||||
|
else return true ;
|
||||||
|
}
|
||||||
|
seq.ChangeValeur(circuit,max);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
TimeSpan timeStamp = TimeSpan.Zero;
|
TimeSpan timeStamp = TimeSpan.Zero;
|
||||||
TimeSpan tempsTransition = TimeSpan.Zero;
|
TimeSpan tempsTransition = TimeSpan.Zero;
|
||||||
List<Circuit> circuitsSeq = new List<Circuit> ();
|
List<Circuit> circuitsSeq = new List<Circuit> ();
|
||||||
|
|
@ -110,6 +144,12 @@ namespace DMX2
|
||||||
Dictionary<Circuit,int> valeurscourantes = new Dictionary<Circuit, int> ();
|
Dictionary<Circuit,int> valeurscourantes = new Dictionary<Circuit, int> ();
|
||||||
Dictionary<Circuit,int> valeursinitiales = new Dictionary<Circuit, int> ();
|
Dictionary<Circuit,int> valeursinitiales = new Dictionary<Circuit, int> ();
|
||||||
Dictionary<Circuit,bool> valeurschangees = new Dictionary<Circuit, bool> ();
|
Dictionary<Circuit,bool> valeurschangees = new Dictionary<Circuit, bool> ();
|
||||||
|
|
||||||
|
Dictionary<Circuit,circuitEventTarget> targets = new Dictionary<Circuit, circuitEventTarget>();
|
||||||
|
actionEventTarget masterEventTarget=null;
|
||||||
|
actionEventTarget goNextEventTarget=null;
|
||||||
|
actionEventTarget goBackEventTarget=null;
|
||||||
|
|
||||||
SeqLinUI ui = null;
|
SeqLinUI ui = null;
|
||||||
|
|
||||||
int master = 100;
|
int master = 100;
|
||||||
|
|
@ -126,6 +166,28 @@ namespace DMX2
|
||||||
public SequenceurLineaire ()
|
public SequenceurLineaire ()
|
||||||
{
|
{
|
||||||
effetcourrant = new Effet ("",valeurscourantes , TimeSpan.Zero, TimeSpan.Zero);
|
effetcourrant = new Effet ("",valeurscourantes , TimeSpan.Zero, TimeSpan.Zero);
|
||||||
|
|
||||||
|
masterEventTarget = new actionEventTarget (
|
||||||
|
delegate(EventData data) {
|
||||||
|
Master = 100 * data.value / 255;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
goNextEventTarget = new actionEventTarget (
|
||||||
|
delegate(EventData data) {
|
||||||
|
if(data.value>0) IndexEffetCourrant++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
goBackEventTarget = new actionEventTarget (
|
||||||
|
delegate(EventData data) {
|
||||||
|
if(data.value>0) IndexEffetCourrant--;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan TimeStamp {
|
public TimeSpan TimeStamp {
|
||||||
|
|
@ -218,6 +280,13 @@ namespace DMX2
|
||||||
if(!enTransition) return false ;
|
if(!enTransition) return false ;
|
||||||
return valeurscourantes [c] != effetcourrant [c];
|
return valeurscourantes [c] != effetcourrant [c];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool EstCapture (Circuit c)
|
||||||
|
{
|
||||||
|
if(!targets.ContainsKey(c)) return false;
|
||||||
|
return targets[c].Attache;
|
||||||
|
}
|
||||||
|
|
||||||
bool paused=false;
|
bool paused=false;
|
||||||
|
|
||||||
public bool Paused {
|
public bool Paused {
|
||||||
|
|
@ -294,6 +363,7 @@ namespace DMX2
|
||||||
timeStamp = TimeSpan.Zero;
|
timeStamp = TimeSpan.Zero;
|
||||||
if (ui != null)
|
if (ui != null)
|
||||||
ui.EffetChange ();
|
ui.EffetChange ();
|
||||||
|
foreach(var t in targets.Values) t.Attache = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,6 +432,7 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private class circEvTarget : IEventTarget{
|
private class circEvTarget : IEventTarget{
|
||||||
Circuit c; SequenceurLineaire seq; int s=-2; bool ok=false;
|
Circuit c; SequenceurLineaire seq; int s=-2; bool ok=false;
|
||||||
public circEvTarget(SequenceurLineaire _seq, Circuit _c){
|
public circEvTarget(SequenceurLineaire _seq, Circuit _c){
|
||||||
|
|
@ -384,12 +455,50 @@ namespace DMX2
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void BindEvent (Circuit c, string eventId)
|
public void BindCircuitEvent (Circuit c, string eventId)
|
||||||
{
|
{
|
||||||
// TODO : plein de trucs
|
|
||||||
|
|
||||||
Conduite.Courante.EventManager.Bind(eventId,new circEvTarget(this,c));
|
if (eventId.Length == 0) {
|
||||||
|
if(!targets.ContainsKey(c)) return;
|
||||||
|
Conduite.Courante.EventManager.Unbind(targets[c]);
|
||||||
|
targets.Remove(c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!targets.ContainsKey(c)) targets[c]=new circuitEventTarget(this,c);
|
||||||
|
Conduite.Courante.EventManager.Bind(eventId,targets[c]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void BindMasterEvent (string eventId)
|
||||||
|
{
|
||||||
|
if(eventId.Length==0)
|
||||||
|
{
|
||||||
|
Conduite.Courante.EventManager.Unbind(masterEventTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Conduite.Courante.EventManager.Bind(eventId,masterEventTarget);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindEffetSuivantEvent (string eventId)
|
||||||
|
{
|
||||||
|
if (eventId.Length == 0) {
|
||||||
|
Conduite.Courante.EventManager.Unbind (goNextEventTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Conduite.Courante.EventManager.Bind(eventId,goNextEventTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindEffetPrecedentEvent (string eventId)
|
||||||
|
{
|
||||||
|
if (eventId.Length == 0) {
|
||||||
|
Conduite.Courante.EventManager.Unbind (goBackEventTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Conduite.Courante.EventManager.Bind(eventId,goBackEventTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Save (System.Xml.XmlElement parent)
|
public override void Save (System.Xml.XmlElement parent)
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,6 @@ namespace DMX2
|
||||||
this.moveDownAction.Activated += new global::System.EventHandler (this.OnMoveDownActionActivated);
|
this.moveDownAction.Activated += new global::System.EventHandler (this.OnMoveDownActionActivated);
|
||||||
this.circuitsAction.Activated += new global::System.EventHandler (this.OnCircuitsActionActivated);
|
this.circuitsAction.Activated += new global::System.EventHandler (this.OnCircuitsActionActivated);
|
||||||
this.closeAction.Activated += new global::System.EventHandler (this.OnCloseActionActivated);
|
this.closeAction.Activated += new global::System.EventHandler (this.OnCloseActionActivated);
|
||||||
this.seqMasterScale.ValueChanged += new global::System.EventHandler (this.OnSeqMasterScaleValueChanged);
|
|
||||||
this.zoneWid.SizeAllocated += new global::Gtk.SizeAllocatedHandler (this.OnZoneWidSizeAllocated);
|
this.zoneWid.SizeAllocated += new global::Gtk.SizeAllocatedHandler (this.OnZoneWidSizeAllocated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -817,7 +817,6 @@ au sequenceur</property>
|
||||||
<property name="DrawValue">True</property>
|
<property name="DrawValue">True</property>
|
||||||
<property name="Digits">0</property>
|
<property name="Digits">0</property>
|
||||||
<property name="ValuePos">Right</property>
|
<property name="ValuePos">Right</property>
|
||||||
<signal name="ValueChanged" handler="OnSeqMasterScaleValueChanged" />
|
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="Position">1</property>
|
<property name="Position">1</property>
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,15 @@ style "tirettest" {
|
||||||
fg[NORMAL] = "#50FF50"
|
fg[NORMAL] = "#50FF50"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
style "tirettesm" {
|
||||||
|
GtkScale::slider-width = 19
|
||||||
|
GtkScale::slider-length = 28
|
||||||
|
bg[NORMAL] = "#6070B0"
|
||||||
|
bg[PRELIGHT] = "#B06060"
|
||||||
|
bg[SELECTED] = "#DAC000"
|
||||||
|
fg[NORMAL] = "#8080FF"
|
||||||
|
}
|
||||||
|
|
||||||
style "progressbar" {
|
style "progressbar" {
|
||||||
bg[SELECTED] = "#A8A8B8"
|
bg[SELECTED] = "#A8A8B8"
|
||||||
}
|
}
|
||||||
|
|
@ -92,3 +101,4 @@ widget "*.lblTirette" style "lbtirette"
|
||||||
widget "*.sclTirette" style "tirettes"
|
widget "*.sclTirette" style "tirettes"
|
||||||
widget "*.sclTiretteC" style "tirettesc"
|
widget "*.sclTiretteC" style "tirettesc"
|
||||||
widget "*.sclTiretteT" style "tirettest"
|
widget "*.sclTiretteT" style "tirettest"
|
||||||
|
widget "*.sclTiretteM" style "tirettesm"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue