protected void OnDoneButtonClicked(object sender, EventArgs e) { string ty = Typebox.ActiveText; int id = Locals.Count + 1; if (ty == "Cine") { Cine cine = new Cine(NameBox.Text, id, HoursBox.Text, OwnerBox.Text, ScreenSpin.ValueAsInt); LocalController.Locals.Add(cine); } else if (ty == "Hobbie") { Hobbie hobbie = new Hobbie(NameBox.Text, id, HoursBox.Text, OwnerBox.Text); LocalController.Locals.Add(hobbie); } else if (ty == "Restaurant") { Restaurant restaurant = new Restaurant(NameBox.Text, id, HoursBox.Text, OwnerBox.Text, ExTablesButton.Active); LocalController.Locals.Add(restaurant); } else if (ty == "Store") { string cats = CatBox.Text; List <string> x = new List <string>(); foreach (string cat in cats.Split(',')) { x.Add(cat); } Store store = new Store(NameBox.Text, id, HoursBox.Text, OwnerBox.Text, x); LocalController.Locals.Add(store); } int id2 = LocalController.Locals.Count; DoneLabel.Text = $"Local N˚ {id2} created!\n"; Dictionary <int, Dictionary <string, string> > dict = LocalController.FillDict(); string name = $"Name: {dict[id2]["Name"]}\n"; string owner = $"Owner: {dict[id2]["Owner"]}\n"; string bh = $"Business Hours: {dict[id2]["Business Hours"]}\n"; DoneLabel.Text += name; DoneLabel.Text += owner; DoneLabel.Text += bh; DoneLabel.Show(); Back(); }
public Window2() : base(Gtk.WindowType.Toplevel) { this.Build(); Deletable = false; Dictionary <int, Dictionary <string, string> > dict = LocalController.FillDict(); Gtk.TreeViewColumn nameColumn = new Gtk.TreeViewColumn(); nameColumn.Title = "Name"; Gtk.TreeViewColumn idColumn = new Gtk.TreeViewColumn(); idColumn.Title = "ID"; Gtk.TreeViewColumn hColumn = new Gtk.TreeViewColumn(); hColumn.Title = "Business Hours"; Gtk.TreeViewColumn oColumn = new Gtk.TreeViewColumn(); oColumn.Title = "Owner"; Gtk.TreeViewColumn sColumn = new Gtk.TreeViewColumn(); sColumn.Title = "Screens"; Gtk.TreeViewColumn cColumn = new Gtk.TreeViewColumn(); cColumn.Title = "Categories"; Gtk.TreeViewColumn tColumn = new Gtk.TreeViewColumn(); tColumn.Title = "Exclusive tables"; Gtk.TreeViewColumn lColumn = new Gtk.TreeViewColumn(); lColumn.Title = "Local type"; ViewTree2.AppendColumn(idColumn); ViewTree2.AppendColumn(nameColumn); ViewTree2.AppendColumn(hColumn); ViewTree2.AppendColumn(oColumn); ViewTree2.AppendColumn(sColumn); ViewTree2.AppendColumn(cColumn); ViewTree2.AppendColumn(tColumn); ViewTree2.AppendColumn(lColumn); Gtk.ListStore viewListStore = new Gtk.ListStore(typeof(string), typeof(string), typeof(string) , typeof(string), typeof(string), typeof(string), typeof(string)); ViewTree2.Model = viewListStore; Gtk.CellRendererText IDCell = new Gtk.CellRendererText(); Gtk.CellRendererText NameCell = new Gtk.CellRendererText(); Gtk.CellRendererText Cell1 = new Gtk.CellRendererText(); Gtk.CellRendererText Cell2 = new Gtk.CellRendererText(); Gtk.CellRendererText Cell3 = new Gtk.CellRendererText(); Gtk.CellRendererText Cell4 = new Gtk.CellRendererText(); Gtk.CellRendererText Cell5 = new Gtk.CellRendererText(); Gtk.CellRendererText Cell6 = new Gtk.CellRendererText(); idColumn.PackStart(IDCell, true); idColumn.AddAttribute(IDCell, "text", 0); nameColumn.PackStart(NameCell, true); nameColumn.AddAttribute(NameCell, "text", 1); hColumn.PackStart(Cell1, true); hColumn.AddAttribute(Cell1, "text", 2); oColumn.PackStart(Cell2, true); oColumn.AddAttribute(Cell2, "text", 3); sColumn.PackStart(Cell3, true); sColumn.AddAttribute(Cell3, "text", 4); cColumn.PackStart(Cell4, true); cColumn.AddAttribute(Cell4, "text", 5); tColumn.PackStart(Cell5, true); tColumn.AddAttribute(Cell5, "text", 6); lColumn.PackStart(Cell6, true); lColumn.AddAttribute(Cell6, "text", 7); foreach (Dictionary <string, string> item in dict.Values) { viewListStore.AppendValues(item["ID"], item[cn[0]], item[cn[1]], item[cn[2]], item[cn[3]], item[cn[4]], item[cn[5]], item[cn[6]]); } ViewTree2.ShowAll(); /* * idColumn.PackStart(IDCell, true); * idColumn.AddAttribute(IDCell, "text", 0); * * //viewListStore.AppendValues(item[cn[0]]); * * nameColumn.PackStart(NameCell, true); * nameColumn.AddAttribute(NameCell, "text", 1); * * //viewListStore.AppendValues(item[cn[1]]); * * hColumn.PackStart(Cell1, true); * hColumn.AddAttribute(Cell1, "text", 2); * * //viewListStore.AppendValues(item[cn[2]]); * * oColumn.PackStart(Cell2, true); * oColumn.AddAttribute(Cell2, "text", 3); * * //viewListStore.AppendValues(item[cn[3]]); * * sColumn.PackStart(Cell3, true); * sColumn.AddAttribute(Cell3, "text", 4); * * //viewListStore.AppendValues(item[cn[4]]); * * cColumn.PackStart(Cell4, true); * cColumn.AddAttribute(Cell4, "text", 5); * * //viewListStore.AppendValues(item[cn[5]]); * * tColumn.PackStart(Cell5, true); * tColumn.AddAttribute(Cell5, "text", 6); * * //viewListStore.AppendValues(item[cn[6]]); * * lColumn.PackStart(Cell6, true); * lColumn.AddAttribute(Cell6, "text", 7);*/ }