Reorganisation du code de la MainWindow
Ajout d'un peu de locking Ajout du n° d'effet courrant sur SeqUI
This commit is contained in:
parent
addc975f83
commit
ab06a57225
4 changed files with 265 additions and 229 deletions
|
|
@ -25,43 +25,8 @@ namespace DMX2
|
|||
MajWidgets();
|
||||
}
|
||||
|
||||
protected void MajWidgets ()
|
||||
{
|
||||
if (Conduite.Courante != null) {
|
||||
//Activation / Désactivation des boutons en fonction de l'état de la counduite courante
|
||||
showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = true;
|
||||
openAction.Sensitive = newAction.Sensitive = false;
|
||||
this.Title = "DMX 2.0 - " + Conduite.Courante.Name;
|
||||
ConstruitMatrice();
|
||||
} else {
|
||||
showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = false;
|
||||
openAction.Sensitive = newAction.Sensitive = true;
|
||||
this.Title = "DMX 2.0";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void MajCircuits (bool full)
|
||||
{
|
||||
// Ajoute une ProgressBar par circuit, met a jour le texte si necessaire
|
||||
ProgressBar pb;int i = 0;
|
||||
if (full) {
|
||||
foreach (var widget in vboxCircuits.Children)
|
||||
vboxCircuits.Remove (widget);
|
||||
foreach (var circuit in Conduite.Courante.Circuits) {
|
||||
vboxCircuits.PackStart (pb=new ProgressBar (),false,false,0);
|
||||
pb.Text = (++i).ToString() + " - " + circuit.Name;
|
||||
pb.HeightRequest = 22;
|
||||
pb.Data[circuitKey] = circuit;
|
||||
}
|
||||
vboxCircuits.ShowAll ();
|
||||
}
|
||||
|
||||
foreach (var widget in vboxCircuits.Children) {
|
||||
pb = (ProgressBar)widget;
|
||||
pb.Fraction = (double) (pb.Data[circuitKey] as Circuit).ValeurCourante / 255;
|
||||
}
|
||||
}
|
||||
#region Sequenceur Maitre
|
||||
|
||||
protected void ConstruitMatrice ()
|
||||
{
|
||||
|
|
@ -100,6 +65,7 @@ namespace DMX2
|
|||
|
||||
static object seqkey = new object();
|
||||
|
||||
|
||||
void ConstruitMatriceSeqColumns ()
|
||||
{
|
||||
|
||||
|
|
@ -196,6 +162,67 @@ namespace DMX2
|
|||
SequenceurMaitre.Ligne l = lsMatrice.GetValue(iter,0) as SequenceurMaitre.Ligne;
|
||||
l[seq] = args.NewText;
|
||||
}
|
||||
|
||||
int IndexEffetSelectionne()
|
||||
{
|
||||
var sel = MatriceUI.Selection.GetSelectedRows();
|
||||
if(sel.Length ==0) return -1;
|
||||
return MatriceUI.Selection.GetSelectedRows()[0].Indices[0];
|
||||
}
|
||||
|
||||
void SelectionneEffet (int index)
|
||||
{
|
||||
if(index <0 ) return;
|
||||
MatriceUI.SetCursor( new TreePath( new int[1] {index }) ,null,false);
|
||||
}
|
||||
|
||||
protected void OnBtnAjoutLigneClicked (object sender, EventArgs e)
|
||||
{
|
||||
int pos=IndexEffetSelectionne() + 1;
|
||||
Conduite.Courante.SequenceurMaitre.AjoutLigne(pos);
|
||||
FillMatrice();
|
||||
SelectionneEffet(pos);
|
||||
}
|
||||
void OnMatriceNumColClicked (object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void OnBtnRetireLigneClicked (object sender, EventArgs e)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
protected void OnBtnGoBackClicked (object sender, EventArgs e)
|
||||
{
|
||||
Conduite.Courante.SequenceurMaitre.EffetPrecedent();
|
||||
//FillMatrice();
|
||||
}
|
||||
|
||||
protected void OnBtnGoClicked (object sender, EventArgs e)
|
||||
{
|
||||
Conduite.Courante.SequenceurMaitre.EffetSuivant();
|
||||
//FillMatrice();
|
||||
}
|
||||
|
||||
protected void OnMatriceUICursorChanged (object sender, EventArgs e)
|
||||
{
|
||||
TreeViewColumn col;
|
||||
TreePath path;
|
||||
MatriceUI.GetCursor (out path, out col);
|
||||
|
||||
if (MatriceUI.Columns [0] == col) {
|
||||
Conduite.Courante.SequenceurMaitre.IndexLigneaSuivre = IndexEffetSelectionne();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Application
|
||||
|
||||
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
|
||||
{
|
||||
Application.Quit ();
|
||||
|
|
@ -206,13 +233,9 @@ namespace DMX2
|
|||
Application.Quit ();
|
||||
}
|
||||
|
||||
protected void OnCircuitsActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
GestionCircuits gc= new GestionCircuits(this);
|
||||
gc.Run();
|
||||
gc.Destroy();
|
||||
NextUpdateFull();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Gestion de la Conduite
|
||||
|
||||
protected void OnNewActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -230,8 +253,6 @@ namespace DMX2
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void OnCloseActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
Conduite.Courante.Dispose();
|
||||
|
|
@ -239,115 +260,6 @@ namespace DMX2
|
|||
MajWidgets();
|
||||
}
|
||||
|
||||
// bonton ajout de sequenceur linéraire
|
||||
protected void OnSeqLinActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
Sequenceur s = new SequenceurLineaire();
|
||||
Conduite.Courante.AjoutSequenceur(s);
|
||||
AddSeqUI(s);
|
||||
ConstruitMatriceSeqColumns();
|
||||
}
|
||||
|
||||
void AddSeqUI (Sequenceur s)
|
||||
{
|
||||
VBox newvbox = new VBox();
|
||||
newvbox.PackStart(s.GetUI(),false,false,0);
|
||||
onglets.Add (newvbox);
|
||||
onglets.ShowAll();
|
||||
}
|
||||
|
||||
|
||||
bool updScheduled=false;
|
||||
bool fullUpdateFlag=false;
|
||||
|
||||
public void NextUpdateFull ()
|
||||
{
|
||||
fullUpdateFlag=true;
|
||||
}
|
||||
|
||||
|
||||
public void ScheduleUpdate ()
|
||||
{
|
||||
if (updScheduled) {
|
||||
//Console.WriteLine("{0} Skip !",DateTime.Now);
|
||||
return;
|
||||
}
|
||||
updScheduled=true;
|
||||
Gtk.Application.Invoke(new EventHandler(Update));
|
||||
|
||||
}
|
||||
|
||||
void Update (object sender, EventArgs e)
|
||||
{
|
||||
foreach (var notebookvbox in onglets.Children) {
|
||||
foreach (var sequi in (notebookvbox as VBox).Children) {
|
||||
(sequi as SequenceurUI).Update (fullUpdateFlag);
|
||||
}
|
||||
}
|
||||
MajCircuits(fullUpdateFlag);
|
||||
fullUpdateFlag=false;
|
||||
updScheduled=false;
|
||||
if( Conduite.Courante.SequenceurMaitre.EffetChange() )MatriceUI.QueueDraw();
|
||||
}
|
||||
|
||||
protected void OnMasterScaleValueChanged (object sender, EventArgs e)
|
||||
{
|
||||
Conduite.Courante.Master = (int)(masterScale.Value);
|
||||
}
|
||||
|
||||
|
||||
bool isfullscreen=false;
|
||||
protected void OnFullscreenAction1Activated (object sender, EventArgs e)
|
||||
{
|
||||
if (!isfullscreen) {
|
||||
Fullscreen ();
|
||||
isfullscreen = true;
|
||||
} else {
|
||||
Unfullscreen();
|
||||
isfullscreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
EditionUnivers uDlg = null;
|
||||
protected void OnUniversActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (uDlg != null) {
|
||||
uDlg.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
uDlg = new EditionUnivers(this);
|
||||
uDlg.ShowAll();
|
||||
uDlg.Destroyed += udlgDestroyed;
|
||||
|
||||
}
|
||||
|
||||
void udlgDestroyed (object sender, EventArgs e)
|
||||
{
|
||||
uDlg=null;
|
||||
}
|
||||
|
||||
protected void OnShowAllActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
foreach (var notebookvbox in onglets.Children)
|
||||
notebookvbox.Destroy();
|
||||
|
||||
foreach (Sequenceur s in Conduite.Courante.Sequenceurs) {
|
||||
VBox newvbox = new VBox();
|
||||
newvbox.PackStart(s.GetUI(),false,false,0);
|
||||
onglets.Add (newvbox);
|
||||
onglets.ShowAll();
|
||||
}
|
||||
|
||||
}
|
||||
protected void OnConnectActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Conduite.Courante.Drivers.Add( new DriverBoitierV1());
|
||||
|
||||
}
|
||||
|
||||
protected void OnSaveActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
if(conduiteFile==null)
|
||||
|
|
@ -467,70 +379,180 @@ namespace DMX2
|
|||
NextUpdateFull();
|
||||
}
|
||||
|
||||
int IndexEffetSelectionne()
|
||||
#endregion
|
||||
|
||||
#region Gestion des Circuits
|
||||
|
||||
protected void OnCircuitsActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
var sel = MatriceUI.Selection.GetSelectedRows();
|
||||
if(sel.Length ==0) return -1;
|
||||
return MatriceUI.Selection.GetSelectedRows()[0].Indices[0];
|
||||
GestionCircuits gc= new GestionCircuits(this);
|
||||
gc.Run();
|
||||
gc.Destroy();
|
||||
NextUpdateFull();
|
||||
}
|
||||
|
||||
void SelectionneEffet (int index)
|
||||
#endregion
|
||||
|
||||
#region Gestion des Sequenceurs
|
||||
|
||||
// bonton ajout de sequenceur linéraire
|
||||
protected void OnSeqLinActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
if(index <0 ) return;
|
||||
MatriceUI.SetCursor( new TreePath( new int[1] {index }) ,null,false);
|
||||
Sequenceur s = new SequenceurLineaire();
|
||||
Conduite.Courante.AjoutSequenceur(s);
|
||||
AddSeqUI(s);
|
||||
ConstruitMatriceSeqColumns();
|
||||
}
|
||||
|
||||
protected void OnBtnAjoutLigneClicked (object sender, EventArgs e)
|
||||
void AddSeqUI (Sequenceur s)
|
||||
{
|
||||
int pos=IndexEffetSelectionne() + 1;
|
||||
Conduite.Courante.SequenceurMaitre.AjoutLigne(pos);
|
||||
FillMatrice();
|
||||
SelectionneEffet(pos);
|
||||
VBox newvbox = new VBox();
|
||||
newvbox.PackStart(s.GetUI(),false,false,0);
|
||||
onglets.Add (newvbox);
|
||||
onglets.ShowAll();
|
||||
}
|
||||
void OnMatriceNumColClicked (object sender, EventArgs e)
|
||||
|
||||
protected void OnShowAllActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
foreach (var notebookvbox in onglets.Children)
|
||||
notebookvbox.Destroy();
|
||||
|
||||
foreach (Sequenceur s in Conduite.Courante.Sequenceurs) {
|
||||
VBox newvbox = new VBox();
|
||||
newvbox.PackStart(s.GetUI(),false,false,0);
|
||||
onglets.Add (newvbox);
|
||||
onglets.ShowAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void OnBtnRetireLigneClicked (object sender, EventArgs e)
|
||||
#region Gestion de l'affichage
|
||||
|
||||
bool updScheduled=false;
|
||||
bool fullUpdateFlag=false;
|
||||
|
||||
public void NextUpdateFull ()
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
fullUpdateFlag=true;
|
||||
}
|
||||
|
||||
protected void OnBtnGoBackClicked (object sender, EventArgs e)
|
||||
|
||||
public void ScheduleUpdate ()
|
||||
{
|
||||
Conduite.Courante.SequenceurMaitre.EffetPrecedent();
|
||||
//FillMatrice();
|
||||
if (updScheduled) {
|
||||
//Console.WriteLine("{0} Skip !",DateTime.Now);
|
||||
return;
|
||||
}
|
||||
updScheduled=true;
|
||||
Gtk.Application.Invoke(new EventHandler(Update));
|
||||
|
||||
}
|
||||
|
||||
protected void OnBtnGoClicked (object sender, EventArgs e)
|
||||
void Update (object sender, EventArgs e)
|
||||
{
|
||||
Conduite.Courante.SequenceurMaitre.EffetSuivant();
|
||||
//FillMatrice();
|
||||
foreach (var notebookvbox in onglets.Children) {
|
||||
foreach (var sequi in (notebookvbox as VBox).Children) {
|
||||
(sequi as SequenceurUI).Update (fullUpdateFlag);
|
||||
}
|
||||
}
|
||||
MajCircuits(fullUpdateFlag);
|
||||
fullUpdateFlag=false;
|
||||
updScheduled=false;
|
||||
if( Conduite.Courante.SequenceurMaitre.EffetChange() )MatriceUI.QueueDraw();
|
||||
}
|
||||
|
||||
protected void OnMatriceUICursorChanged (object sender, EventArgs e)
|
||||
protected void MajWidgets ()
|
||||
{
|
||||
TreeViewColumn col;
|
||||
TreePath path;
|
||||
MatriceUI.GetCursor (out path, out col);
|
||||
|
||||
if (MatriceUI.Columns [0] == col) {
|
||||
Conduite.Courante.SequenceurMaitre.IndexLigneaSuivre = IndexEffetSelectionne();
|
||||
if (Conduite.Courante != null) {
|
||||
//Activation / Désactivation des boutons en fonction de l'état de la counduite courante
|
||||
showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = true;
|
||||
openAction.Sensitive = newAction.Sensitive = false;
|
||||
this.Title = "DMX 2.0 - " + Conduite.Courante.Name;
|
||||
ConstruitMatrice();
|
||||
} else {
|
||||
showAllAction.Sensitive = universAction.Sensitive = masterScale.Sensitive = seqLinAction.Sensitive = circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = false;
|
||||
openAction.Sensitive = newAction.Sensitive = true;
|
||||
this.Title = "DMX 2.0";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void MajCircuits (bool full)
|
||||
{
|
||||
// Ajoute une ProgressBar par circuit, met a jour le texte si necessaire
|
||||
ProgressBar pb;int i = 0;
|
||||
if (full) {
|
||||
foreach (var widget in vboxCircuits.Children)
|
||||
vboxCircuits.Remove (widget);
|
||||
foreach (var circuit in Conduite.Courante.Circuits) {
|
||||
vboxCircuits.PackStart (pb=new ProgressBar (),false,false,0);
|
||||
pb.Text = (++i).ToString() + " - " + circuit.Name;
|
||||
pb.HeightRequest = 22;
|
||||
pb.Data[circuitKey] = circuit;
|
||||
}
|
||||
vboxCircuits.ShowAll ();
|
||||
}
|
||||
|
||||
foreach (var widget in vboxCircuits.Children) {
|
||||
pb = (ProgressBar)widget;
|
||||
pb.Fraction = (double) (pb.Data[circuitKey] as Circuit).ValeurCourante / 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
protected void OnMasterScaleValueChanged (object sender, EventArgs e)
|
||||
{
|
||||
Conduite.Courante.Master = (int)(masterScale.Value);
|
||||
}
|
||||
|
||||
|
||||
bool isfullscreen=false;
|
||||
protected void OnFullscreenAction1Activated (object sender, EventArgs e)
|
||||
{
|
||||
if (!isfullscreen) {
|
||||
Fullscreen ();
|
||||
isfullscreen = true;
|
||||
} else {
|
||||
Unfullscreen();
|
||||
isfullscreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
#region Boite dialogue Univers
|
||||
|
||||
EditionUnivers uDlg = null;
|
||||
protected void OnUniversActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (uDlg != null) {
|
||||
uDlg.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
uDlg = new EditionUnivers(this);
|
||||
uDlg.ShowAll();
|
||||
uDlg.Destroyed += udlgDestroyed;
|
||||
|
||||
}
|
||||
|
||||
void udlgDestroyed (object sender, EventArgs e)
|
||||
{
|
||||
uDlg=null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void OnConnectActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Conduite.Courante.Drivers.Add( new DriverBoitierV1());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +143,8 @@ namespace DMX2
|
|||
|
||||
public override void Update (bool full)
|
||||
{
|
||||
if(fullUpdFlag || full) FullUpdate();
|
||||
if (fullUpdFlag || full)
|
||||
FullUpdate ();
|
||||
UpdateValues ();
|
||||
timeLabel.LabelProp = string.Format (@"<big>{0:0\.0}</big>", sequenceur.TimeStamp.TotalMilliseconds / 100);
|
||||
|
||||
|
|
@ -157,8 +158,10 @@ namespace DMX2
|
|||
else
|
||||
pbTrans.Fraction = 0.0d;
|
||||
|
||||
if (effetChange)
|
||||
if (effetChange) {
|
||||
SelectionneEffet (sequenceur.IndexEffetCourrant);
|
||||
posLabel.Text = string.Format("n°{0}",sequenceur.IndexEffetCourrant +1 );
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionneEffet (int index)
|
||||
|
|
@ -266,6 +269,8 @@ namespace DMX2
|
|||
|
||||
seqMasterScale.Value = sequenceur.Master;
|
||||
|
||||
posLabel.Text = string.Format("n°{0}",sequenceur.IndexEffetCourrant +1);
|
||||
|
||||
fullUpdFlag=false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -272,12 +272,15 @@ namespace DMX2
|
|||
|
||||
void ChangeEffetCourrant (int index)
|
||||
{
|
||||
lock (this) {
|
||||
effetcourrant = effets [index];
|
||||
valeurschangees.Clear ();
|
||||
valeursinitiales = new Dictionary<Circuit, int> (valeurscourantes);
|
||||
enTransition = true;
|
||||
timeStamp = TimeSpan.Zero;
|
||||
if(ui!=null) ui.EffetChange();
|
||||
if (ui != null)
|
||||
ui.EffetChange ();
|
||||
}
|
||||
}
|
||||
|
||||
public int SauveEffet (string nom, TimeSpan duree, TimeSpan transition)
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ namespace DMX2
|
|||
|
||||
public void EffetSuivant ()
|
||||
{
|
||||
lock (this) {
|
||||
if (aSuivre == null) {
|
||||
if (IndexLigneEnCours + 1 < lignes.Count)
|
||||
enCours = lignes [IndexLigneEnCours + 1];
|
||||
|
|
@ -123,9 +124,11 @@ namespace DMX2
|
|||
timeStamp = TimeSpan.Zero;
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void EffetPrecedent ()
|
||||
{
|
||||
lock (this) {
|
||||
if (IndexLigneEnCours > 0)
|
||||
enCours = lignes [IndexLigneEnCours - 1];
|
||||
else
|
||||
|
|
@ -134,6 +137,7 @@ namespace DMX2
|
|||
timeStamp = TimeSpan.Zero;
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<Ligne> Lignes {
|
||||
get {
|
||||
|
|
@ -148,9 +152,11 @@ namespace DMX2
|
|||
|
||||
public int AjoutLigne (int pos)
|
||||
{
|
||||
lock (this) {
|
||||
lignes.Insert (pos, new Ligne ());
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick (TimeSpan deltaT)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue