diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index 70bf87b..57849e5 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -6,11 +6,11 @@ using System.Collections.ObjectModel; namespace DMX2 { - public class Conduite : IComparer + public class Conduite : IComparer, IDisposable { - public static Conduite Courante = new Conduite(); - + public static Conduite Courante = null; + public Conduite() { @@ -26,15 +26,29 @@ namespace DMX2 public Circuit NouveauCircuit () { - Circuit c = new Circuit(); - circuits.Add (c); - return c; + lock (this) { + Circuit c = new Circuit (); + circuits.Add (c); + return c; + } } - public void SupprimeCircuit(Circuit c) + public void SupprimeCircuit (Circuit c) { - circuits.Remove(c); + lock (this) { + circuits.Remove (c); + } + } + string _name; + + public string Name { + get { + return _name; + } + set { + _name = value; + } } @@ -46,9 +60,9 @@ namespace DMX2 List sequenceurs= new List(); - public List Sequenceurs { + public ReadOnlyCollection Sequenceurs { get { - return sequenceurs; + return sequenceurs.AsReadOnly(); } } @@ -60,6 +74,22 @@ namespace DMX2 } } + public void Dispose() + { + disposed=true; + // stop thread if running + } + + #region IDisposable implementation + bool disposed=false; + void IDisposable.Dispose () + { + if(!disposed) + Dispose(); + } + #endregion + + } public class Circuit diff --git a/DMX-2.0/GestionCircuits.cs b/DMX-2.0/GestionCircuits.cs index 28e6dd7..3eb8117 100644 --- a/DMX-2.0/GestionCircuits.cs +++ b/DMX-2.0/GestionCircuits.cs @@ -53,7 +53,7 @@ namespace DMX2 var etry = new Gtk.Entry ("1"); etry.ActivatesDefault=true; dlg.VBox.Add (etry); - dlg.AddButton ("Close", Gtk.ResponseType.Close ).GrabDefault(); + dlg.AddButton (Gtk.Stock.Close, Gtk.ResponseType.Close ).GrabDefault(); dlg.VBox.ShowAll (); dlg.Run (); int nb; @@ -69,9 +69,8 @@ namespace DMX2 } protected void OnRemoveActionActivated (object sender, EventArgs e) { - foreach(var c in GetSelection()) - Conduite.Courante.SupprimeCircuit(c); - + foreach (var c in GetSelection()) + Conduite.Courante.SupprimeCircuit (c); UpdateListeCircuits(); } diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index 9e8b11f..783fb44 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -9,8 +9,47 @@ namespace DMX2 public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); + MajWidgets(); } - + + protected void MajWidgets () + { + if (Conduite.Courante != null) { + circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = true; + openAction.Sensitive = newAction.Sensitive = false; + this.Title = "DMX 2.0 - " + Conduite.Courante.Name; + } else { + circAction.Sensitive = saveAction.Sensitive = saveAsAction.Sensitive = closeAction.Sensitive = false; + openAction.Sensitive = newAction.Sensitive = true; + this.Title = "DMX 2.0"; + } + + } + + protected void MajCircuits () + { + // Ajoute une ProgressBar par circuit, met a jour le texte si necessaire + if (vboxCircuits.Children.Length != Conduite.Courante.Circuits.Count) { + foreach (var widget in vboxCircuits.Children) + vboxCircuits.Remove (widget); + foreach (var circuit in Conduite.Courante.Circuits) { + vboxCircuits.PackStart (new ProgressBar (),false,false,0); + } + vboxCircuits.ShowAll (); + } + int i = 0; + foreach (var widget in vboxCircuits.Children) { + var c = Conduite.Courante.Circuits[i++]; + ProgressBar pb = (ProgressBar)widget; + pb.Text = i.ToString() + " - " + c.Name; + pb.Fraction = (double) c.ValeurCourante / 255; + pb.HeightRequest = 22; + } + + + } + + protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); @@ -25,6 +64,31 @@ namespace DMX2 { GestionCircuits gc= new GestionCircuits(this); gc.Run(); + gc.Destroy(); + MajCircuits(); } + + protected void OnNewActionActivated (object sender, EventArgs e) + { + var dlg = new Dialog ("Nom ?", this, DialogFlags.Modal); var entry = new Entry ("Conduite sans Nom"); + dlg.AddButton (Stock.Ok, ResponseType.Ok).GrabDefault(); dlg.AddButton (Stock.Cancel, ResponseType.Cancel); + dlg.VBox.Add (new Label("Nom de la nouvelle Conduite :")); dlg.VBox.Add (entry); dlg.VBox.ShowAll (); + entry.ActivatesDefault=true; + + if ((ResponseType)dlg.Run () == ResponseType.Ok) { + Conduite.Courante = new Conduite (); + Conduite.Courante.Name = entry.Text; + } + MajWidgets(); + dlg.Destroy(); + } + protected void OnCloseActionActivated (object sender, EventArgs e) + { + Conduite.Courante.Dispose(); + Conduite.Courante= null; + MajWidgets(); + } + + } } \ No newline at end of file diff --git a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs index 0dbb987..864254f 100644 --- a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs +++ b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs @@ -11,7 +11,7 @@ namespace DMX2 private global::Gtk.Action quitAction; private global::Gtk.Action closeAction; private global::Gtk.Action TestAction; - private global::Gtk.Action CircuitsAction; + private global::Gtk.Action circAction; private global::Gtk.Action propertiesAction; private global::Gtk.Action FichierAction; private global::Gtk.Action newAction; @@ -25,7 +25,8 @@ namespace DMX2 private global::Gtk.VBox vbox3; private global::Gtk.ScrolledWindow GtkScrolledWindow; private global::Gtk.NodeView nodeview1; - private global::Gtk.VBox vbox2; + private global::Gtk.ScrolledWindow scrolledwindow2; + private global::Gtk.VBox vboxCircuits; private global::Gtk.ProgressBar progressbar1; private global::Gtk.ProgressBar progressbar2; private global::Gtk.ProgressBar progressbar3; @@ -42,7 +43,6 @@ namespace DMX2 this.UIManager = new global::Gtk.UIManager (); global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default"); this.openAction = new global::Gtk.Action ("openAction", global::Mono.Unix.Catalog.GetString ("_Ouvrir"), null, "gtk-open"); - this.openAction.Sensitive = false; this.openAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("_Ouvrir"); w1.Add (this.openAction, null); this.saveAction = new global::Gtk.Action ("saveAction", null, null, "gtk-save"); @@ -59,9 +59,10 @@ namespace DMX2 this.TestAction = new global::Gtk.Action ("TestAction", global::Mono.Unix.Catalog.GetString ("Test"), null, null); this.TestAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Test"); w1.Add (this.TestAction, null); - this.CircuitsAction = new global::Gtk.Action ("CircuitsAction", global::Mono.Unix.Catalog.GetString ("Circuits"), null, "circuits"); - this.CircuitsAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Circuits"); - w1.Add (this.CircuitsAction, null); + this.circAction = new global::Gtk.Action ("circAction", global::Mono.Unix.Catalog.GetString ("Circuits"), null, "circuits"); + this.circAction.Sensitive = false; + this.circAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Circuits"); + w1.Add (this.circAction, null); this.propertiesAction = new global::Gtk.Action ("propertiesAction", global::Mono.Unix.Catalog.GetString ("Circuits"), null, "gtk-properties"); this.propertiesAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Circuits"); w1.Add (this.propertiesAction, null); @@ -105,7 +106,7 @@ namespace DMX2 this.hpaned1 = new global::Gtk.HPaned (); this.hpaned1.CanFocus = true; this.hpaned1.Name = "hpaned1"; - this.hpaned1.Position = 651; + this.hpaned1.Position = 705; // Container child hpaned1.Gtk.Paned+PanedChild this.hpaned2 = new global::Gtk.HPaned (); this.hpaned2.CanFocus = true; @@ -128,6 +129,7 @@ namespace DMX2 this.hpaned2.Add (this.scrolledwindow1); global::Gtk.Paned.PanedChild w7 = ((global::Gtk.Paned.PanedChild)(this.hpaned2 [this.scrolledwindow1])); w7.Resize = false; + w7.Shrink = false; // Container child hpaned2.Gtk.Paned+PanedChild this.GtkScrolledWindow = new global::Gtk.ScrolledWindow (); this.GtkScrolledWindow.Name = "GtkScrolledWindow"; @@ -138,72 +140,90 @@ namespace DMX2 this.nodeview1.Name = "nodeview1"; this.GtkScrolledWindow.Add (this.nodeview1); this.hpaned2.Add (this.GtkScrolledWindow); + global::Gtk.Paned.PanedChild w9 = ((global::Gtk.Paned.PanedChild)(this.hpaned2 [this.GtkScrolledWindow])); + w9.Resize = false; + w9.Shrink = false; this.hpaned1.Add (this.hpaned2); global::Gtk.Paned.PanedChild w10 = ((global::Gtk.Paned.PanedChild)(this.hpaned1 [this.hpaned2])); w10.Resize = false; // Container child hpaned1.Gtk.Paned+PanedChild - this.vbox2 = new global::Gtk.VBox (); - this.vbox2.WidthRequest = 150; - this.vbox2.Name = "vbox2"; - this.vbox2.Spacing = 2; - // Container child vbox2.Gtk.Box+BoxChild + this.scrolledwindow2 = new global::Gtk.ScrolledWindow (); + this.scrolledwindow2.WidthRequest = 150; + this.scrolledwindow2.CanFocus = true; + this.scrolledwindow2.Name = "scrolledwindow2"; + this.scrolledwindow2.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child scrolledwindow2.Gtk.Container+ContainerChild + global::Gtk.Viewport w11 = new global::Gtk.Viewport (); + w11.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child GtkViewport1.Gtk.Container+ContainerChild + this.vboxCircuits = new global::Gtk.VBox (); + this.vboxCircuits.Name = "vboxCircuits"; + this.vboxCircuits.Spacing = 2; + // Container child vboxCircuits.Gtk.Box+BoxChild this.progressbar1 = new global::Gtk.ProgressBar (); this.progressbar1.Name = "progressbar1"; - this.vbox2.Add (this.progressbar1); - global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressbar1])); - w11.Position = 0; - w11.Expand = false; - w11.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.progressbar2 = new global::Gtk.ProgressBar (); - this.progressbar2.Name = "progressbar2"; - this.vbox2.Add (this.progressbar2); - global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressbar2])); - w12.Position = 1; + this.vboxCircuits.Add (this.progressbar1); + global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vboxCircuits [this.progressbar1])); + w12.Position = 0; w12.Expand = false; w12.Fill = false; - // Container child vbox2.Gtk.Box+BoxChild - this.progressbar3 = new global::Gtk.ProgressBar (); - this.progressbar3.Name = "progressbar3"; - this.vbox2.Add (this.progressbar3); - global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.progressbar3])); - w13.Position = 2; + // Container child vboxCircuits.Gtk.Box+BoxChild + this.progressbar2 = new global::Gtk.ProgressBar (); + this.progressbar2.Name = "progressbar2"; + this.vboxCircuits.Add (this.progressbar2); + global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vboxCircuits [this.progressbar2])); + w13.Position = 1; w13.Expand = false; w13.Fill = false; - this.hpaned1.Add (this.vbox2); + // Container child vboxCircuits.Gtk.Box+BoxChild + this.progressbar3 = new global::Gtk.ProgressBar (); + this.progressbar3.HeightRequest = 22; + this.progressbar3.Name = "progressbar3"; + this.progressbar3.Text = global::Mono.Unix.Catalog.GetString ("tre"); + this.vboxCircuits.Add (this.progressbar3); + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vboxCircuits [this.progressbar3])); + w14.Position = 2; + w14.Expand = false; + w14.Fill = false; + w11.Add (this.vboxCircuits); + this.scrolledwindow2.Add (w11); + this.hpaned1.Add (this.scrolledwindow2); + global::Gtk.Paned.PanedChild w17 = ((global::Gtk.Paned.PanedChild)(this.hpaned1 [this.scrolledwindow2])); + w17.Resize = false; + w17.Shrink = false; this.hbox1.Add (this.hpaned1); - global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.hpaned1])); - w15.Position = 2; + global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.hpaned1])); + w18.Position = 2; this.vbox1.Add (this.hbox1); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); - w16.Position = 0; + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); + w19.Position = 0; // Container child vbox1.Gtk.Box+BoxChild this.hseparator1 = new global::Gtk.HSeparator (); this.hseparator1.Name = "hseparator1"; this.vbox1.Add (this.hseparator1); - global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hseparator1])); - w17.Position = 1; - w17.Expand = false; - w17.Fill = false; + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hseparator1])); + w20.Position = 1; + w20.Expand = false; + w20.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.hbox2 = new global::Gtk.HBox (); this.hbox2.Name = "hbox2"; this.hbox2.Spacing = 6; // Container child hbox2.Gtk.Box+BoxChild - this.UIManager.AddUiFromString (""); + this.UIManager.AddUiFromString (""); this.toolbar3 = ((global::Gtk.Toolbar)(this.UIManager.GetWidget ("/toolbar3"))); this.toolbar3.Name = "toolbar3"; this.toolbar3.ShowArrow = false; this.hbox2.Add (this.toolbar3); - global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.toolbar3])); - w18.Position = 0; + global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.toolbar3])); + w21.Position = 0; // Container child hbox2.Gtk.Box+BoxChild this.fixed3 = new global::Gtk.Fixed (); this.fixed3.Name = "fixed3"; this.fixed3.HasWindow = false; this.hbox2.Add (this.fixed3); - global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.fixed3])); - w19.Position = 1; + global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.fixed3])); + w22.Position = 1; // Container child hbox2.Gtk.Box+BoxChild this.UIManager.AddUiFromString (""); this.toolbar2 = ((global::Gtk.Toolbar)(this.UIManager.GetWidget ("/toolbar2"))); @@ -211,15 +231,15 @@ namespace DMX2 this.toolbar2.ShowArrow = false; this.toolbar2.ToolbarStyle = ((global::Gtk.ToolbarStyle)(0)); this.hbox2.Add (this.toolbar2); - global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.toolbar2])); - w20.Position = 2; - w20.Expand = false; - w20.Fill = false; + global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.toolbar2])); + w23.Position = 2; + w23.Expand = false; + w23.Fill = false; this.vbox1.Add (this.hbox2); - global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox2])); - w21.Position = 2; - w21.Expand = false; - w21.Fill = false; + global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox2])); + w24.Position = 2; + w24.Expand = false; + w24.Fill = false; this.Add (this.vbox1); if ((this.Child != null)) { this.Child.ShowAll (); @@ -229,7 +249,9 @@ namespace DMX2 this.Show (); this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent); this.quitAction.Activated += new global::System.EventHandler (this.OnQuitActionActivated); - this.CircuitsAction.Activated += new global::System.EventHandler (this.OnCircuitsActionActivated); + this.closeAction.Activated += new global::System.EventHandler (this.OnCloseActionActivated); + this.circAction.Activated += new global::System.EventHandler (this.OnCircuitsActionActivated); + this.newAction.Activated += new global::System.EventHandler (this.OnNewActionActivated); } } } diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index 7dfb032..e1901d6 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -37,7 +37,6 @@ Action _Ouvrir - False _Ouvrir gtk-open @@ -64,15 +63,17 @@ False gtk-close + Action Test Test - + Action Circuits + False Circuits circuits @@ -92,6 +93,7 @@ Action gtk-new + @@ -134,7 +136,7 @@ True - 651 + 705 @@ -168,7 +170,7 @@ - False + False @@ -183,6 +185,10 @@ + + False + False + @@ -190,44 +196,63 @@ - + 150 - 2 + True + In - + + None + + + + 2 + + + + + + 0 + True + False + False + + + + + + + + 1 + True + False + False + + + + + + 22 + tre + + + 2 + True + False + False + + + + - - 0 - True - False - False - - - - - - - - 1 - True - False - False - - - - - - - - 2 - True - False - False - + + False + False + @@ -261,7 +286,7 @@ False - +