private void AddMember_Click(object sender, EventArgs e) { MemberForm memberForm = new MemberForm(CurrentProject); if (memberForm.ShowDialog() == DialogResult.OK) { CurrentProject.AddPerson(memberForm.ValueReturn); CurrentProject.Do(new AddMember(memberForm.ValueReturn)); UpdateGroupView(); } memberForm.Dispose(); }
private void UpdatePropertiesButtons() { ComponentResourceManager res = new ComponentResourceManager(typeof(Form1)); if (listView.SelectedItems.Count == 0) { properties.Enabled = false; } else if (listView.SelectedItems.Count == 1) { EventHandler action = (x, y) => { MemberForm memberForm = new MemberForm(CurrentProject.FindPerson((Guid)listView.SelectedItems[0].Tag), CurrentProject); if (memberForm.ShowDialog() == DialogResult.OK) { UpdateGroupView(); } memberForm.Dispose(); }; listMenu.MenuItems.Add(res.GetString("properties"), action) .Enabled = unlocked.CanChangeMember; if (lastPropertiesButtonAction != null) { properties.Click -= lastPropertiesButtonAction; } properties.Click += action; lastPropertiesButtonAction = action; properties.Enabled = unlocked.CanChangeMember; } else { bool inOneGroup = true; Group lastGroup = null; foreach (ListViewItem item in listView.SelectedItems) { Person person = CurrentProject.FindPerson((Guid)item.Tag); if (lastGroup == null) { lastGroup = person.Group; } else if (person.Group != lastGroup) { inOneGroup = false; break; } } if (inOneGroup) { EventHandler action = (x, y) => { GroupForm form = new GroupForm(lastGroup); Group oldGroup = lastGroup.Clone() as Group; if (form.ShowDialog() == DialogResult.OK) { CurrentProject.Do(new ChangeGroupProperties(oldGroup, lastGroup)); UpdateGroupView(); DrawCharts(); } form.Dispose(); }; listMenu.MenuItems.Add(res.GetString("properties"), action) .Enabled = unlocked.CanChangeMember; if (lastPropertiesButtonAction != null) { properties.Click -= lastPropertiesButtonAction; } properties.Click += action; lastPropertiesButtonAction = action; } } }