private void editBtn_Click(object sender, EventArgs e)
 {
     if (this._meeting != null)
     {
         CreateMeeting cM = new CreateMeeting(this._meeting);
         cM.Show();
     }
 }
Example #2
0
        public ParticipantPanel(Meeting m, Participant p, int mode = 0, CreateMeeting cMCaller = null, User _impersonator = null)
        {
            this.cMCaller      = cMCaller;
            this.meeting       = m;
            this.participant   = p;
            this.impersonator  = _impersonator;
            this.isPriviledged = this.impersonator != null && this.meeting != null && this.impersonator == this.meeting.Initiator;
            InitializeComponent();
            this.nameLbl.Text = p.user.getName();
            if (isPriviledged)
            {
                //if this panel is being created in view of a user who is not the initiator, hide edit options
                this.roleBox.Visible   = false;
                this.roleBox.Enabled   = false;
                this.removeBtn.Enabled = false;
                this.removeBtn.Visible = false;

                if (p.status == 1)
                {
                    this.nameLbl.Text += " (Important)";
                }
                else if (p.status == 2)
                {
                    this.nameLbl.Text += " (Guest Speaker)";
                }
            }
            else if (p.status == 2)
            {
                this.nameLbl.Text += " (Guest Speaker)";
            }
            this.roleBox.SelectedIndex = p.status;
            ToolTip tTip = new ToolTip();

            tTip.ToolTipTitle = "Roles";
            tTip.SetToolTip(this.roleBox, "Standard: can request equipment.\nImportant: can request equipment & locations.\nGuest Speaker: can request equipment & locations. 1 per meeting.");
            this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
            //try to set the persons image, if this fails then the background image will be used by default
            try
            {
                this.pictureBox1.BackgroundImage = (Image)Properties.Resources.ResourceManager.GetObject(p.user.ImageName.ToString());
                if (this.meeting.Name.ToLower().Contains("funky") && this.participant.user.ImageName == "mehmet")
                {
                    this.pictureBox1.BackgroundImage = (Image)Properties.Resources.ResourceManager.GetObject("funky");
                }

                if (p.hasGivenAttendance && p.Attendance == false)
                {
                    this.pictureBox1.Image = (Image)Properties.Resources.ResourceManager.GetObject("Grey_thingy");
                }
            }
            catch (Exception e)
            {
                Logging.AddMessage(e.Message);
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            CreateMeeting cM = new CreateMeeting((User)(impersonationComboBox.SelectedItem));

            cM.Show();
        }
        private void newMeetingSaveBtn_Click(object sender, EventArgs e)
        {
            // Check to make sure the user hasn't put the meeting in a conflicting position
            Dictionary <Meeting, List <User> > conflicting = new Dictionary <Meeting, List <User> >();
            List <Meeting> lowerImportance = new List <Meeting>();

            foreach (Meeting m in _thisMeeting.IntersectingMeetings)
            {
                List <User> conflictingUsers = new List <User>();

                foreach (Participant p in _thisMeeting.Participants)
                {
                    if (m.GetParticipant(p.user)?.Attendance == true)
                    {
                        conflictingUsers.Add(p.user);
                    }
                }

                if (conflictingUsers.Count > 0)
                {
                    conflicting.Add(m, conflictingUsers);

                    if (_thisMeeting.ComparePriority(m) < 0)
                    {
                        lowerImportance.Add(m);
                    }
                }
            }

            if (conflicting.Count > 0)
            {
                // If there is a meeting of higher importance, the meeting cannot occur at this time.
                // Otherwise, offer to move one of the meetings.

                if (lowerImportance.Count < conflicting.Count)
                {
                    DialogResult result = MessageBox.Show($"One of your participants has already said they will attend a meeting of higher importance at this time.\n\nYou can choose to schedule the meeting here anyway, but it is unlikely they will attend.\n\nDo you want to schedule the meeting at this time?", "Meeting conflict", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
                else
                {
                    string listOfMeetings = "";
                    foreach (Meeting m in lowerImportance)
                    {
                        string userList = string.Join(", ", conflicting[m]);

                        listOfMeetings += $"- {m} ({userList})\n";
                    }

                    DialogResult result = MessageBox.Show($"One or more of your participants have already said they will attend a meeting of lower importance at this time::\n\n{listOfMeetings}\nYou can choose to move these meetings to make yours easier to attend.\n\nDo you want to move the conflicting meetings?", "Meeting conflict", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                    if (result == DialogResult.Yes)
                    {
                        foreach (Meeting m in lowerImportance)
                        {
                            CreateMeeting cM = new CreateMeeting(m);
                            cM.Show();
                        }
                        return;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            // If we've reached this point time slot conflicts have been sorted.
            _thisMeeting.CurrentLocation = _thisMeeting.ProvisionalLocation;

            if (_thisMeeting.CurrentLocation == null)
            {
                // List of meetings that, if moved, would give us a suitable location for this meeting.
                List <Meeting> wouldFreeSlotForUs = new List <Meeting>();
                lowerImportance.Clear();

                foreach (Meeting m in _thisMeeting.IntersectingMeetings)
                {
                    if (_thisMeeting.PotentialLocations.Contains(m.CurrentLocation))
                    {
                        wouldFreeSlotForUs.Add(m);

                        if (_thisMeeting.ComparePriority(m) < 0)
                        {
                            lowerImportance.Add(m);
                        }
                    }
                }

                if (lowerImportance.Count < wouldFreeSlotForUs.Count)
                {
                    DialogResult result = MessageBox.Show($"There is no suitable location for this meeting to take place at this time with its requirements.\n\nYou can choose to schedule the meeting here anyway, but there will be no location scheduled unless one becomes free or you edit the meeting.\n\nDo you want to schedule the meeting at this time?", "Meeting conflict", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
                else
                {
                    string listOfMeetings = "";
                    foreach (Meeting m in lowerImportance)
                    {
                        listOfMeetings += $"- {m} ({m.CurrentLocation})\n";
                    }

                    DialogResult result = MessageBox.Show($"There is no suitable location for this meeting to take place at this time with its requirements, but there are lower importance meetings that, if moved, would allow the requirements to be met::\n\n{listOfMeetings}\nYou can choose to move these meetings to free up resources for your meeting.\n\nDo you want to move the conflicting meetings?", "Meeting conflict", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                    if (result == DialogResult.Yes)
                    {
                        foreach (Meeting m in lowerImportance)
                        {
                            CreateMeeting cM = new CreateMeeting(m);
                            cM.Show();
                        }
                        return;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            // Update the meeting
            AllMeetings.Update(this._thisMeeting);

            if (editing)
            {
                if (originalTime != _thisMeeting.StartTime)
                {
                    _thisMeeting.HasBeenMoved = true;
                }
                Logging.AddMessage($"Edited meeting {_thisMeeting}");
            }
            else
            {
                Logging.AddMessage($"Created meeting {_thisMeeting}");
            }

            this.Close();
        }