/
MainWindow.cs
204 lines (163 loc) · 5.33 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Collections.Generic;
using Gtk;
using gsalon;
public partial class MainWindow: Gtk.Window
{
VBox vboxMain = new VBox (false,10);
HBox hbTop = new HBox (false,1);
HPaned verticalPane = new HPaned ();
ScrolledWindow scrollWindowLeft = new ScrolledWindow ();
ScrolledWindow scrollWindowRight = new ScrolledWindow ();
Viewport viewPortLeft = new Viewport ();
Viewport viewPortRight = new Viewport ();
Entry tbSearch ;
HBox hboxSearch;
VBox vboxVpLeft;
TreeView tvResults = new TreeView ();
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Application.Init ();
this.Resize(640,480);
//menu bar very top
MenuBar mb = new MenuBar ();
Menu fileMenu = new Menu ();
MenuItem menuItem = new MenuItem ("_File");
menuItem.Submenu = fileMenu;
mb.Append(menuItem);
MenuItem menuFileQuit = new MenuItem("Quit");
fileMenu.Append(menuFileQuit);
vboxMain.PackStart(mb,false,false,0);
//toolbar
Toolbar tbTop = new Toolbar ();
//toolbutton Staff
ToolButton tbStaff = new ToolButton (Gtk.Stock.OrientationPortrait);
tbStaff.Label="Staff";
tbStaff.IsImportant=true;
tbStaff.Clicked += HandleTbStaffClicked;
tbTop.Insert(tbStaff,0);
//toolbutton Clients
ToolButton tbClients = new ToolButton (Gtk.Stock.About);
tbClients.Label="Clients";
tbClients.IsImportant=true;
tbClients.Clicked+= HandleTbClientsClicked;
tbTop.Insert(tbClients,1);
//media bar
Label lbMediaTemp = new Label ();
lbMediaTemp.Text="Media holder";
lbMediaTemp.Show();
//pack the toolbar and media bar in the top hbox//
hbTop.PackStart(tbTop);
hbTop.PackStart(lbMediaTemp);
//pack the top hbox in the main vbox
vboxMain.PackStart(hbTop,false,false,1);
// horizontal pane
verticalPane.Position=200;
verticalPane.Pack1(scrollWindowLeft,false,false);
verticalPane.Pack2(scrollWindowRight,false,false);
vboxMain.PackStart(verticalPane);
scrollWindowLeft.Add(viewPortLeft);
scrollWindowRight.Add(viewPortRight);
Label lbMain = new Label ();
lbMain.Text= "main";
viewPortRight.Add(lbMain);
verticalPane.ShowAll();
//status bar very bottom
Statusbar sb = new Statusbar ();
vboxMain.PackStart(sb,false,false,1);
this.Add(vboxMain);
//hb1.Add(tbTop);
this.ShowAll ();
Build ();
}
void HandleTbSearchKeyReleaseEvent (object o, KeyReleaseEventArgs args)
{
//get results live on key up
staff staffMember = new staff();
staffMember.fName = "ted";
List<staff> searchResults = new List<staff> ();
searchResults = staffMember.search_staff(tbSearch.Text);
Console.WriteLine("Search Results found: "+searchResults.Count.ToString());
//staffMember.get_staff_member();
foreach(staff sr in searchResults)
{
Console.WriteLine(sr.fName+" "+sr.lName);
}
}
void HandleTbClientsClicked (object sender, EventArgs e)
{
viewPortRight.Remove(viewPortLeft.Child);
Label lbClients =new Label ();
lbClients.Text ="Im the clients bit";
viewPortLeft.Remove(viewPortLeft.Child);
viewPortLeft.Add(lbClients);
viewPortLeft.Show();
lbClients.Show();
Console.WriteLine("Clients Clicked");
staff s = new staff ();
List<staff> staffList = new List<staff>();
staffList= s.get_all_staff_members();
foreach(staff sm in staffList)
{
Console.WriteLine(sm.fName);
}
}
void HandleTbStaffClicked (object sender, EventArgs e)
{
//set up search input
tbSearch=new Entry ();
tbSearch.KeyReleaseEvent+= HandleTbSearchKeyReleaseEvent;
viewPortLeft.Remove(viewPortLeft.Child);
hboxSearch = new HBox ();
vboxVpLeft = new VBox ();
Button btSearchGo = new Button ();
btSearchGo.Clicked+= HandleBtSearchGoClicked;
btSearchGo.Label="Go";
viewPortLeft.Remove(viewPortLeft.Child);
Label lbStaff = new Label ();
lbStaff.Text="im the staff bit";
viewPortLeft.Add(vboxVpLeft);
hboxSearch.PackStart(tbSearch,true,true,1);
hboxSearch.PackStart(btSearchGo,false,false,1);
vboxVpLeft.PackStart(hboxSearch,false,false,1);
viewPortLeft.Show();
lbStaff.Show();
tbSearch.Show();
vboxVpLeft.ShowAll();
Console.WriteLine("staff clicked");
}
void HandleBtSearchGoClicked (object sender, EventArgs e)
{
tvResults.Destroy();
tvResults = new TreeView ();
Console.WriteLine("Searched: "+tbSearch.Text);
staff staffMember = new staff();
staffMember.fName = "ted";
List<staff> searchResults = new List<staff> ();
searchResults = staffMember.search_staff(tbSearch.Text);
Console.WriteLine("Search Results found: "+searchResults.Count.ToString());
//staffMember.get_staff_member();
foreach(staff sr in searchResults)
{
Console.WriteLine(sr.fName+" "+sr.lName);
}
//Console.WriteLine(staffMember.fName);
Gtk.ListStore searchResultsStore = new Gtk.ListStore (typeof (string));
searchResultsStore.AppendValues ("Gerry");
Gtk.CellRendererText staffResult = new Gtk.CellRendererText ();
tvResults.Model = searchResultsStore;
vboxVpLeft.PackStart(tvResults);
TreeViewColumn tvcName = new TreeViewColumn ();
tvcName.Title="Name";
tvcName.PackStart(staffResult,true);
tvResults.AppendColumn(tvcName);
tvcName.AddAttribute (staffResult, "text", 0);
tvResults.Show();
vboxVpLeft.PackStart(tvResults);
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}