Beispiel #1
0
        /**
         * Handler for when the label for an APNode is changed
         */
        private void afterAPLabelEdit_handler(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label != null)
            {
                /* New name should have a length > 0 */
                if (e.Label.Length == 0)
                {
                    /* Cancel the label edit action, inform the user, and
                     * place the node in edit mode again. */
                    e.CancelEdit = true;
                    MessageBox.Show("New name cannot be blank");
                    e.Node.BeginEdit();
                }

                /* Update the name of the node in DB an UI */
                UITreeViewNode apNode = e.Node as UITreeViewNode;
                DBResult       res    = this.db.updateName(apNode.type, apNode.id, e.Label.ToString());
                if (res.ecode == ErrorCode.OP_SUCCESS)
                {
                    apNode.Text = e.Label.ToString();
                }
                else
                {
                    e.CancelEdit = true;
                    this.showDBError(res);
                }
            }
        }
Beispiel #2
0
        /**
         * Handler for when the label for a PPNode is changed
         */
        private void participantPanel_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label != null)
            {
                /* New name should have a length > 0 */
                if (e.Label.Length == 0)
                {
                    /* Prompt user to re-enter a new name */
                    e.CancelEdit = true;
                    MessageBox.Show("New name cannot be blank");
                    e.Node.BeginEdit();
                }

                /* Update the name of the node in DB an UI */
                UITreeViewNode ppNode = e.Node as UITreeViewNode;
                DBResult       res    = this.db.updateName(ppNode.type, ppNode.id, e.Label.ToString());
                if (res.ecode == ErrorCode.OP_SUCCESS)
                {
                    ppNode.Text = e.Label.ToString();
                }
                else
                {
                    e.CancelEdit = true;
                    this.showDBError(res);
                }
            }
        }
Beispiel #3
0
        /**
         * -----------------------------------
         * PARTICIPANT PANEL (TREE VIEW)
         * -----------------------------------
         */
        #region Participant Panel handlers

        /**
         * Updates the reference participant node that was
         * clicked on
         */
        private void getPPNodeFromClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
            {
                // Select the clicked node
                this.curPPNode = this.participantPanel.GetNodeAt(e.X, e.Y) as UITreeViewNode;
            }
        }
        private void apComponentCM_rename_Click(object sender, EventArgs e)
        {
            if (this.curAPNode != null)
            {
                UITreeViewNode cn = this.curAPNode;
                cn.BeginEdit();
            }

            /* NOTE: The update in the DB is handled by the
             * afterAPLabelEdit_handler function
             */
        }
Beispiel #5
0
        /**
         * Rename group
         */
        private void ppGroupCM_rename_Click(object sender, EventArgs e)
        {
            if (this.curPPNode != null)
            {
                /* Get the group node object */
                UITreeViewNode cn = this.curPPNode;

                /* change the text value */
                cn.BeginEdit();

                /* NOTE: The update in the DB is handled by the
                 * afterPPLabelEdit_handler function
                 */
            }
        }
Beispiel #6
0
        /**
         * -----------------------------------
         * CONTEXT MENU STRIP HANDLERS FOR PP
         * -----------------------------------
         */

        #region Right-clicking on nothing

        /**
         * New -> Group
         */
        private void ppCM_new_group_Click(object sender, EventArgs e)
        {
            /* Create a new node that corresponds to a new group */
            string newGroupName = "New Group";        /* default */

            /* TODO: Update DB with the new group */
            // int result = this.db.addNewGroup(newGroupName, this.curSelCourseID)
            UITreeViewNode newGroupNode =
                new UITreeViewNode(EntityConstants.EntityType.Group,
                                   newGroupName,
                                   null,                 /* groups have no parent nodes */
                                   this.ppGroupContextMenu);

            // newGroupNode.id = result
            this.participantPanel.Nodes.Add(newGroupNode);
        }
