Ajout suppression Circuits. et dialogue nb circuits
This commit is contained in:
parent
ae242bfde0
commit
4afe3c85fd
4 changed files with 48 additions and 30 deletions
|
|
@ -1,26 +1,23 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
public partial class GestionCircuits : Gtk.Dialog
|
public partial class GestionCircuits : Gtk.Dialog
|
||||||
{
|
{
|
||||||
Gtk.ListStore ls;
|
Gtk.ListStore ls;
|
||||||
public GestionCircuits ()
|
public GestionCircuits (Gtk.Window parent) : base ("Circuits",parent,Gtk.DialogFlags.Modal)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.Build ();
|
this.Build ();
|
||||||
Gtk.TreeViewColumn nameCol = new Gtk.TreeViewColumn();
|
Gtk.TreeViewColumn nameCol = new Gtk.TreeViewColumn();
|
||||||
Gtk.CellRendererText nameCell = new Gtk.CellRendererText();
|
Gtk.CellRendererText nameCell = new Gtk.CellRendererText();
|
||||||
nameCol.Title = "Circuit";
|
nameCol.Title = "Circuit";
|
||||||
nameCol.PackStart(nameCell,true);
|
nameCol.PackStart(nameCell,true);
|
||||||
nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc(
|
nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) ));
|
||||||
new Gtk.TreeCellDataFunc(RenderCircuitName)
|
|
||||||
));
|
|
||||||
|
|
||||||
nameCell.Editable =true;
|
nameCell.Editable =true;
|
||||||
nameCell.Edited += OnNameCellEdited;
|
nameCell.Edited += OnNameCellEdited;
|
||||||
|
|
||||||
this.listeCircuits.AppendColumn(nameCol);
|
this.listeCircuits.AppendColumn(nameCol);
|
||||||
|
|
||||||
ls = new Gtk.ListStore(typeof (Circuit));
|
ls = new Gtk.ListStore(typeof (Circuit));
|
||||||
this.listeCircuits.Model = ls;
|
this.listeCircuits.Model = ls;
|
||||||
UpdateListeCircuits();
|
UpdateListeCircuits();
|
||||||
|
|
@ -36,37 +33,57 @@ namespace DMX2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) {
|
private void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) {
|
||||||
Circuit c = tree_model.GetValue (iter, 0) as Circuit;
|
Circuit c = tree_model.GetValue (iter, 0) as Circuit;
|
||||||
(cell as Gtk.CellRendererText).Text = c.Name;
|
(cell as Gtk.CellRendererText).Text = c.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateListeCircuits ()
|
protected void UpdateListeCircuits ()
|
||||||
{
|
{
|
||||||
ls.Clear();
|
ls.Clear();
|
||||||
foreach(Circuit c in Conduite.Courante.Circuits)
|
foreach(var c in Conduite.Courante.Circuits)
|
||||||
ls.AppendValues(c);
|
ls.AppendValues(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnAddActionActivated (object sender, EventArgs e)
|
protected void OnAddActionActivated (object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
Gtk.Dialog dlg = new Gtk.Dialog("Test", this, Gtk.DialogFlags.DestroyWithParent);
|
var dlg = new Gtk.Dialog ("Test", this, Gtk.DialogFlags.DestroyWithParent);
|
||||||
Gtk.VBox vb = new Gtk.VBox();
|
dlg.VBox.Add (new Gtk.Label ("Nombre de circuits :"));
|
||||||
var etry = new Gtk.Entry();
|
var etry = new Gtk.Entry ("1");
|
||||||
dlg.Add(vb);
|
etry.ActivatesDefault=true;
|
||||||
vb.Add(etry);
|
dlg.VBox.Add (etry);
|
||||||
vb.Add(dlg.AddButton("Close",Gtk.ResponseType.Close));
|
dlg.AddButton ("Close", Gtk.ResponseType.Close ).GrabDefault();
|
||||||
|
dlg.VBox.ShowAll ();
|
||||||
dlg.Run ();
|
dlg.Run ();
|
||||||
dlg.Destroy();
|
int nb;
|
||||||
|
if (int.TryParse (etry.Text, out nb) && nb > 0) {
|
||||||
Conduite.Courante.NouveauCircuit();
|
for (int i=0; i<nb; i++)
|
||||||
UpdateListeCircuits();
|
Conduite.Courante.NouveauCircuit ();
|
||||||
|
UpdateListeCircuits ();
|
||||||
|
} else {
|
||||||
|
var md = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal,Gtk.MessageType.Error, Gtk.ButtonsType.Ok,"Veuillez saisir un nombre positif");
|
||||||
|
md.Run(); md.Destroy();
|
||||||
|
}
|
||||||
|
dlg.Destroy ();
|
||||||
}
|
}
|
||||||
protected void OnRemoveActionActivated (object sender, EventArgs e)
|
protected void OnRemoveActionActivated (object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException ();
|
foreach(var c in GetSelection())
|
||||||
|
Conduite.Courante.SupprimeCircuit(c);
|
||||||
|
|
||||||
|
UpdateListeCircuits();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<Circuit> GetSelection()
|
||||||
|
{
|
||||||
|
Gtk.TreeIter iter; List<Circuit> selection = new List<Circuit>();
|
||||||
|
foreach(var row in listeCircuits.Selection.GetSelectedRows())
|
||||||
|
{
|
||||||
|
ls.GetIter (out iter, row);
|
||||||
|
selection.Add( ls.GetValue(iter,0) as Circuit);
|
||||||
|
}
|
||||||
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnResp (object o, Gtk.ResponseArgs args)
|
protected void OnResp (object o, Gtk.ResponseArgs args)
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,8 @@ namespace DMX2
|
||||||
|
|
||||||
protected void OnCircuitsActionActivated (object sender, EventArgs e)
|
protected void OnCircuitsActionActivated (object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
GestionCircuits gc= new GestionCircuits();
|
GestionCircuits gc= new GestionCircuits(this);
|
||||||
gc.Parent=this;
|
|
||||||
gc.Run();
|
gc.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +28,7 @@ namespace DMX2
|
||||||
this.Name = "DMX2.GestionCircuits";
|
this.Name = "DMX2.GestionCircuits";
|
||||||
this.Title = global::Mono.Unix.Catalog.GetString ("Circuits");
|
this.Title = global::Mono.Unix.Catalog.GetString ("Circuits");
|
||||||
this.TypeHint = ((global::Gdk.WindowTypeHint)(1));
|
this.TypeHint = ((global::Gdk.WindowTypeHint)(1));
|
||||||
|
this.WindowPosition = ((global::Gtk.WindowPosition)(4));
|
||||||
this.DestroyWithParent = true;
|
this.DestroyWithParent = true;
|
||||||
this.Gravity = ((global::Gdk.Gravity)(10));
|
this.Gravity = ((global::Gdk.Gravity)(10));
|
||||||
// Internal child DMX2.GestionCircuits.VBox
|
// Internal child DMX2.GestionCircuits.VBox
|
||||||
|
|
@ -88,7 +89,8 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
this.DefaultWidth = 400;
|
this.DefaultWidth = 400;
|
||||||
this.DefaultHeight = 456;
|
this.DefaultHeight = 456;
|
||||||
this.Show ();
|
this.buttonOk.HasDefault = true;
|
||||||
|
this.Hide ();
|
||||||
this.Response += new global::Gtk.ResponseHandler (this.OnResp);
|
this.Response += new global::Gtk.ResponseHandler (this.OnResp);
|
||||||
this.addAction.Activated += new global::System.EventHandler (this.OnAddActionActivated);
|
this.addAction.Activated += new global::System.EventHandler (this.OnAddActionActivated);
|
||||||
this.removeAction.Activated += new global::System.EventHandler (this.OnRemoveActionActivated);
|
this.removeAction.Activated += new global::System.EventHandler (this.OnRemoveActionActivated);
|
||||||
|
|
|
||||||
|
|
@ -327,8 +327,10 @@
|
||||||
</action>
|
</action>
|
||||||
</action-group>
|
</action-group>
|
||||||
<property name="MemberName" />
|
<property name="MemberName" />
|
||||||
|
<property name="Visible">False</property>
|
||||||
<property name="Title" translatable="yes">Circuits</property>
|
<property name="Title" translatable="yes">Circuits</property>
|
||||||
<property name="TypeHint">Dialog</property>
|
<property name="TypeHint">Dialog</property>
|
||||||
|
<property name="WindowPosition">CenterOnParent</property>
|
||||||
<property name="DestroyWithParent">True</property>
|
<property name="DestroyWithParent">True</property>
|
||||||
<property name="Gravity">Static</property>
|
<property name="Gravity">Static</property>
|
||||||
<property name="Buttons">1</property>
|
<property name="Buttons">1</property>
|
||||||
|
|
@ -396,6 +398,7 @@
|
||||||
<widget class="Gtk.Button" id="buttonOk">
|
<widget class="Gtk.Button" id="buttonOk">
|
||||||
<property name="MemberName" />
|
<property name="MemberName" />
|
||||||
<property name="CanDefault">True</property>
|
<property name="CanDefault">True</property>
|
||||||
|
<property name="HasDefault">True</property>
|
||||||
<property name="CanFocus">True</property>
|
<property name="CanFocus">True</property>
|
||||||
<property name="UseStock">True</property>
|
<property name="UseStock">True</property>
|
||||||
<property name="Type">StockItem</property>
|
<property name="Type">StockItem</property>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue