Example #1
0
        public override void Initialize()
        {
            selectedMealPlan     = new List <MealPlan>(new MealPlan[rooms.Count]);
            selectedWebsitePrice = new List <Tuple <Website, int> >(new Tuple <Website, int> [rooms.Count]);
            int    boxSpacing = 50;
            double cardWidth  = canvas.Width - 0.2 * canvas.Width;
            double cardHeight = 0.7 * canvas.Height;

            canvas.Background = new SolidColorBrush(Color.FromRgb(239, 239, 239));

            ScrollViewer roomScrollViewer = new ScrollViewer
            {
                Height = canvas.Height
            };

            canvas.Children.Add(roomScrollViewer);

            StackPanel roomCardStackPanel = new StackPanel();

            roomScrollViewer.Content = roomCardStackPanel;

            for (int i = 0; i < rooms.Count; i++)
            {
                Room room = rooms[i];

                //creates room card
                Border cardBorder = new Border
                {
                    BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                    BorderThickness = new Thickness(3),
                    Width           = cardWidth,
                    Margin          = new Thickness(0.1 * canvas.Width, boxSpacing, 0.1 * canvas.Width, 0)
                };
                Grid roomGrid = new Grid
                {
                    Width = cardWidth,

                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(0.4 * cardWidth)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(0.6 * cardWidth)
                        }
                    },
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        }
                    }
                };
                cardBorder.Child = roomGrid;
                roomCardStackPanel.Children.Add(cardBorder);

                //set card image
                Image roomImage = room.image.GetImage();
                roomImage.MaxWidth  = 0.35 * cardWidth;
                roomImage.MaxHeight = 0.85 * cardHeight;
                Grid.SetColumn(roomImage, 0);
                Grid.SetRow(roomImage, 0);
                roomGrid.Children.Add(roomImage);

                //set roomdatastackpanel
                StackPanel roomDataStackPanel = new StackPanel
                {
                    Width  = 0.6 * cardWidth,
                    Height = 0.85 * cardHeight,
                };
                Grid.SetColumn(roomDataStackPanel, 1);
                Grid.SetRow(roomDataStackPanel, 0);
                roomGrid.Children.Add(roomDataStackPanel);

                //set room type
                Label roomTypeLabel = new Label
                {
                    Content  = "Room Type: " + room.type.name,
                    FontSize = 22,
                    Margin   = new Thickness(0, 0.2 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(roomTypeLabel);

                //set hotel name
                Label roomHotelLabel = new Label
                {
                    Content  = "Hotel: " + room.hotel.name,
                    FontSize = 22,
                    Margin   = new Thickness(0, 0.05 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(roomHotelLabel);

                //set room price
                Label roomPriceLabel = new Label
                {
                    Content  = "Price: ",
                    FontSize = 22,
                    Margin   = new Thickness(0, 0.05 * cardHeight, 0, 0)
                };
                roomDataStackPanel.Children.Add(roomPriceLabel);

                //set view more button
                Grid grid = new Grid
                {
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(0.5 * roomDataStackPanel.Width)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(0.5 * roomDataStackPanel.Width)
                        }
                    },
                    Margin = new Thickness(0, 0.05 * cardHeight, 0, 0)
                };

                Label locationLabel = new Label
                {
                    Content  = "Loaction: " + room.hotel.location.city + ", " + room.hotel.location.country,
                    FontSize = 22,
                };
                Grid.SetColumn(locationLabel, 0);
                grid.Children.Add(locationLabel);

                Button viewMoreButton = FrontEndHelper.CreateButton(cardWidth * 0.1, cardHeight * 0.1, "Reserve");

                Grid.SetColumn(viewMoreButton, 1);
                grid.Children.Add(viewMoreButton);
                roomDataStackPanel.Children.Add(grid);

                //creates view more expander
                Expander viewMoreExpander = new Expander
                {
                    Width  = canvas.Width,
                    Margin = new Thickness(0, 0, 0, 0.05 * cardHeight),
                    Header = "More Data"
                };
                Grid.SetColumnSpan(viewMoreExpander, 2);
                Grid.SetRow(viewMoreExpander, 1);
                roomGrid.Children.Add(viewMoreExpander);

                //creates tabs
                TabControl MoreDetailsTabs = new TabControl();
                viewMoreExpander.Content   = MoreDetailsTabs;
                MoreDetailsTabs.Background = new SolidColorBrush(Color.FromRgb(239, 239, 239));

                //creates meals tab
                TabItem MealsTab = new TabItem {
                    Header = "Meals"
                };
                StackPanel MealsPanel = new StackPanel();
                MealsTab.Content = MealsPanel;
                MoreDetailsTabs.Items.Add(MealsTab);

                for (int j = 0; j < room.hotel.mealPlans.Count; j++)
                {
                    MealPlan    mealPlan            = room.hotel.mealPlans[j];
                    RadioButton mealPlanRadioButton = new RadioButton
                    {
                        GroupName = "MealPlanRadioGroup " + i.ToString(),
                        Content   = mealPlan,
                        FontSize  = 22,
                        Margin    = new Thickness(0, 0.025 * cardHeight, 0, 0)
                    };
                    mealPlanRadioButton.Checked += mealRadioButtonChecked;
                    if (j == 0)
                    {
                        mealPlanRadioButton.IsChecked = true;
                    }
                    MealsPanel.Children.Add(mealPlanRadioButton);
                }

                //creates website and prices tab
                TabItem websitesTab = new TabItem {
                    Header = "Websites"
                };
                StackPanel websitesPanel = new StackPanel();
                websitesTab.Content = websitesPanel;
                MoreDetailsTabs.Items.Add(websitesTab);

                List <Tuple <Website, int> > websitePrice = DataModels.GetInstance().GetWebsitePricesForRoom(room);
                for (int j = 0; j < websitePrice.Count; j++)
                {
                    RadioButton websitePriceRadioButton = new RadioButton
                    {
                        GroupName   = "WebsitePriceRadioGroup " + i.ToString(),
                        DataContext = websitePrice[j],
                        Content     = websitePrice[j].Item1.name + " , " + websitePrice[j].Item2.ToString(),
                        FontSize    = 22,
                        Margin      = new Thickness(0, 0.025 * cardHeight, 0, 0)
                    };
                    websitePriceRadioButton.Checked += webstiePriceRadioButtonChecked;
                    if (j == 0)
                    {
                        websitePriceRadioButton.IsChecked = true;
                    }
                    websitesPanel.Children.Add(websitePriceRadioButton);
                }

                //creates room view tab
                TabItem roomViewsTab = new TabItem {
                    Header = "Views"
                };
                StackPanel roomViewsPanel = new StackPanel();
                roomViewsTab.Content = roomViewsPanel;
                MoreDetailsTabs.Items.Add(roomViewsTab);

                foreach (RoomView view in room.views)
                {
                    Label viewLabel = new Label
                    {
                        Content  = view.view,
                        FontSize = 22,
                        Margin   = new Thickness(0, 0.025 * cardHeight, 0, 0)
                    };
                    roomViewsPanel.Children.Add(viewLabel);
                }

                //create room photos
                TabItem hotelPhotosTab = new TabItem {
                    Header = "Photos"
                };
                Canvas hotelPhotosCanvas = new Canvas
                {
                    Width  = cardWidth,
                    Height = 300
                };
                hotelPhotosTab.Content = hotelPhotosCanvas;
                MoreDetailsTabs.Items.Add(hotelPhotosTab);

                List <CustomImage> images = new List <CustomImage>();
                images.Add(room.hotel.image);
                foreach (HotelFacility facility in room.hotel.facilities)
                {
                    images.Add(facility.image);
                }
                foreach (PlaceOfIntrest placeOfIntrest in room.hotel.location.placesOfIntrest)
                {
                    images.Add(placeOfIntrest.image);
                }
                ImageAlbum hotelAlbum = new ImageAlbum(hotelPhotosCanvas, 25, 25, 250, 250, images);

                //creates room reviews
                TabItem roomReviewsTab = new TabItem {
                    Header = "Room Reviews"
                };
                StackPanel roomReviewsStackPanel = new StackPanel();
                roomReviewsTab.Content = roomReviewsStackPanel;
                MoreDetailsTabs.Items.Add(roomReviewsTab);

                List <Booking> roomBookings = DataModels.GetInstance().GetRoomBookings(room);
                for (int j = 0; j < roomBookings.Count; j++)
                {
                    Booking booking = roomBookings[j];
                    Border  roomBookingCardBorder = new Border
                    {
                        Width               = 0.8 * cardWidth,
                        BorderBrush         = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                        BorderThickness     = new Thickness(3),
                        HorizontalAlignment = HorizontalAlignment.Left
                    };
                    if (j == roomBookings.Count - 1)
                    {
                        roomBookingCardBorder.Margin = new Thickness(0.1 * cardWidth, 25, 0.1 * cardWidth, 25);
                    }
                    else
                    {
                        roomBookingCardBorder.Margin = new Thickness(0.1 * cardWidth, 25, 0.1 * cardWidth, 0);
                    }
                    StackPanel roomBookingCardPanel = new StackPanel();
                    roomBookingCardBorder.Child = roomBookingCardPanel;
                    roomReviewsStackPanel.Children.Add(roomBookingCardBorder);

                    Label userNameLabel = new Label
                    {
                        Content  = "User Name : " + booking.bookingUser.username,
                        FontSize = 22
                    };
                    roomBookingCardPanel.Children.Add(userNameLabel);

                    Label ratingLabel = new Label
                    {
                        Content  = "Rating : " + booking.bookingReview.rating,
                        FontSize = 22
                    };
                    roomBookingCardPanel.Children.Add(ratingLabel);

                    Label startDateLabel = new Label
                    {
                        Content  = "From " + booking.startDate.ToShortDateString() + " To " + booking.endDate.ToShortDateString(),
                        FontSize = 22
                    };
                    roomBookingCardPanel.Children.Add(startDateLabel);

                    TextBlock description = new TextBlock
                    {
                        Width        = 0.8 * cardWidth - 5,
                        Text         = "Description : " + booking.bookingReview.description,
                        FontSize     = 22,
                        Margin       = new Thickness(0, 0, 0, 10),
                        TextWrapping = TextWrapping.WrapWithOverflow,
                        Padding      = new Thickness(5, 0, 0, 0)
                    };
                    roomBookingCardPanel.Children.Add(description);
                }
            }
        }
