Exemplo n.º 1
0
        private ConfirmationWin CreateWindow(string title, string text)
        {
            ConfirmationWin win = new ConfirmationWin(this);

            win.Owner = this;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.top_win.Text          = title;
            win.question.Content      = text;
            return(win);
        }
Exemplo n.º 2
0
        // dropping a course onto the schedule
        private void ScheduleGrid_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (released != null)
            {
                bool dropConflict = false;
                foreach (UIElement ui in ScheduleGrid.Children)
                {
                    GridSection gs = ui as GridSection;
                    if (gs != null)
                    {
                        Point p = Mouse.GetPosition(gs);
                        if (IsHoveringGridSection(gs, p) && gs.parentClass == released)
                        {
                            if (!IsReleasedConflicting(gs))
                            {
                                PlaceOnGrid(gs);
                                break;
                            }
                            else
                            {
                                if (!conflicting.parentClass.data.name.Equals(gs.parentClass.data.name))
                                {
                                    ConfirmationWin win = CreateWindow("Dropping", "Are you sure you wish to drop " + conflicting.parentClass.data.name + " to add " + released.data.name + "?");
                                    win.ShowDialog();

                                    if (ConfirmResult)
                                    {
                                        dropConflict = true;
                                        PlaceOnGrid(gs);
                                    }
                                }
                            }
                        }
                    }
                }
                if (dropConflict)
                {
                    conflicting.parentClass.ResetPosition(false);
                    conflicting.parentClass.HideConnected();
                    ClassSection other = conflicting.parentClass.other;
                    if (other != null)
                    {
                        if (other.onGrid)
                        {
                            other.ResetPosition(false);
                            other.HideConnected();
                        }
                    }
                    CourseList_Clear(conflicting.parentClass.data.name);
                }
            }
        }
Exemplo n.º 3
0
        private void Window_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (released != null)
            {
                if (IsHoveringGarbage(TrashEmpty) || IsHoveringGarbage(TrashFull))
                {
                    if (released.onGrid && released.originalParent.Children.Count == 0)
                    {
                        ConfirmationWin win = CreateWindow("Dropping", "Are you sure you wish to drop: " + released.data.name);
                        win.ShowDialog();

                        if (ConfirmResult)
                        {
                            CourseList_Clear(released.name);
                            released.ResetPosition(false);
                            ClassSection other = released.other;
                            if (other != null)
                            {
                                if (other.onGrid)
                                {
                                    other.ResetPosition(false);
                                    other.HideConnected();
                                }
                            }
                        }
                        else
                        {
                            released.Margin = released.originalMargin;
                            released.OnGridPlace(true);
                        }
                    }
                    else
                    {
                        released.ResetPosition();
                    }
                }
                else
                {
                    if (released.onGrid)
                    {
                        released.Margin = new Thickness(5, 0, 5, 0);
                        released.OnGridPlace(true);
                    }
                    else
                    {
                        released.ResetPosition();
                    }
                }
                released = null;
            }
        }
Exemplo n.º 4
0
        // confirmation window
        private void Enroll_Click(object sender, RoutedEventArgs e)
        {
            List <CourseListItem> addList  = new List <CourseListItem>();
            List <CourseListItem> dropList = new List <CourseListItem>();

            foreach (UIElement ui in ListOfCourses.Children)
            {
                CourseListItem cli = ui as CourseListItem;
                if (cli != null)
                {
                    if (cli.isChecked)
                    {
                        addList.Add(cli);
                    }
                    else
                    {
                        if (enrolled.Contains(cli))
                        {
                            dropList.Add(cli);
                        }
                    }
                }
            }

            string prompt = "";
            bool   allIn  = true;

            foreach (CourseListItem cli in addList)
            {
                if (!enrolled.Contains(cli) || !cli.enrolled)
                {
                    allIn = false;
                    break;
                }
            }
            foreach (CourseListItem cli in enrolled)
            {
                if (!addList.Contains(cli) || !cli.enrolled)
                {
                    allIn = false;
                    break;
                }
            }
            if (allIn)
            {
                prompt = "Are you sure you want to confirm enrollment?";
            }
            else
            {
                if (addList.Count > 0)
                {
                    prompt += "Are you sure you want to enroll in the following courses?";
                    foreach (CourseListItem cli in addList)
                    {
                        prompt += "\n\t" + cli.name;
                    }
                }

                if (dropList.Count > 0)
                {
                    if (addList.Count > 0)
                    {
                        prompt += "\nAnd drop the following courses?";
                    }
                    else
                    {
                        prompt += "Are you sure you want to drop the following courses?";
                    }
                    foreach (CourseListItem cli in dropList)
                    {
                        prompt += "\n\t" + cli.name;
                    }
                }
            }

            ConfirmationWin win = CreateWindow("Confirming Enrollment", prompt);

            win.ShowDialog();

            if (ConfirmResult)
            {
                enrolled = addList;
                foreach (CourseListItem cli in addList)
                {
                    cli.SetEnrollment(true);
                }
                foreach (CourseListItem cli in dropList)
                {
                    cli.SetEnrollment(false);
                }
            }
        }