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.Collections.Generic;
|
||||
|
||||
namespace DMX2
|
||||
{
|
||||
public partial class GestionCircuits : Gtk.Dialog
|
||||
{
|
||||
Gtk.ListStore ls;
|
||||
public GestionCircuits ()
|
||||
public GestionCircuits (Gtk.Window parent) : base ("Circuits",parent,Gtk.DialogFlags.Modal)
|
||||
{
|
||||
|
||||
this.Build ();
|
||||
Gtk.TreeViewColumn nameCol = new Gtk.TreeViewColumn();
|
||||
Gtk.CellRendererText nameCell = new Gtk.CellRendererText();
|
||||
nameCol.Title = "Circuit";
|
||||
nameCol.PackStart(nameCell,true);
|
||||
nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc(
|
||||
new Gtk.TreeCellDataFunc(RenderCircuitName)
|
||||
));
|
||||
|
||||
nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) ));
|
||||
nameCell.Editable =true;
|
||||
nameCell.Edited += OnNameCellEdited;
|
||||
|
||||
this.listeCircuits.AppendColumn(nameCol);
|
||||
|
||||
ls = new Gtk.ListStore(typeof (Circuit));
|
||||
this.listeCircuits.Model = ls;
|
||||
UpdateListeCircuits();
|
||||
|
|
@ -36,39 +33,59 @@ namespace DMX2
|
|||
|
||||
}
|
||||
|
||||
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;
|
||||
(cell as Gtk.CellRendererText).Text = c.Name;
|
||||
}
|
||||
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;
|
||||
(cell as Gtk.CellRendererText).Text = c.Name;
|
||||
}
|
||||
|
||||
protected void UpdateListeCircuits ()
|
||||
{
|
||||
ls.Clear();
|
||||
foreach(Circuit c in Conduite.Courante.Circuits)
|
||||
foreach(var c in Conduite.Courante.Circuits)
|
||||
ls.AppendValues(c);
|
||||
}
|
||||
|
||||
protected void OnAddActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Gtk.Dialog dlg = new Gtk.Dialog("Test", this, Gtk.DialogFlags.DestroyWithParent);
|
||||
Gtk.VBox vb = new Gtk.VBox();
|
||||
var etry = new Gtk.Entry();
|
||||
dlg.Add(vb);
|
||||
vb.Add(etry);
|
||||
vb.Add(dlg.AddButton("Close",Gtk.ResponseType.Close));
|
||||
var dlg = new Gtk.Dialog ("Test", this, Gtk.DialogFlags.DestroyWithParent);
|
||||
dlg.VBox.Add (new Gtk.Label ("Nombre de circuits :"));
|
||||
var etry = new Gtk.Entry ("1");
|
||||
etry.ActivatesDefault=true;
|
||||
dlg.VBox.Add (etry);
|
||||
dlg.AddButton ("Close", Gtk.ResponseType.Close ).GrabDefault();
|
||||
dlg.VBox.ShowAll ();
|
||||
dlg.Run ();
|
||||
dlg.Destroy();
|
||||
|
||||
Conduite.Courante.NouveauCircuit();
|
||||
UpdateListeCircuits();
|
||||
|
||||
int nb;
|
||||
if (int.TryParse (etry.Text, out nb) && nb > 0) {
|
||||
for (int i=0; i<nb; i++)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Hide ();
|
||||
|
|
|
|||
|
|
@ -23,12 +23,8 @@ namespace DMX2
|
|||
|
||||
protected void OnCircuitsActionActivated (object sender, EventArgs e)
|
||||
{
|
||||
GestionCircuits gc= new GestionCircuits();
|
||||
gc.Parent=this;
|
||||
GestionCircuits gc= new GestionCircuits(this);
|
||||
gc.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ namespace DMX2
|
|||
this.Name = "DMX2.GestionCircuits";
|
||||
this.Title = global::Mono.Unix.Catalog.GetString ("Circuits");
|
||||
this.TypeHint = ((global::Gdk.WindowTypeHint)(1));
|
||||
this.WindowPosition = ((global::Gtk.WindowPosition)(4));
|
||||
this.DestroyWithParent = true;
|
||||
this.Gravity = ((global::Gdk.Gravity)(10));
|
||||
// Internal child DMX2.GestionCircuits.VBox
|
||||
|
|
@ -88,7 +89,8 @@ namespace DMX2
|
|||
}
|
||||
this.DefaultWidth = 400;
|
||||
this.DefaultHeight = 456;
|
||||
this.Show ();
|
||||
this.buttonOk.HasDefault = true;
|
||||
this.Hide ();
|
||||
this.Response += new global::Gtk.ResponseHandler (this.OnResp);
|
||||
this.addAction.Activated += new global::System.EventHandler (this.OnAddActionActivated);
|
||||
this.removeAction.Activated += new global::System.EventHandler (this.OnRemoveActionActivated);
|
||||
|
|
|
|||
|
|
@ -327,8 +327,10 @@
|
|||
</action>
|
||||
</action-group>
|
||||
<property name="MemberName" />
|
||||
<property name="Visible">False</property>
|
||||
<property name="Title" translatable="yes">Circuits</property>
|
||||
<property name="TypeHint">Dialog</property>
|
||||
<property name="WindowPosition">CenterOnParent</property>
|
||||
<property name="DestroyWithParent">True</property>
|
||||
<property name="Gravity">Static</property>
|
||||
<property name="Buttons">1</property>
|
||||
|
|
@ -396,6 +398,7 @@
|
|||
<widget class="Gtk.Button" id="buttonOk">
|
||||
<property name="MemberName" />
|
||||
<property name="CanDefault">True</property>
|
||||
<property name="HasDefault">True</property>
|
||||
<property name="CanFocus">True</property>
|
||||
<property name="UseStock">True</property>
|
||||
<property name="Type">StockItem</property>
|
||||
|
|
|
|||
Loading…
Reference in a new issue