Renommage des Sequenceurs

Lancement des Effets depuis sequenceur Maitre
This commit is contained in:
tzim 2013-10-13 16:08:26 +00:00
parent a7d6aa210f
commit 9775cd0bbe
9 changed files with 225 additions and 55 deletions

View file

@ -119,9 +119,15 @@ namespace DMX2
{ {
lock (this) { lock (this) {
sequenceurs.Add(seq); sequenceurs.Add(seq);
seq.Renamed += SequenceurRenomme;
} }
} }
void SequenceurRenomme (object sender, Sequenceur.SeqRenamedEventArgs e)
{
MainWindow.Win.NextUpdateFull();
}
public Sequenceur GetSeqByID (int i) public Sequenceur GetSeqByID (int i)
{ {
foreach(Sequenceur seq in sequenceurs) foreach(Sequenceur seq in sequenceurs)
@ -148,6 +154,9 @@ namespace DMX2
TimeSpan deltaT = tickTime - dernierTick; TimeSpan deltaT = tickTime - dernierTick;
dernierTick = tickTime; dernierTick = tickTime;
if( deltaT > TimeSpan.FromMilliseconds(15) )
Console.WriteLine ("{0}", deltaT);
lock (this) { lock (this) {
seqmaitre.Tick(deltaT); seqmaitre.Tick(deltaT);
@ -173,9 +182,6 @@ namespace DMX2
derniereMaj = DateTime.Now; derniereMaj = DateTime.Now;
} }
if( deltaT > TimeSpan.FromMilliseconds(15) )
Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,deltaT);
} }
#region IDisposable implementation #region IDisposable implementation
@ -260,8 +266,10 @@ namespace DMX2
foreach (var xs in root["Sequenceurs"].ChildNodes) { foreach (var xs in root["Sequenceurs"].ChildNodes) {
Sequenceur s = Sequenceur.Load (this, xs as XmlElement); Sequenceur s = Sequenceur.Load (this, xs as XmlElement);
if (s != null) if (s != null){
sequenceurs.Add (s); sequenceurs.Add (s);
s.Renamed += SequenceurRenomme;
}
} }
univers.Clear(); univers.Clear();

View file

@ -58,8 +58,6 @@ namespace DMX2
dureeCell.Edited += OnDureeCellEdited; dureeCell.Edited += OnDureeCellEdited;
this.MatriceUI.AppendColumn (dureeCol); this.MatriceUI.AppendColumn (dureeCol);
ConstruitMatriceSeqColumns();
lsMatrice = new Gtk.ListStore(typeof (SequenceurMaitre.Ligne)); lsMatrice = new Gtk.ListStore(typeof (SequenceurMaitre.Ligne));
this.MatriceUI.Model = lsMatrice; this.MatriceUI.Model = lsMatrice;
FillMatrice(); FillMatrice();
@ -194,7 +192,7 @@ namespace DMX2
int pos=IndexEffetSelectionne() + 1; int pos=IndexEffetSelectionne() + 1;
Conduite.Courante.SequenceurMaitre.AjoutLigne(pos); Conduite.Courante.SequenceurMaitre.AjoutLigne(pos);
FillMatrice(); FillMatrice();
SelectionneEffet(pos); MatriceUI.SetCursor( new TreePath( new int[1] {pos }) , MatriceUI.Columns[1] ,true);
} }
protected void OnBtnRetireLigneClicked (object sender, EventArgs e) protected void OnBtnRetireLigneClicked (object sender, EventArgs e)
@ -407,33 +405,22 @@ namespace DMX2
Sequenceur s = new SequenceurLineaire(); Sequenceur s = new SequenceurLineaire();
Conduite.Courante.AjoutSequenceur(s); Conduite.Courante.AjoutSequenceur(s);
AddSeqUI(s); AddSeqUI(s);
ConstruitMatriceSeqColumns(); NextUpdateFull();
} }
void AddSeqUI (Sequenceur s) void AddSeqUI (Sequenceur s)
{ {
VBox newvbox = new VBox(); onglets.AppendPage(s.GetUI(),new Gtk.Label(s.Name));
newvbox.PackStart(s.GetUI(),false,false,0);
Widget label = new Gtk.Label(s.Name);
//onglets.Add (newvbox);
onglets.AppendPage(newvbox,label);
onglets.ShowAll(); onglets.ShowAll();
} }
protected void OnShowAllActionActivated (object sender, EventArgs e) protected void OnShowAllActionActivated (object sender, EventArgs e)
{ {
foreach (var notebookvbox in onglets.Children) foreach (var notebookchild in onglets.Children)
notebookvbox.Destroy(); notebookchild.Destroy();
foreach (Sequenceur s in Conduite.Courante.Sequenceurs) foreach (Sequenceur s in Conduite.Courante.Sequenceurs)
AddSeqUI(s); AddSeqUI(s);
/*{
VBox newvbox = new VBox();
newvbox.PackStart(s.GetUI(),false,false,0);
onglets.Add (newvbox);
onglets.ShowAll();
}*/
} }
#endregion #endregion
@ -462,15 +449,16 @@ namespace DMX2
void Update (object sender, EventArgs e) void Update (object sender, EventArgs e)
{ {
foreach (var notebookvbox in onglets.Children) { if(Conduite.Courante==null)return;
foreach (var sequi in (notebookvbox as VBox).Children) { foreach (var notebookchild in onglets.Children) {
(sequi as SequenceurUI).Update (fullUpdateFlag); SequenceurUI sequi = notebookchild as SequenceurUI;
} if(sequi != null) sequi.Update(fullUpdateFlag);
} }
MajCircuits(fullUpdateFlag); MajCircuits(fullUpdateFlag);
if(fullUpdateFlag) ConstruitMatriceSeqColumns();
if( Conduite.Courante.SequenceurMaitre.EffetChange() )MatriceUI.QueueDraw();
fullUpdateFlag=false; fullUpdateFlag=false;
updScheduled=false; updScheduled=false;
if( Conduite.Courante.SequenceurMaitre.EffetChange() )MatriceUI.QueueDraw();
} }
protected void MajWidgets () protected void MajWidgets ()
@ -492,6 +480,10 @@ namespace DMX2
openAction.Sensitive = newAction.Sensitive = true; openAction.Sensitive = newAction.Sensitive = true;
this.Title = "DMX 2.0"; this.Title = "DMX 2.0";
DetruitMatrice(); DetruitMatrice();
foreach (var widget in vboxCircuits.Children)
vboxCircuits.Remove (widget);
foreach (var notebookvbox in onglets.Children)
notebookvbox.Destroy();
} }
} }

View file

@ -19,13 +19,46 @@ namespace DMX2
effetChange = true; 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) public SeqLinUI (SequenceurLineaire s ) : base (s)
{ {
this.Build (); this.Build ();
titreLabel.Text = s.Name; titreLabel.Text = s.Name;
sequenceur = s; sequenceur = s;
frame1.ButtonPressEvent += OnButtonPressedEvent;
#region Construction listeEffets #region Construction listeEffets
// Construction de la liste d'effets // Construction de la liste d'effets
var numCol = new TreeViewColumn(); var numCol = new TreeViewColumn();
nomCol = new TreeViewColumn(); nomCol = new TreeViewColumn();
@ -80,6 +113,7 @@ namespace DMX2
} }
void EditNom (object o, EditedArgs args) void EditNom (object o, EditedArgs args)
{ {
Gtk.TreeIter iter; Gtk.TreeIter iter;
@ -185,7 +219,7 @@ namespace DMX2
protected void OnCloseActionActivated (object sender, EventArgs e) protected void OnCloseActionActivated (object sender, EventArgs e)
{ {
this.Parent.Destroy(); this.Destroy();
} }
@ -385,8 +419,11 @@ namespace DMX2
{ {
if (fullUpdFlag)return; if (fullUpdFlag)return;
sequenceur.Master = (int)(seqMasterScale.Value); sequenceur.Master = (int)(seqMasterScale.Value);
} }
} }
} }

