Exemplo n.º 1
0
        /*** INVITATIONS METHODS ***/
        /// <summary>
        /// Displays the currently selected outgoing or incoming invitation while managing related UI elements.
        /// Runs whenever an update to invitation information occurs.
        /// </summary>
        private void PopulateInvitation()
        {
            // Delete any inactive invitations prior to displaying them
            network.DeleteInactiveInvitations();
            // Will store the list of invitations
            List <Invitation> invitations = null;

            // Check if incoming invitations must be displayed
            if (invitationState == InvitationType.Incoming)
            {
                // Indicate that the incoming invitations are shown
                lblInvitationListHeading.Text = "Incoming Invitations";
                // Get the user's incoming invitations
                invitations = user.IncomingInvitations;
            }
            // Otherwise, outgoing invitations must be displayed
            else
            {
                // Indicate that the outgoing invitations are shown
                lblInvitationListHeading.Text = "Outgoing Invitations";
                // Get the user's outgoing invitations
                invitations = user.OutgoingInvitations;
            }

            // Set the invitation font to regular. This will be changed to bold if the invitation has been accepted by the user.
            txtInvitation.Font = new Font(Font, FontStyle.Regular);
            // By default, disable the accept invitation button
            btnAcceptInvitation.Enabled = false;

            // Ensure that the invitation index is within bounds
            invitationIndex = RestrictWithinBounds(invitationIndex, invitations.Count);
            // Disable or enable the invitation up or down buttons according to list position
            SetScrollButtonActivity(btnInvitationDown, btnInvitationUp, invitationIndex, invitations);

            // Check if there are any invitations to display
            if (invitations.Any())
            {
                // Get the invitation to be displayed
                Invitation selectedInvitation = invitations[invitationIndex];
                // Display the invitation in a label
                txtInvitation.Text = selectedInvitation.ToString(user);

                // Check if the user is a recipient of the invitation
                if (invitationState == InvitationType.Incoming)
                {
                    // Check if the user has accepted the invitation
                    if (selectedInvitation.GetInvitationStateOfRecipient(user) == InvitationStatus.Accepted)
                    {
                        // Set the invitation font to bold to show that it has been accepted
                        txtInvitation.Font = new Font(Font, FontStyle.Bold);
                    }
                    // Otherwise, the user has not accepted the invitation
                    else
                    {
                        // Enable the accept invitation button since there is an invitation to accept
                        btnAcceptInvitation.Enabled = true;
                    }
                }
            }
            // Otherwise, display a placeholder
            else
            {
                // Show the placeholder in the textbox
                txtInvitation.Text = "No invitation";
            }


            // The delete invitation button should be enabled if and only if there is an invitation to delete
            btnDeleteInvitation.Enabled = invitations.Any();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deletes an outgoing invitation from this user's outgoing invitation list.
 /// </summary>
 /// <remarks>
 /// When this is called by the Network class, the network completely removes the invitation from the network.
 /// </remarks>
 /// <param name="invitation">The non-null outgoing invitation to delete.</param>
 public void DeleteOutgoingInvitation(Invitation invitation)
 {
     // Remove the invitation
     outgoingInvitations.Remove(invitation);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds an outgoing invitation to this Person's outgoing invitations list.
 /// </summary>
 /// <param name="invitation">The non-null outgoing invitation to add.</param>
 public void AddOutgoingInvitation(Invitation invitation)
 {
     // Add the invitation to the list
     outgoingInvitations.Add(invitation);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Receives an incoming invitation into the person's pending list.
 /// </summary>
 /// <param name="invitation">Non-null invitation to receive.</param>
 public void ReceiveInvitation(Invitation invitation)
 {
     // Add the invitation to the received list
     incomingInvitations.Add(invitation);
 }