/
MainWindow.cs
67 lines (50 loc) · 1.76 KB
/
MainWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using Gtk;
using Serpis.Ad;
public partial class MainWindow: Gtk.Window
{
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build ();
//App.Instance.DbConnection; TODO uso de dbConnection
CategoriaListView categoriaListView = new CategoriaListView(App.Instance.DbConnection);
ArticuloListView articuloListView = new ArticuloListView(App.Instance.DbConnection);
notebook.AppendPage(articuloListView, new Label("Articulos"));
notebook.AppendPage(categoriaListView, new Label("Categorias"));
articuloListView.SelectedChanged += delegate {
refesAction();
};
categoriaListView.SelectedChanged += delegate {
refesAction();
};
/*newAction.Activated += delegate {
if (!(notebook.CurrentPageWidget is IEntityListVIew)){
return;
}
IEntityListVIew entittyListView = (IEntityListVIew) notebook.CurrentPageWidget;
Console.WriteLine("entitytListView.getType(0)"+ entittyListView.GetType());
entittyListView.New();
};*/
newAction.Activated += delegate {
IEntityListVIew entittyListView = notebook.CurrentPageWidget as IEntityListVIew;//as comprueba si es posible la conversion y si es posible convierte sino devuelve null
if (entittyListView == null){
return;
}
Console.WriteLine("entitytListView.getType(0)"+ entittyListView.GetType());
entittyListView.New();
};
notebook.SwitchPage += delegate {
refesAction();
};
}
public void refesAction(){
IEntityListVIew entityListView = notebook.CurrentPageWidget as IEntityListVIew;
newAction.Sensitive = entityListView != null;
editAction.Sensitive = entityListView != null && entityListView.HasSelected;
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}