View file

@ -42,9 +42,22 @@ namespace DMX2
} }
set { set {
name = value; 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<SeqRenamedEventArgs> Renamed;
public abstract SequenceurUI GetUI(); public abstract SequenceurUI GetUI();
public abstract int ValeurCircuit(Circuit c); public abstract int ValeurCircuit(Circuit c);

View file

@ -11,7 +11,6 @@ namespace DMX2
string _nom; string _nom;
public Effet (string nom, Dictionary<Circuit,int> valeurs, TimeSpan duree, TimeSpan transition) public Effet (string nom, Dictionary<Circuit,int> valeurs, TimeSpan duree, TimeSpan transition)
{ {
_nom = nom; _nom = nom;
@ -302,6 +301,7 @@ namespace DMX2
int pos = index+1; int pos = index+1;
if (pos >= effets.Count) return SauveEffet(nom,duree,transition); if (pos >= effets.Count) return SauveEffet(nom,duree,transition);
effets.Insert (pos,effetcourrant = new Effet (nom, valeurscourantes, duree, transition)); effets.Insert (pos,effetcourrant = new Effet (nom, valeurscourantes, duree, transition));
CommandAdd(index);
return pos; return pos;
} }
} }
@ -317,26 +317,37 @@ namespace DMX2
public void SupprimeEffet (int index) public void SupprimeEffet (int index)
{ {
lock (this) {
effets.RemoveAt (index); effets.RemoveAt (index);
CommandRemove(index);
}
} }
public int MonteEffet (int index) public int MonteEffet (int index)
{ {
if(index>= effets.Count || index < 1 ) return index; lock (this) {
if (index >= effets.Count || index < 1)
return index;
Effet ef = effets [index]; Effet ef = effets [index];
effets.RemoveAt (index); effets.RemoveAt (index);
effets.Insert (index - 1, ef); effets.Insert (index - 1, ef);
CommandSwap (index - 1);
return index - 1; return index - 1;
} }
}
public int BaisseEffet (int index) public int BaisseEffet (int index)
{ {
if(index> effets.Count-2 || index <0) return index; lock (this) {
if (index > effets.Count - 2 || index < 0)
return index;
Effet ef = effets [index]; Effet ef = effets [index];
effets.RemoveAt (index); effets.RemoveAt (index);
effets.Insert (index + 1, ef); effets.Insert (index + 1, ef);
CommandSwap(index);
return index + 1; return index + 1;
} }
}
public override void Save (System.Xml.XmlElement parent) public override void Save (System.Xml.XmlElement parent)
{ {
@ -400,10 +411,18 @@ namespace DMX2
effets.Add(Effet.Load(conduite,xe as System.Xml.XmlElement)); effets.Add(Effet.Load(conduite,xe as System.Xml.XmlElement));
} }
static System.Text.RegularExpressions.Regex regexCommand1 = new System.Text.RegularExpressions.Regex(
@"(?<effet>\d+)(t(?<transition>\d+))?",
System.Text.RegularExpressions.RegexOptions.Compiled);
static System.Text.RegularExpressions.Regex regexCommand2 = new System.Text.RegularExpressions.Regex(
@"(?<effet>\d+)(?<params>(t\d+)?)?",
System.Text.RegularExpressions.RegexOptions.Compiled);
public override void Command (string command) public override void Command (string command)
{ {
lock (this) { lock (this) {
var cmd = System.Text.RegularExpressions.Regex.Match (command, @"(?<effet>\d+)(t(?<transition>\d+))?"); var cmd = regexCommand1.Match(command);
if (cmd.Success) { if (cmd.Success) {
if (cmd.Groups ["effet"].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);
}
}
} }
} }

View file