Example #2
0
        public override void Initialize()
        {
            double       cardWidth    = 0.8 * canvas.Width;
            ScrollViewer scrollViewer = new ScrollViewer
            {
                Height = canvas.Height
            };

            canvas.Children.Add(scrollViewer);

            StackPanel hotelCardsStackPanel = new StackPanel
            {
                Width = canvas.Width
            };

            scrollViewer.Content = hotelCardsStackPanel;

            Button addHotelButton = FrontEndHelper.CreateButton(120, 60, "Add Hotel");

            addHotelButton.HorizontalAlignment = HorizontalAlignment.Right;
            addHotelButton.Margin = new Thickness(0, 20, 0.1 * canvas.Width, 0);
            addHotelButton.Click += AddHotelButton_Click;
            hotelCardsStackPanel.Children.Add(addHotelButton);

            for (int i = 0; i < hotels.Count; i++)
            {
                Hotel hotel = hotels[i];

                Border border = new Border
                {
                    Width           = cardWidth,
                    BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                    BorderThickness = new Thickness(3)
                };
                if (i == hotels.Count - 1)
                {
                    border.Margin = new Thickness(0.1 * canvas.Width, 0.1 * canvas.Height, 0.1 * canvas.Width, 25);
                }
                else
                {
                    border.Margin = new Thickness(0.1 * canvas.Width, 0.1 * canvas.Height, 0.1 * canvas.Width, 0);
                }

                hotelCardsStackPanel.Children.Add(border);

                StackPanel cardStackPanel = new StackPanel();
                border.Child = cardStackPanel;

                Grid hotelDataGrid = new Grid
                {
                    Width             = cardWidth,
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        }
                    },
                    Margin = new Thickness(0, 20, 0, 20)
                };
                cardStackPanel.Children.Add(hotelDataGrid);

                Image hotelImaege = new Image
                {
                    Source   = hotel.image.GetImage().Source,
                    MaxWidth = 0.4 * cardWidth,
                    Margin   = new Thickness(0.05 * cardWidth, 0, 0.05 * cardWidth, 0)
                };
                Grid.SetColumn(hotelImaege, 0);
                hotelDataGrid.Children.Add(hotelImaege);

                StackPanel hotelDataStackPanel = new StackPanel
                {
                    Width = 0.5 * cardWidth
                };
                Grid.SetColumn(hotelDataStackPanel, 1);
                hotelDataGrid.Children.Add(hotelDataStackPanel);

                Label hotelName = new Label
                {
                    Content  = "Name : " + hotel.name,
                    FontSize = 22
                };
                hotelDataStackPanel.Children.Add(hotelName);

                Label hotelLicenseNumber = new Label
                {
                    Content  = "License Number : " + hotel.licenseNumber,
                    FontSize = 22
                };
                hotelDataStackPanel.Children.Add(hotelLicenseNumber);

                Label locationLabal = new Label
                {
                    Content  = "Location : " + hotel.location.city + " , " + hotel.location.country,
                    FontSize = 22
                };
                hotelDataStackPanel.Children.Add(locationLabal);

                Grid buttonsGrid = new Grid
                {
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        },
                    },
                    Margin = new Thickness(0.2 * cardWidth, 0, 0, 0)
                };
                cardStackPanel.Children.Add(buttonsGrid);

                Button deleteButton = FrontEndHelper.CreateButton(80, 40, "Delete");
                deleteButton.Tag    = hotel;
                deleteButton.Click += DeleteButton_Click;
                Grid.SetColumn(deleteButton, 0);
                buttonsGrid.Children.Add(deleteButton);

                Button updatePhotoButton = FrontEndHelper.CreateButton(180, 40, "Update Hotel Photo");
                updatePhotoButton.Margin = new Thickness(0.025 * cardWidth, 0, 0, 0);
                updatePhotoButton.Tag    = hotel;
                updatePhotoButton.Click += UpdatePhotoButton_Click;
                Grid.SetColumn(updatePhotoButton, 1);
                buttonsGrid.Children.Add(updatePhotoButton);

                Button addFacilityPhoto = FrontEndHelper.CreateButton(180, 40, "Add Facility Photo");
                addFacilityPhoto.Margin = new Thickness(0.025 * cardWidth, 0, 0, 0);
                addFacilityPhoto.Tag    = hotel;
                addFacilityPhoto.Click += AddFacilityPhoto_Click;
                Grid.SetColumn(addFacilityPhoto, 2);
                buttonsGrid.Children.Add(addFacilityPhoto);

                Button addMealPlanButton = FrontEndHelper.CreateButton(160, 40, "Add meal plan");
                addMealPlanButton.Margin = new Thickness(0.025 * cardWidth, 0, 0, 0);
                addMealPlanButton.Tag    = new List <object>();
                ((List <object>)addMealPlanButton.Tag).Add(hotel);
                addMealPlanButton.Click += AddMealPlanButton_Click;
                Grid.SetColumn(addMealPlanButton, 3);
                buttonsGrid.Children.Add(addMealPlanButton);

                //add expander
                Expander moreDataExpander = new Expander
                {
                    Width  = cardWidth,
                    Header = "More Data"
                };
                cardStackPanel.Children.Add(moreDataExpander);

                TabControl moreDataTabs = new TabControl();
                moreDataExpander.Content = moreDataTabs;
                moreDataTabs.Background  = new SolidColorBrush(Color.FromRgb(239, 239, 239));

                //add meals tab
                TabItem MealsTab = new TabItem {
                    Header = "Meals"
                };
                StackPanel MealsPanel = new StackPanel();
                MealsTab.Content = MealsPanel;
                moreDataTabs.Items.Add(MealsTab);

                ListBox mealsPlanListBox = new ListBox
                {
                    Width = cardWidth
                };
                ((List <object>)addMealPlanButton.Tag).Add(mealsPlanListBox);
                MealsPanel.Children.Add(mealsPlanListBox);

                for (int j = 0; j < hotel.mealPlans.Count; j++)
                {
                    MealPlan    mealPlan     = hotel.mealPlans[j];
                    ListBoxItem mealPlanItem = new ListBoxItem
                    {
                        Content  = mealPlan,
                        FontSize = 22,
                    };
                    mealsPlanListBox.Items.Add(mealPlanItem);
                }

                //add hotel facilities
                TabItem hotelFacilitiesPhotosTab = new TabItem {
                    Header = "Photos"
                };
                Canvas hotelPhotosCanvas = new Canvas
                {
                    Width  = cardWidth,
                    Height = 300
                };
                hotelFacilitiesPhotosTab.Content = hotelPhotosCanvas;
                moreDataTabs.Items.Add(hotelFacilitiesPhotosTab);

                List <CustomImage> images = new List <CustomImage>();
                images.Add(hotel.image);
                foreach (HotelFacility facility in hotel.facilities)
                {
                    images.Add(facility.image);
                }
                ImageAlbum hotelAlbum = new ImageAlbum(hotelPhotosCanvas, 25, 25, 250, 250, images);
            }
        }