コード例 #1
0
        private void buttonAddNewMember_Click(object sender, EventArgs e)
        {
            // unselect any member and set the target tab (see
            //  tabControlProjectMetaData_Selected for what happens)
            listBoxTeamMembers.SelectedIndex = -1;

            EditMemberForm dlg = new EditMemberForm(null);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (listBoxTeamMembers.Items.Contains(dlg.MemberName))
                {
                    MessageBox.Show(String.Format("Oops... you already have a member with the name, '{0}'. If you meant to edit that member, then select the name in the listbox and click the 'Edit Member' button", dlg.MemberName));
                    return;
                }

                Modified = true;

                TeamMemberData theNewMemberData;
                if (m_mapNewMembersThisSession.TryGetValue(dlg.MemberName, out theNewMemberData))
                {
                    // I don't see how this could happen... this must have been from back when
                    //  you could edit and add in a similar way. Now *Add* means *add a new one*
                    //  and they can't exist in this map...
                    System.Diagnostics.Debug.Assert(false);

                    // must just be editing the already added member...
                    System.Diagnostics.Debug.Assert(listBoxTeamMembers.Items.Contains(dlg.MemberName));

                    theNewMemberData.MemberType   = dlg.MemberType;
                    theNewMemberData.Email        = dlg.Email;
                    theNewMemberData.AltPhone     = dlg.AltPhone;
                    theNewMemberData.Phone        = dlg.Phone;
                    theNewMemberData.BioData      = dlg.BioData;
                    theNewMemberData.SkypeID      = dlg.SkypeID;
                    theNewMemberData.TeamViewerID = dlg.TeamViewerID;

                    // update the role listbox
                    int nIndex = listBoxTeamMembers.Items.IndexOf(dlg.MemberName);
                    listBoxMemberRoles.Items[nIndex] = TeamMemberData.GetMemberTypeAsDisplayString(theNewMemberData.MemberType);
                }
                else
                {
                    // add this new user to the proj file
                    theNewMemberData = new TeamMemberData(dlg.MemberName,
                                                          dlg.MemberType, String.Format("mem-{0}", Guid.NewGuid()),
                                                          dlg.Email, dlg.SkypeID, dlg.TeamViewerID, dlg.Phone, dlg.AltPhone,
                                                          dlg.BioData);

                    _dataTeamMembers.Add(dlg.MemberName, theNewMemberData);
                    m_mapNewMembersThisSession.Add(dlg.MemberName, theNewMemberData);
                    listBoxTeamMembers.Items.Add(dlg.MemberName);
                    listBoxMemberRoles.Items.Add(TeamMemberData.GetMemberTypeAsDisplayString(theNewMemberData.MemberType));
                    listBoxTeamMembers.SelectedItem = dlg.MemberName;
                }
            }
        }
コード例 #2
0
        private void buttonEditMember_Click(object sender, EventArgs e)
        {
            // this button should only be enabled if a team member is selected
            System.Diagnostics.Debug.Assert(listBoxTeamMembers.SelectedIndex != -1);
            int nIndex = listBoxTeamMembers.SelectedIndex;

            m_strSelectedMember = (string)listBoxTeamMembers.SelectedItem;
            System.Diagnostics.Debug.Assert(_dataTeamMembers.ContainsKey(m_strSelectedMember));
            TeamMemberData theMemberData = _dataTeamMembers[m_strSelectedMember];
            EditMemberForm dlg           = new EditMemberForm(theMemberData);

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Modified = true;

            // if the name of the edited item has been changed and the new name is already
            //  in use, then don't change the name
            if ((dlg.MemberName != m_strSelectedMember) &&
                _dataTeamMembers.ContainsKey(dlg.MemberName))
            {
                MessageBox.Show(String.Format("Oops... you already have a member with the name, '{0}'. If you meant to edit that member, then select the name in the listbox and click the 'Edit Member' button.", dlg.MemberName));
            }
            else
            {
                theMemberData.Name = dlg.MemberName;
            }

            theMemberData.MemberType   = dlg.MemberType;
            theMemberData.Email        = dlg.Email;
            theMemberData.AltPhone     = dlg.AltPhone;
            theMemberData.Phone        = dlg.Phone;
            theMemberData.BioData      = dlg.BioData;
            theMemberData.SkypeID      = dlg.SkypeID;
            theMemberData.TeamViewerID = dlg.TeamViewerID;

            // update the role listbox
            listBoxMemberRoles.Items[nIndex] = TeamMemberData.GetMemberTypeAsDisplayString(theMemberData.MemberType);
            if (theMemberData.Name != m_strSelectedMember)
            {
                _dataTeamMembers.Remove(m_strSelectedMember);
                m_strSelectedMember = theMemberData.Name;
                _dataTeamMembers.Add(m_strSelectedMember, theMemberData);
            }

            listBoxTeamMembers.Items[nIndex] = theMemberData.Name;

            // keep a hang on it so we don't try to, for example, give it a new guid
            if (!m_mapNewMembersThisSession.ContainsKey(dlg.MemberName))
            {
                m_mapNewMembersThisSession.Add(dlg.MemberName, theMemberData);
            }
        }