@ -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<Ligne> Lignes { public ReadOnlyCollection<Ligne> Lignes {
get { get {

View file

@ -288,7 +288,7 @@ namespace DMX2
w64.Fill = false; w64.Fill = false;
// Container child vbox2.Gtk.Box+BoxChild // Container child vbox2.Gtk.Box+BoxChild
this.masterScale = new global::Gtk.VScale (null); this.masterScale = new global::Gtk.VScale (null);
this.masterScale.HeightRequest = 260; this.masterScale.HeightRequest = 150;
this.masterScale.Name = "masterScale"; this.masterScale.Name = "masterScale";
this.masterScale.Inverted = true; this.masterScale.Inverted = true;
this.masterScale.Adjustment.Upper = 100; this.masterScale.Adjustment.Upper = 100;

View file

@ -33,6 +33,7 @@ namespace DMX2
private global::Gtk.ScrolledWindow GtkScrolledWindow; private global::Gtk.ScrolledWindow GtkScrolledWindow;
private global::Gtk.TreeView effetsListe; private global::Gtk.TreeView effetsListe;
private global::Gtk.Toolbar toolbar3; private global::Gtk.Toolbar toolbar3;
private global::Gtk.ScrolledWindow GtkScrolledWindow1;
private global::Gtk.Fixed zoneWid; private global::Gtk.Fixed zoneWid;
private global::Gtk.Label titreLabel; private global::Gtk.Label titreLabel;
@ -217,15 +218,21 @@ namespace DMX2
w15.Expand = false; w15.Expand = false;
w15.Fill = false; w15.Fill = false;
// Container child vbox2.Gtk.Box+BoxChild // 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 = new global::Gtk.Fixed ();
this.zoneWid.HeightRequest = 0; this.zoneWid.HeightRequest = 0;
this.zoneWid.Name = "zoneWid"; this.zoneWid.Name = "zoneWid";
this.zoneWid.HasWindow = false; this.zoneWid.HasWindow = false;
this.vbox2.Add (this.zoneWid); w16.Add (this.zoneWid);
global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.zoneWid])); this.GtkScrolledWindow1.Add (w16);
w16.Position = 1; this.vbox2.Add (this.GtkScrolledWindow1);
w16.Expand = false; global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.GtkScrolledWindow1]));
w16.Fill = false; w19.Position = 1;
this.GtkAlignment.Add (this.vbox2); this.GtkAlignment.Add (this.vbox2);
this.frame1.Add (this.GtkAlignment); this.frame1.Add (this.GtkAlignment);
this.titreLabel = new global::Gtk.Label (); this.titreLabel = new global::Gtk.Label ();

View file

@ -307,7 +307,7 @@
<child> <child>
<widget class="Gtk.VScale" id="masterScale"> <widget class="Gtk.VScale" id="masterScale">
<property name="MemberName" /> <property name="MemberName" />
<property name="HeightRequest">260</property> <property name="HeightRequest">150</property>
<property name="Inverted">True</property> <property name="Inverted">True</property>
<property name="Upper">100</property> <property name="Upper">100</property>
<property name="PageIncrement">10</property> <property name="PageIncrement">10</property>
@ -892,18 +892,28 @@
<property name="Fill">False</property> <property name="Fill">False</property>
</packing> </packing>
</child> </child>
<child>
<widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow1">
<property name="MemberName" />
<child>
<widget class="Gtk.Viewport" id="GtkViewport">
<property name="MemberName" />
<property name="ShadowType">None</property>
<child> <child>
<widget class="Gtk.Fixed" id="zoneWid"> <widget class="Gtk.Fixed" id="zoneWid">
<property name="MemberName" /> <property name="MemberName" />
<property name="HeightRequest">0</property> <property name="HeightRequest">0</property>
<property name="ShowScrollbars">True</property>
<property name="HasWindow">False</property> <property name="HasWindow">False</property>
<signal name="SizeAllocated" handler="OnZoneWidSizeAllocated" /> <signal name="SizeAllocated" handler="OnZoneWidSizeAllocated" />
</widget> </widget>
</child>
</widget>
</child>
</widget>
<packing> <packing>
<property name="Position">1</property> <property name="Position">1</property>
<property name="AutoSize">True</property> <property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing> </packing>
</child> </child>
</widget> </widget>