private void removeCourse(Course course, SemesterView dgv)
        {
            int semPosition = dgv.getSemesterPosition();

            dgv.removeCourse(course);
            semesterList[semPosition] = dgv.getSemester();
        }
        private void removeClass(object sender, EventArgs e, SemesterView dgv)
        {
            DataGridViewRow row    = dgv.CurrentCell.OwningRow;
            Course          course = (Course)row.DataBoundItem;

            removeCourse(course, dgv);
        }
        private void addClass(object sender, EventArgs e, SemesterView dgv)
        {
            List <Course> coursesToAdd = getClasses();
            int           semPosition  = dgv.getSemesterPosition();

            dgv.addCourses(coursesToAdd);
            semesterList[semPosition] = dgv.getSemester();
        }
        private void moveClass(object sender, EventArgs e, SemesterView dgv)
        {
            ToolStripItem   clickedItem         = sender as ToolStripItem;
            int             destinationPosition = int.Parse(clickedItem.Tag.ToString());
            DataGridViewRow row    = dgv.CurrentCell.OwningRow;
            Course          course = row.DataBoundItem as Course;

            semesterViews[destinationPosition].addCourse(course);
            removeCourse(course, dgv);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            semesterViews = new List <SemesterView>();

            int rowCounter = 4;

            foreach (Semester sem in semesterList)
            {
                if (masterGrid.RowDefinitions.Count - 2 < rowCounter)
                {
                    RowDefinition temp = new RowDefinition();
                    temp.Height = GridLength.Auto;
                    masterGrid.RowDefinitions.Add(temp);
                }

                SemesterView semView = new SemesterView(sem);
                semView.CellMouseClick += new DataGridViewCellMouseEventHandler(cellClick);
                WindowsFormsHost tempHost = new WindowsFormsHost();
                tempHost.Child  = semView;
                tempHost.Height = semView.Height;
                tempHost.Width  = semView.Width;


                if (sem.isFall)
                {
                    tempHost.SetValue(Grid.ColumnProperty, 0);
                    tempHost.SetValue(Grid.RowProperty, rowCounter);
                    semesterViews.Add(semView);
                }
                else
                {
                    tempHost.SetValue(Grid.ColumnProperty, 1);
                    tempHost.SetValue(Grid.RowProperty, rowCounter);
                    semesterViews.Add(semView);
                    rowCounter++;
                }
                masterGrid.Children.Add(tempHost);
            }

            //move back button
            RowDefinition lastRow = new RowDefinition();

            lastRow.Height = GridLength.Auto;
            masterGrid.RowDefinitions.Add(lastRow);
            thotButton.SetValue(Grid.RowProperty, masterGrid.RowDefinitions.Count - 1);
        }
        private void cellClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            SemesterView dgv = (sender as SemesterView);

            if (e.Button == MouseButtons.Right && e.RowIndex != -1 && e.ColumnIndex != -1)
            {
                DataGridViewCell cell = dgv[e.ColumnIndex, e.RowIndex];
                if (!cell.Selected)
                {
                    cell.DataGridView.ClearSelection();
                    cell.DataGridView.CurrentCell = cell;
                    cell.Selected = true;
                }
                System.Windows.Forms.ContextMenuStrip menuStrip = new System.Windows.Forms.ContextMenuStrip();

                ToolStripMenuItem move = new ToolStripMenuItem("Move a class");
                //move.Click += new EventHandler(moveClass);
                menuStrip.Items.Add(move);
                ToolStripMenuItem add = new ToolStripMenuItem("Add a class");
                add.Click += (sender2, e2) => addClass(sender2, e2, dgv);
                menuStrip.Items.Add(add);
                ToolStripMenuItem remove = new ToolStripMenuItem("Remove a class");
                remove.Click += (sender2, e2) => removeClass(sender2, e2, dgv);
                menuStrip.Items.Add(remove);

                bool isSemFall     = completedClasses.getIsFall();
                int  fallCounter   = 1;
                int  springCounter = 1;
                foreach (Semester sem in semesterList)
                {
                    int    i            = sem.position;
                    string menuItemName = "";
                    if (isSemFall)
                    {
                        menuItemName += "Fall " + fallCounter;
                        fallCounter++;
                    }
                    else
                    {
                        menuItemName += "Spring " + springCounter;
                        springCounter++;
                    }
                    ToolStripMenuItem item = new ToolStripMenuItem(menuItemName);
                    item.Tag    = sem.position;
                    item.Click += (sender2, e2) => moveClass(sender2, e2, dgv);
                    move.DropDownItems.Add(item);
                    isSemFall = !isSemFall;
                }


                //menuStrip.Items.Add("Move a class");
                //(menuStrip.Items[0] as ToolStripMenuItem).DropDownItems.Add()
                //menuStrip.Items.Add("Add a class");
                //menuStrip.Items[1].Click += new EventHandler(addClass);
                //menuStrip.Items.Add("Remove a class");
                //menuStrip.Items[2].Click += new EventHandler(removeClass);

                //menuStrip.ItemClicked += new ToolStripItemClickedEventHandler(menuClick);
                menuStrip.Show(dgv, new System.Drawing.Point(e.X + 42, e.Y));
            }
        }