Exemple #1
0
        private void resetAllButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to reset the prototype?", "Reset all", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                AllMeetings.Reset();
            }
        }
 private void cancelBtn_Click(object sender, EventArgs e)
 {
     if (this._isEditing)
     {
         //the meeting will only be removed if the user confirms this AND
         // it is already an existing meeting
         DialogResult confirmCancellation = MessageBox.Show($"Are you sure you want to cancel {this._thisMeeting}?", "Cancel Meeting", MessageBoxButtons.YesNo);
         if (confirmCancellation == DialogResult.Yes && AllMeetings.meetings.Contains(this._thisMeeting))
         {
             AllMeetings.Remove(this._thisMeeting);
             this.Close();
         }
     }
     else
     {
         this.Close();
     }
 }
Exemple #3
0
        public MainForm()
        {
            InitializeComponent();
            // set the drop down options
            impersonationComboBox.DataSource    = AllUsers.Users.ToList();
            impersonationComboBox.DisplayMember = "Name";
            this._activeUser = (User)impersonationComboBox.SelectedItem;
            //set up the devForm
            devForm.ShowIcon      = false;
            devForm.ShowInTaskbar = true;

            // Assign event handler for new meetings
            AllMeetings.meetingsUpdated += AllMeetings_meetingsUpdated;

            AllMeetings.Reset();

            Logging.AddMessage("Initialisation complete");
        }
        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();
        }