Exemplo n.º 1
0
        private void PlaceOnGrid(GridSection gs)
        {
            bool inOldSpot = (Grid.GetRow(gs) == Grid.GetRow(released)) && (Grid.GetColumn(gs) == Grid.GetColumn(released)) && (Grid.GetRowSpan(released) == Grid.GetRowSpan(gs));

            Grid.SetRow(released, Grid.GetRow(gs));
            Grid.SetColumn(released, Grid.GetColumn(gs));
            Grid.SetRowSpan(released, Grid.GetRowSpan(gs));
            Grid.SetZIndex(released, -10);
            released.VerticalAlignment = VerticalAlignment.Top;
            released.Height            = gs.Height;
            released.Margin            = gs.Margin;
            released.OnGridPlace();
            released.linked = gs;
            if (gs.parentClass.enrolled && !inOldSpot)
            {
                gs.parentClass.SetEnrollment(false);
                foreach (CourseListItem cli in enrolled)
                {
                    if (cli.name.Equals(gs.parentClass.data.name))
                    {
                        cli.SetEnrollment(false, false);
                        break;
                    }
                }
            }
            released = null;
        }
Exemplo n.º 2
0
        public ClassSection(MainWindow Window, bool IsTutorial, Panel OriginalParent, ClassData Data, Brush Color, SearchItem SearchParent)
        {
            InitializeComponent();

            window       = Window;
            searchParent = SearchParent;

            originalParent = OriginalParent;
            originalMargin = new Thickness(5, 0, 5, 0);
            originalHeight = Height;

            data                = Data;
            isTutorial          = IsTutorial;
            name                = data.name;
            type                = (IsTutorial) ? "Tutorial" : "Lecture";
            SectionType.Content = type;
            radius              = new Point(BG.RadiusX, BG.RadiusY);
            color               = Color;
            BG.Fill             = Color;
            placedOnce          = false;
            onGrid              = false;
            other               = null;

            TimeSlot[] slots = (IsTutorial) ? Data.tutorialSlots : Data.timeSlots;

            sections = new GridSection[slots.Length][];
            for (int j = 0; j < slots.Length; j++)
            {
                TimeSlot t = slots[j];
                time = getTime(t.startTime, t.duration);
                GridSection[] gs = new GridSection[t.days.Length];
                for (int i = 0; i < t.days.Length; i++)
                {
                    GridSection g = new GridSection(this, name, type, color, t.location, time, t);
                    Grid.SetRow(g, (int)Math.Floor(t.startTime));
                    Grid.SetColumn(g, t.days[i]);
                    Grid.SetRowSpan(g, (int)Math.Ceiling(t.duration));
                    g.VerticalAlignment = VerticalAlignment.Top;
                    double defaultHeight = 116.5;
                    double height        = t.duration * defaultHeight;
                    g.Height = height;
                    Thickness thickness = new Thickness(0);
                    thickness.Top = (t.startTime - Math.Floor(t.startTime)) * defaultHeight;
                    g.Margin      = thickness;
                    gs[i]         = g;
                    window.ScheduleGrid.Children.Add(g);
                }
                foreach (GridSection g in gs)
                {
                    g.SetConnected(gs);
                }
                if (gs.Length > 0)
                {
                    gs[0].HideConnected();
                }
                sections[j] = gs;
            }
        }
Exemplo n.º 3
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.º 4
0
        public CourseListItem(ClassSection Section, ClassSection Other, MainWindow Window)
        {
            InitializeComponent();
            section = Section;
            other   = Other;
            window  = Window;
            name    = Section.name;
            color   = Section.color;

            SectionType.Content = name;
            BG.Fill             = color;
            isChecked           = true;
        }
Exemplo n.º 5
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.º 6
0
        public GridSection(ClassSection ParentClass, string Name, string Type, Brush HoverColor, string location, string startTime, TimeSlot Slot)
        {
            InitializeComponent();

            parentClass = ParentClass;
            hover       = HoverColor;
            timeSlot    = Slot;

            Color c = ((SolidColorBrush)HoverColor).Color;

            normal  = new SolidColorBrush(Color.FromArgb(100, c.R, c.G, c.B));
            BG.Fill = normal;

            SectionType.Content = Name + " " + Type + "\n" + location + "\n" + startTime;
            stayOnGrid          = false;
        }
Exemplo n.º 7
0
 private void CreateSearchItems()
 {
     items = new SearchItem[classes.Count];
     for (int i = 0; i < items.Length; i++)
     {
         ClassData  data = classes[i];
         SearchItem item = new SearchItem(data.name, data.ToString(), this);
         item.Course_title.Text = data.title;
         ClassSection lecture = new ClassSection(this, false, item.Sections, data, data.brush, item);
         item.Sections.Children.Add(lecture);
         if (data.hasTutorial)
         {
             ClassSection tutorial = new ClassSection(this, true, item.Sections, data, data.brush, item);
             item.Sections.Children.Add(tutorial);
             tutorial.other   = lecture;
             lecture.other    = tutorial;
             item.numSections = 2;
         }
         items[i] = item;
     }
 }
Exemplo n.º 8
0
        public MainWindow()
        {
            InitializeComponent();

            enrolled = new List <CourseListItem>();

            released = null;
            rand     = new Random();

            classColors    = new Brush[6];
            classColors[0] = CreateBrush(75, 163, 255);  // Blue
            classColors[1] = CreateBrush(191, 0, 255);   // Yellow
            classColors[2] = CreateBrush(116, 195, 101); // Green
            classColors[3] = CreateBrush(253, 255, 0);   // Purple
            classColors[4] = CreateBrush(255, 36, 0);    // Red
            classColors[5] = CreateBrush(255, 159, 0);   // Orange

            classes = GetClasses();
            CreateSearchItems();

            Garbage.Visibility = Visibility.Hidden;
        }