Beispiel #7
0
        /**
         * Remove the selected student
         */
        private void ppStudentCM_delete_Click(object sender, EventArgs e)
        {
            /* Prompt user to confirm */
            if (MessageBox.Show(DialogueMessages.STUDENT_REMOVE_CONFIRMATION, "", MessageBoxButtons.OKCancel)
                == DialogResult.OK)
            {
                /* Reflect change in DB */
                // int result = this.db.deleteStudent(this.curPPNode.id, this.curSelCourseID);

                /* Remove this node from the parent group in UI */
                UITreeViewNode parentGroup = this.curPPNode.parentNode;
                parentGroup.Nodes.Remove(this.curPPNode);

                /* Dereference current node */
                this.curPPNode = null;
            }
        }
        /**
         * -----------------------------------
         * CONTEXT MENU STRIP HANDLERS FOR AP
         * -----------------------------------
         */
        #region Context Menu Strips Handlers - occurs when a right click is made

        #region Right-clicking on nothing

        /**
         * "New -> Course"
         */
        private void apCM_new_course_Click(object sender, EventArgs e)
        {
            /* Create a new node that corresponds to a new course */
            string newCourseName = "New Course";        /* default */

            /* TODO: Update DB with the new course */
            // Course newCourse = this.db.addNewCourse(newCourseName);

            UITreeViewNode newCourseNode =
                new UITreeViewNode(EntityConstants.EntityType.Course,
                                   newCourseName,        /* default name of new course */
                                   null,                 /* courses have no parent nodes */
                                   this.apCourseContextMenu);

            // newCourseNode.id = result
            this.assessmentPanel.Nodes.Add(newCourseNode);
        }
Beispiel #9
0
        /**
         * New -> Student
         */
        private void ppGroupCM_new_student_Click(object sender, EventArgs e)
        {
            if (this.curPPNode != null)
            {
                /* Create a new student node for the associated group */
                string newStudentName = "New Student";        /* default */

                /* TODO: Update DB with the new student */
                // int result = this.db.addNewStudent(...);
                UITreeViewNode newStudentNode =
                    new UITreeViewNode(EntityConstants.EntityType.Student,
                                       newStudentName,        /* default name of new course */
                                       this.curPPNode,
                                       this.ppStudentContextMenu);
                // newAssessmentNode.id = result
                this.curPPNode.Nodes.Add(newStudentNode);
                this.curPPNode.Expand();        /* Keep group node expanded */
            }
        }
        /**
         * New -> Component
         */
        private void apAssessmentCM_new_component_Click(object sender, EventArgs e)
        {
            if (this.curAPNode != null)
            {
                /* Create a new component node for the associated assessement */
                string newComponentName = "New Component";        /* default */

                /* TODO: Update DB with the new component */
                // int result = this.db.addNewComponent(newComponentName, null, this.curAPNode.id);
                UITreeViewNode newComponentNode =
                    new UITreeViewNode(EntityConstants.EntityType.Component,
                                       newComponentName,        /* default name of new course */
                                       this.curAPNode,
                                       this.apComponentContextMenu);
                // newAssessmentNode.id = result
                this.curAPNode.Nodes.Add(newComponentNode);
                this.curAPNode.Expand();        /* Keep assessment node expanded */
            }
        }
        /**
         * Remove this specific treenode
         */
        private void apComponentCM_delete_Click(object sender, EventArgs e)
        {
            if (this.curAPNode != null)
            {
                /* Prompt user to confirm */
                if (MessageBox.Show(DialogueMessages.COMPONENT_REMOVE_CONFIRMATION, "", MessageBoxButtons.OKCancel)
                    == DialogResult.OK)
                {
                    /* Reflect change in DB */
                    // int result = this.db.deleteComponent(this.curAPNode.id);

                    /* Remove this node from the parent course in UI */
                    UITreeViewNode parentCourse = this.curAPNode.parentNode;
                    parentCourse.Nodes.Remove(this.curAPNode);

                    /* Dereference current node */
                    this.curAPNode = null;
                }
            }
        }