コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: dnguyen06/hciecr
        // 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);
                }
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: dnguyen06/hciecr
        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;
            }
        }