Circuits ... suite

This commit is contained in:
tzim 2013-04-10 10:06:25 +00:00
parent 4afe3c85fd
commit 5842ebc386
5 changed files with 243 additions and 103 deletions

View file

@ -6,10 +6,10 @@ using System.Collections.ObjectModel;
namespace DMX2
{
public class Conduite : IComparer<Circuit>
public class Conduite : IComparer<Circuit>, 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<Sequenceur> sequenceurs= new List<Sequenceur>();
public List<Sequenceur> Sequenceurs {
public ReadOnlyCollection<Sequenceur> 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

View file

@ -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();
}

View file

@ -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();
}
}
}

View file

@ -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 ("<ui><toolbar name='toolbar3'><toolitem name='CircuitsAction' action='CircuitsAction'/></toolbar></ui>");
this.UIManager.AddUiFromString ("<ui><toolbar name='toolbar3'><toolitem name='circAction' action='circAction'/></toolbar></ui>");
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 ("<ui><toolbar name='toolbar2'><toolitem name='newAction' action='newAction'/><toolitem name='openAction' action='openAction'/><toolitem name='saveAction' action='saveAction'/><toolitem name='saveAsAction' action='saveAsAction'/><toolitem name='closeAction' action='closeAction'/><toolitem name='quitAction' action='quitAction'/></toolbar></ui>");
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);
}
}
}

View file

@ -37,7 +37,6 @@
<action id="openAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">_Ouvrir</property>
<property name="Sensitive">False</property>
<property name="ShortLabel" translatable="yes">_Ouvrir</property>
<property name="StockId">gtk-open</property>
</action>
@ -64,15 +63,17 @@
<property name="Label" translatable="yes" />
<property name="Sensitive">False</property>
<property name="StockId">gtk-close</property>
<signal name="Activated" handler="OnCloseActionActivated" />
</action>
<action id="TestAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Test</property>
<property name="ShortLabel" translatable="yes">Test</property>
</action>
<action id="CircuitsAction">
<action id="circAction">
<property name="Type">Action</property>
<property name="Label" translatable="yes">Circuits</property>
<property name="Sensitive">False</property>
<property name="ShortLabel" translatable="yes">Circuits</property>
<property name="StockId">circuits</property>
<signal name="Activated" handler="OnCircuitsActionActivated" />
@ -92,6 +93,7 @@
<property name="Type">Action</property>
<property name="Label" translatable="yes" />
<property name="StockId">gtk-new</property>
<signal name="Activated" handler="OnNewActionActivated" />
</action>
</action-group>
<property name="MemberName" />
@ -134,7 +136,7 @@
<widget class="Gtk.HPaned" id="hpaned1">
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="Position">651</property>
<property name="Position">705</property>
<child>
<widget class="Gtk.HPaned" id="hpaned2">
<property name="MemberName" />
@ -168,7 +170,7 @@
</child>
</widget>
<packing>
<property name="Resize">False</property>
<property name="Shrink">False</property>
</packing>
</child>
<child>
@ -183,6 +185,10 @@
</widget>
</child>
</widget>
<packing>
<property name="Resize">False</property>
<property name="Shrink">False</property>
</packing>
</child>
</widget>
<packing>
@ -190,44 +196,63 @@
</packing>
</child>
<child>
<widget class="Gtk.VBox" id="vbox2">
<widget class="Gtk.ScrolledWindow" id="scrolledwindow2">
<property name="MemberName" />
<property name="WidthRequest">150</property>
<property name="Spacing">2</property>
<property name="CanFocus">True</property>
<property name="ShadowType">In</property>
<child>
<widget class="Gtk.ProgressBar" id="progressbar1">
<widget class="Gtk.Viewport" id="GtkViewport1">
<property name="MemberName" />
<property name="ShadowType">None</property>
<child>
<widget class="Gtk.VBox" id="vboxCircuits">
<property name="MemberName" />
<property name="Spacing">2</property>
<child>
<widget class="Gtk.ProgressBar" id="progressbar1">
<property name="MemberName" />
</widget>
<packing>
<property name="Position">0</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.ProgressBar" id="progressbar2">
<property name="MemberName" />
</widget>
<packing>
<property name="Position">1</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.ProgressBar" id="progressbar3">
<property name="MemberName" />
<property name="HeightRequest">22</property>
<property name="Text" translatable="yes">tre</property>
</widget>
<packing>
<property name="Position">2</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="Position">0</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.ProgressBar" id="progressbar2">
<property name="MemberName" />
</widget>
<packing>
<property name="Position">1</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.ProgressBar" id="progressbar3">
<property name="MemberName" />
</widget>
<packing>
<property name="Position">2</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="Resize">False</property>
<property name="Shrink">False</property>
</packing>
</child>
</widget>
<packing>
@ -261,7 +286,7 @@
<property name="MemberName" />
<property name="ShowArrow">False</property>
<node name="toolbar3" type="Toolbar">
<node type="Toolitem" action="CircuitsAction" />
<node type="Toolitem" action="circAction" />
</node>
</widget>
<packing>