private void Reload() { if (fetching) { return; } fetching = true; if (Row.DefaultRow == null) { Row.DefaultRow = Table.Controls[0].Clone(); } Project.GetAll((res) => { Data = res; Table.Controls.Clear(); Table.RowStyles.Clear(); Table.RowCount = Data.Count(); Data.ForEach(x => { var row = new Row(x); RowStyle style = new RowStyle() { SizeType = SizeType.Absolute, Height = 48 }; Table.Controls.Add(row.control); row.Clicked += (s, e) => PhaseSelection.Open(s as Project); SetMenu(x, row.control); Table.RowStyles.Add(style); }); Table.Controls.Add(new Panel()); Table.Refresh(); fetching = false; }); void SetMenu(Project p, Control c) { var Menu = new ContextMenu(); c.ContextMenu = Menu; MenuItem edit = new MenuItem("Edit " + p.name); MenuItem locations = new MenuItem("See Locations"); Menu.MenuItems.Add(edit); Menu.MenuItems.Add(locations); edit.Click += (s, e) => NewProject.Open(p, (saved) => { if (saved) { Reload(); } }); locations.Click += (s, e) => LocationsPage.Show(p); } }
public static void Open(Project p) { if (control == null) { control = new PhaseSelection(); } Form1.Navigate(control); control.project = p; }
private void Reload() { if (fetching) { return; } fetching = true; if (Row.DefaultRow == null) { Row.DefaultRow = Table.Controls[0].Clone(); } Project.GetAll((res) => { Data = res; Table.Controls.Clear(); Table.RowStyles.Clear(); Table.RowCount = Data.Count(); Data.ForEach(x => { var row = new Row(x); RowStyle style = new RowStyle() { SizeType = SizeType.Absolute, Height = 48 }; Table.Controls.Add(row.control); row.Clicked += (s, e) => PhaseSelection.Open(s as Project); row.RightClicked += (s, e) => NewProject.Open(x, (saved) => { if (saved) { Reload(); } }); Table.RowStyles.Add(style); }); Table.Controls.Add(new Panel()); Table.Refresh(); fetching = false; }); }
private void PhaseSelection_Load(object sender, EventArgs e) { control = this; control.TopLevel = false; AutoScroll = true; }