Esempio n. 1
0
        private void AddGroup_Click(object sender, EventArgs e)
        {
            GroupForm groupForm = new GroupForm();

            if (groupForm.ShowDialog() == DialogResult.OK)
            {
                CurrentProject.Groups.Add(groupForm.ReturnValue);
                CurrentProject.Do(new AddGroup(groupForm.ReturnValue));
                UpdateGroupView();
            }
            groupForm.Dispose();
        }
Esempio n. 2
0
        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;
                }
            }
        }