Exemplo n.º 1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.AllEventsWindow1 = ((EventDisplay.AllEventsWindow)(target));
                return;

            case 2:
                this.AEWTodaysEventsTB = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:
                this.AEWDateTB = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.AEWCloseWindow = ((System.Windows.Controls.Button)(target));

            #line 40 "..\..\AllEventsWindow.xaml"
                this.AEWCloseWindow.Click += new System.Windows.RoutedEventHandler(this.AEWCloseWindow_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.AEWListView = ((System.Windows.Controls.ListView)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemplo n.º 2
0
        private void AllEventsButton_Click(object sender, RoutedEventArgs e)
        {
            AllEventsWindow aew = new AllEventsWindow();

            //We want to split our event list into different age groups so we can seperate them and sort them by age range
            List <EventDetails> AdultPrograms    = new List <EventDetails>();
            List <EventDetails> TeenPrograms     = new List <EventDetails>();
            List <EventDetails> ChildrenPrograms = new List <EventDetails>();

            string todaysDateString = DateTime.Today.ToString("MMMM d, yyyy");

            //string todaysDateString = DateTime.Today.ToString("May 1, 2019");
            aew.AEWDateTB.Text = todaysDateString;

            foreach (EventDetails ev in eventList)
            {
                //Change the apostraphe hex code back into the apostraphe
                if (ev.Name.Contains("&#039;"))
                {
                    ev.Name = ev.Name.Replace("&#039;", "'");
                }

                //Change the ampersand hex code back into the ampersand
                if (ev.Name.Contains("&amp;"))
                {
                    ev.Name = ev.Name.Replace("&amp;", "&");
                }

                //Change the double quote hex code back into the double quote
                if (ev.Name.Contains("&quot;"))
                {
                    ev.Name = ev.Name.Replace("&quot;", "\"");
                }

                //If the event had the Adult age range and occurs on todays date, add to the AdultPrograms list
                if (ev.AgeRange == "Adult")
                {
                    if (ev.Date == todaysDateString)
                    {
                        AdultPrograms.Add(ev);
                    }
                }

                //If the event had the Teen age range and occurs on todays date, add to the TeenPrograms list
                if (ev.AgeRange == "Teen")
                {
                    if (ev.Date == todaysDateString)
                    {
                        TeenPrograms.Add(ev);
                    }
                }

                //There are three different age ranges that correspond to Childrens programs. If the the age range is any of the three listed below, and it's on todays date, add it to ChildrensPrograms
                if (ev.AgeRange == "School Age" || ev.AgeRange == "Infant/Toddler/Preschool" || ev.AgeRange == "Family" || ev.AgeRange == "Infant/Toddler/Preschool, School Age, Family")
                {
                    if (ev.Date == todaysDateString)
                    {
                        ChildrenPrograms.Add(ev);
                    }
                }
            }

            //Header that will indicate the start of the Children's Programs. Will be bolded in the list view
            ListViewHeaders childHeader = new ListViewHeaders
            {
                Time = "Time",
                Name = "Children's Programs",
                Room = "Location"
            };

            //Header that will indicate the start of the Teens Programs. Will be bolded in the list view
            ListViewHeaders teenHeader = new ListViewHeaders
            {
                Time = "Time",
                Name = "Teen Programs",
                Room = "Location"
            };

            //Header that will indicate the start of the Adults Programs. Will be bolded in the list view
            ListViewHeaders adultHeader = new ListViewHeaders
            {
                Time = "Time",
                Name = "Adult Programs",
                Room = "Location"
            };

            //We need a blank item that we can insert at the end of each of the program age ranges.
            ListViewHeaders blankLine = new ListViewHeaders();


            if (ChildrenPrograms.Count != 0)
            {
                aew.AEWListView.Items.Add(childHeader);

                foreach (EventDetails ev in ChildrenPrograms)
                {
                    if (ev.Date == todaysDateString)
                    {
                        aew.AEWListView.Items.Add(ev);
                    }
                }

                aew.AEWListView.Items.Add(blankLine);
            }

            if (TeenPrograms.Count != 0)
            {
                aew.AEWListView.Items.Add(teenHeader);

                foreach (EventDetails ev in TeenPrograms)
                {
                    if (ev.Date == todaysDateString)
                    {
                        aew.AEWListView.Items.Add(ev);
                    }
                }

                aew.AEWListView.Items.Add(blankLine);
            }

            if (AdultPrograms.Count != 0)
            {
                aew.AEWListView.Items.Add(adultHeader);

                foreach (EventDetails ev in AdultPrograms)
                {
                    if (ev.Date == todaysDateString)
                    {
                        aew.AEWListView.Items.Add(ev);
                    }
                }

                aew.AEWListView.Items.Add(blankLine);
            }

            //If we have no events. We don't want to just display a blank list. So this changes the background image to a welcome message.
            ImageBrush noEventsImageBrush = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), @"/Images/NoEventsBackground.jpg")));

            //If there are no events: Change background, and hide all elements
            if (AdultPrograms.Count == 0 && TeenPrograms.Count == 0 && ChildrenPrograms.Count == 0)
            {
                aew.Background                   = noEventsImageBrush;
                aew.AEWDateTB.Visibility         = Visibility.Hidden;
                aew.AEWTodaysEventsTB.Visibility = Visibility.Hidden;
                aew.AEWListView.Visibility       = Visibility.Hidden;
                aew.Show();
            }
            else
            {
                aew.Show();
            }
        }